Use journal instead of publisher for page tearing

This commit is contained in:
Lucas Verney 2016-01-30 17:18:32 +01:00
parent 9853469f3c
commit 5f42e7ca6c

View File

@ -10,12 +10,14 @@ from PyPDF2 import PdfFileWriter, PdfFileReader
from PyPDF2.utils import PdfReadError from PyPDF2.utils import PdfReadError
# Dict of bad publishers which adds an extra useless first page, which can be # Dict of bad journals which adds an extra useless first page, which can be
# teared. Please, submit a PR to include new ones which I may not be aware of! # teared. Please, submit a PR to include new ones which I may not be aware of!
# This dict associates the publisher string to look for and to a list of pages # This dict associates the journal string to look for and to a list of pages
# to tear. # to tear.
BAD_PUBLISHERS = { BAD_JOURNALS = {
"IOP": [0] "epl": [0],
"journal of modern optics": [0],
"new journal of physics": [0]
} }
@ -87,12 +89,12 @@ def tearpage_needed(bibtex):
whether tearing is needed. whether tearing is needed.
:returns: A list of pages to tear. :returns: A list of pages to tear.
""" """
for p in BAD_PUBLISHERS: for p in BAD_JOURNALS:
if p in bibtex.get("publisher", ""): if p in bibtex.get("journal", "").lower():
# Bad publisher is found, add pages to tear # Bad journal is found, add pages to tear
return BAD_PUBLISHERS[p] return BAD_JOURNALS[p]
# If no bad publishers are found, return an empty list # If no bad journals are found, return an empty list
return [] return []