@@ -0,0 +1,1558 @@
+%22%22%22%0AThis file contains the necessary functions to determine whether we should tear%0Athe first page from a PDF file, and actually tear it.%0A%22%22%22%0Aimport tearpages%0A%0A%0A# List of bad publishers which adds an extra useless first page, which can be%0A# teared. Please, submit a PR to include new ones which I may not be aware of!%0ABAD_PUBLISHERS = %5B%0A    %22IOP%22%0A%5D%0A%0A%0Adef tearpage_needed(bibtex):%0A    %22%22%22%0A    Check whether a given paper needs the first page to be teared or not.%0A%0A    :params bibtex: The bibtex entry associated to the paper, to guess %5C%0A            whether tearing is needed.%0A    :returns: A boolean indicating whether first page should be teared or not.%0A    %22%22%22%0A    # For each bad publisher, look for it in the publisher bibtex entry%0A    has_bad_publisher = %5Bp in bibtex.get(%22publisher%22, %5B%5D)%0A                         for p in BAD_PUBLISHERS%5D%0A    # Return True iff there is at least one bad publisher%0A    return (True in has_bad_publisher)%0A%0A%0Adef tearpage(filename, bibtex=None):%0A    %22%22%22%0A    Tear the first page of the file if needed.%0A%0A    :params filename: Path to the file to handle.%0A    :params bibtex: BibTeX dict associated to this file, as the one given by %5C%0A            %60%60bibtexparser%60%60.%0A    :returns: A boolean indicating whether the file has been teared or not. %5C%0A            Side effect is tearing the first page from the file.%0A    %22%22%22%0A    if bibtex is not None and tearpage_needed(bibtex):%0A        # If tearing is needed, do it and return True%0A        tearpages.tearpage(filename)%0A        return True%0A    # Else, simply return False%0A    return False%0A

Add some functions to tear first pages from a PDF