Fixed some bugs in delete by id / file
* Remove homogeneize_latex_encoding which is problematic * Fixed encoded path to pdf files
This commit is contained in:
parent
481d3eb048
commit
204357222c
24
backend.py
24
backend.py
@ -82,8 +82,7 @@ def bibtexEdit(ident, modifs):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
||||||
bibtex = BibTexParser(fh.read(),
|
bibtex = BibTexParser(fh.read())
|
||||||
customization=homogeneize_latex_encoding)
|
|
||||||
bibtex = bibtex.get_entry_dict()
|
bibtex = bibtex.get_entry_dict()
|
||||||
except:
|
except:
|
||||||
tools.warning("Unable to open index file.")
|
tools.warning("Unable to open index file.")
|
||||||
@ -114,8 +113,7 @@ def deleteId(ident):
|
|||||||
"""Delete a file based on its id in the bibtex file"""
|
"""Delete a file based on its id in the bibtex file"""
|
||||||
try:
|
try:
|
||||||
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
||||||
bibtex = BibTexParser(fh.read(),
|
bibtex = BibTexParser(fh.read())
|
||||||
customization=homogeneize_latex_encoding)
|
|
||||||
bibtex = bibtex.get_entry_dict()
|
bibtex = bibtex.get_entry_dict()
|
||||||
except:
|
except:
|
||||||
tools.warning("Unable to open index file.")
|
tools.warning("Unable to open index file.")
|
||||||
@ -150,8 +148,7 @@ def deleteFile(filename):
|
|||||||
"""Delete a file based on its filename"""
|
"""Delete a file based on its filename"""
|
||||||
try:
|
try:
|
||||||
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
||||||
bibtex = BibTexParser(fh.read(),
|
bibtex = BibTexParser(fh.read())
|
||||||
customization=homogeneize_latex_encoding)
|
|
||||||
bibtex = bibtex.get_entry_dict()
|
bibtex = bibtex.get_entry_dict()
|
||||||
except:
|
except:
|
||||||
tools.warning("Unable to open index file.")
|
tools.warning("Unable to open index file.")
|
||||||
@ -159,6 +156,7 @@ def deleteFile(filename):
|
|||||||
|
|
||||||
found = False
|
found = False
|
||||||
for key in bibtex.keys():
|
for key in bibtex.keys():
|
||||||
|
try:
|
||||||
if os.path.samefile(bibtex[key]['file'], filename):
|
if os.path.samefile(bibtex[key]['file'], filename):
|
||||||
found = True
|
found = True
|
||||||
try:
|
try:
|
||||||
@ -179,6 +177,8 @@ def deleteFile(filename):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
tools.warning("No associated bibtex entry in index for " +
|
tools.warning("No associated bibtex entry in index for " +
|
||||||
"file " + bibtex[key]['file'])
|
"file " + bibtex[key]['file'])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if found:
|
if found:
|
||||||
bibtexRewrite(bibtex)
|
bibtexRewrite(bibtex)
|
||||||
return found
|
return found
|
||||||
@ -194,8 +194,7 @@ def diffFilesIndex():
|
|||||||
files = tools.listDir(params.folder)
|
files = tools.listDir(params.folder)
|
||||||
try:
|
try:
|
||||||
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
||||||
index = BibTexParser(fh.read(),
|
index = BibTexParser(fh.read())
|
||||||
customization=homogeneize_latex_encoding)
|
|
||||||
index_diff = index.get_entry_dict()
|
index_diff = index.get_entry_dict()
|
||||||
except:
|
except:
|
||||||
tools.warning("Unable to open index file.")
|
tools.warning("Unable to open index file.")
|
||||||
@ -221,8 +220,7 @@ def getBibtex(entry, file_id='both'):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
||||||
bibtex = BibTexParser(fh.read(),
|
bibtex = BibTexParser(fh.read())
|
||||||
customization=homogeneize_latex_encoding)
|
|
||||||
bibtex = bibtex.get_entry_dict()
|
bibtex = bibtex.get_entry_dict()
|
||||||
except:
|
except:
|
||||||
tools.warning("Unable to open index file.")
|
tools.warning("Unable to open index file.")
|
||||||
@ -246,8 +244,7 @@ def getEntries():
|
|||||||
"""Returns the list of all entries in the bibtex index"""
|
"""Returns the list of all entries in the bibtex index"""
|
||||||
try:
|
try:
|
||||||
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
||||||
bibtex = BibTexParser(fh.read(),
|
bibtex = BibTexParser(fh.read())
|
||||||
customization=homogeneize_latex_encoding)
|
|
||||||
bibtex = bibtex.get_entry_dict()
|
bibtex = bibtex.get_entry_dict()
|
||||||
except:
|
except:
|
||||||
tools.warning("Unable to open index file.")
|
tools.warning("Unable to open index file.")
|
||||||
@ -271,8 +268,7 @@ def updateArXiv(entry):
|
|||||||
arxiv_id = bibtex['Eprint']
|
arxiv_id = bibtex['Eprint']
|
||||||
last_bibtex = BibTexParser(fetcher.arXiv2Bib(re.sub(r'v\d+\Z',
|
last_bibtex = BibTexParser(fetcher.arXiv2Bib(re.sub(r'v\d+\Z',
|
||||||
'',
|
'',
|
||||||
arxiv_id)),
|
arxiv_id)))
|
||||||
customization=homogeneize_latex_encoding)
|
|
||||||
last_bibtex = last_bibtex.get_entry_dict()
|
last_bibtex = last_bibtex.get_entry_dict()
|
||||||
|
|
||||||
if last_bibtex['Eprint'] != arxiv_id:
|
if last_bibtex['Eprint'] != arxiv_id:
|
||||||
|
12
main.py
12
main.py
@ -22,8 +22,7 @@ EDITOR = os.environ.get('EDITOR') if os.environ.get('EDITOR') else 'vim'
|
|||||||
def checkBibtex(filename, bibtex):
|
def checkBibtex(filename, bibtex):
|
||||||
print("The bibtex entry found for "+filename+" is:")
|
print("The bibtex entry found for "+filename+" is:")
|
||||||
|
|
||||||
bibtex = BibTexParser(bibtex.encode('utf-8'),
|
bibtex = BibTexParser(bibtex.encode('utf-8'))
|
||||||
customization=homogeneize_latex_encoding)
|
|
||||||
bibtex = bibtex.get_entry_dict()
|
bibtex = bibtex.get_entry_dict()
|
||||||
if len(bibtex) > 0:
|
if len(bibtex) > 0:
|
||||||
bibtex_name = bibtex.keys()[0]
|
bibtex_name = bibtex.keys()[0]
|
||||||
@ -44,8 +43,7 @@ def checkBibtex(filename, bibtex):
|
|||||||
tmpfile.flush()
|
tmpfile.flush()
|
||||||
subprocess.call([EDITOR, tmpfile.name])
|
subprocess.call([EDITOR, tmpfile.name])
|
||||||
tmpfile.seek(0)
|
tmpfile.seek(0)
|
||||||
bibtex = BibTexParser(tmpfile.read().encode('utf-8')+"\n",
|
bibtex = BibTexParser(tmpfile.read().encode('utf-8')+"\n")
|
||||||
customization=homogeneize_latex_encoding)
|
|
||||||
|
|
||||||
bibtex = bibtex.get_entry_dict()
|
bibtex = bibtex.get_entry_dict()
|
||||||
if old_filename is not False and 'file' not in bibtex:
|
if old_filename is not False and 'file' not in bibtex:
|
||||||
@ -215,8 +213,7 @@ def editEntry(entry, file_id='both'):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
||||||
index = BibTexParser(fh.read(),
|
index = BibTexParser(fh.read())
|
||||||
customization=homogeneize_latex_encoding)
|
|
||||||
index = index.get_entry_dict()
|
index = index.get_entry_dict()
|
||||||
except:
|
except:
|
||||||
tools.warning("Unable to open index file.")
|
tools.warning("Unable to open index file.")
|
||||||
@ -248,8 +245,7 @@ def downloadFile(url, filetype, manual):
|
|||||||
def openFile(ident):
|
def openFile(ident):
|
||||||
try:
|
try:
|
||||||
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
with open(params.folder+'index.bib', 'r', encoding='utf-8') as fh:
|
||||||
bibtex = BibTexParser(fh.read(),
|
bibtex = BibTexParser(fh.read())
|
||||||
customization=homogeneize_latex_encoding)
|
|
||||||
bibtex = bibtex.get_entry_dict()
|
bibtex = bibtex.get_entry_dict()
|
||||||
except:
|
except:
|
||||||
tools.warning("Unable to open index file.")
|
tools.warning("Unable to open index file.")
|
||||||
|
Loading…
Reference in New Issue
Block a user