From 613f082471b4ad58cf4e8256f8e7f3855c79ba00 Mon Sep 17 00:00:00 2001 From: Phyks Date: Sun, 27 Apr 2014 10:06:30 +0200 Subject: [PATCH] Upgrade to latest version of bibtex-parser --- README.md | 2 +- main.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 148b8a2..0f70a49 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ Here are some sources of inspirations for this project : A list of ideas and TODO. Don't hesitate to give feedback on the ones you really want or to propose your owns. * Open +* Use bibtex-parser lib to write bibtex, instead of parsed2BibTex * Parameter to disable remote search * Rebuild * Webserver interface @@ -119,5 +120,4 @@ A list of ideas and TODO. Don't hesitate to give feedback on the ones you really See upstream -* homogeneize\_latex\_encoding => to implement again, bug with metadata upstream * Remove the watermarks on pdf files => done, some warning in okular on generated pdf, but seems ok. Seems to be a bug in PyPDF2. diff --git a/main.py b/main.py index 0d9f330..c240631 100755 --- a/main.py +++ b/main.py @@ -19,6 +19,8 @@ try: except: from StringIO import StringIO from bibtexparser.bparser import BibTexParser +from bibtexparser.customization import homogeneize_latex_encoding +from bibtexparser.bwriter import bibtex as bibTexWriter from termios import tcflush, TCIOFLUSH import params @@ -211,8 +213,7 @@ def getExtension(filename): def checkBibtex(filename, bibtex): print("The bibtex entry found for "+filename+" is :") - bibtex = StringIO(bibtex) - bibtex = BibTexParser(bibtex) + bibtex = BibTexParser(bibtex, customization=homogeneize_latex_encoding) bibtex = bibtex.get_entry_dict() if len(bibtex) > 0: bibtex_name = bibtex.keys()[0] @@ -228,7 +229,7 @@ def checkBibtex(filename, bibtex): tmpfile.write(bibtex_string) tmpfile.flush() subprocess.call([EDITOR, tmpfile.name]) - bibtex = BibTexParser(StringIO(tmpfile.read()+"\n")) + bibtex = BibTexParser(tmpfile.read()+"\n", customization=homogeneize_latex_encoding) bibtex = bibtex.get_entry_dict() if len(bibtex) > 0: @@ -341,7 +342,7 @@ def deleteId(ident): Delete a file based on its id in the bibtex file """ with open(params.folder+'index.bib', 'r') as fh: - bibtex = BibTexParser(fh) + bibtex = BibTexParser(fh.read(), customization=homogeneize_latex_encoding) bibtex = bibtex.get_entry_dict() if ident not in bibtex.keys(): @@ -362,7 +363,7 @@ def deleteFile(filename): Delete a file based on its filename """ with open(params.folder+'index.bib', 'r') as fh: - bibtex = BibTexParser(fh) + bibtex = BibTexParser(fh.read(), customization=homogeneize_latex_encoding) bibtex = bibtex.get_entry_dict() found = False