Skip to content

Commit

Permalink
Fix Unicode handling and cache query results in
Browse files Browse the repository at this point in the history
check_biblio.py
  • Loading branch information
wiso committed Nov 15, 2023
1 parent 853d7b5 commit 3061424
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions check_biblio.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def diff_strings(a: str, b: str) -> str:
return "".join(output)


regex_unicode = re.compile("[^\x00-\x7F]")
def help_unicode(item: str) -> Optional[str]:
m = regex_unicode.search(item)
if m:
Expand Down Expand Up @@ -217,10 +218,10 @@ def run_entry(entry, db, fix_unicode, substitutions):
raw_original = entry.raw.strip()
raw_proposed = raw_original

raw_proposed = db.query(raw_original)
if raw_proposed is not None:
if raw_original != raw_proposed:
substitutions.append((raw_original, raw_proposed))
from_cache = db.query(raw_original)
if from_cache is not None:
if raw_original != from_cache:
substitutions.append((raw_original, from_cache))
return

if fix_unicode:
Expand Down Expand Up @@ -255,9 +256,6 @@ def run_entry(entry, db, fix_unicode, substitutions):
)
args = parser.parse_args()

regex_unicode = re.compile("[^\x00-\x7F]")
regex_latex_error = re.compile("Error", re.IGNORECASE)

try:
substitutions = []
biblio_parsed = bibtexparser.parse_file(args.bibtex)
Expand Down

0 comments on commit 3061424

Please sign in to comment.