This commit is contained in:
Phyks 2014-08-03 21:52:01 +02:00
parent a07c2ea292
commit f311de7043
2 changed files with 8 additions and 8 deletions

14
bmc.py
View File

@ -27,7 +27,7 @@ def checkBibtex(filename, bibtex_string):
bibtex = BibTexParser(bibtex_string) bibtex = BibTexParser(bibtex_string)
bibtex = bibtex.get_entry_dict() bibtex = bibtex.get_entry_dict()
try: try:
bibtex = bibtex[bibtex.keys()[0]] bibtex = bibtex[list(bibtex.keys())[0]]
# Check entries are correct # Check entries are correct
assert bibtex['title'] assert bibtex['title']
if bibtex['type'] == 'article': if bibtex['type'] == 'article':
@ -58,7 +58,7 @@ def checkBibtex(filename, bibtex_string):
bibtex = bibtex.get_entry_dict() bibtex = bibtex.get_entry_dict()
try: try:
bibtex = bibtex[bibtex.keys()[0]] bibtex = bibtex[list(bibtex.keys())[0]]
except KeyError: except KeyError:
tools.warning("Invalid bibtex entry") tools.warning("Invalid bibtex entry")
bibtex_string = '' bibtex_string = ''
@ -176,7 +176,7 @@ def addFile(src, filetype, manual, autoconfirm, tag):
bibtex = BibTexParser(bibtex) bibtex = BibTexParser(bibtex)
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 = list(bibtex.keys()[0]
bibtex = bibtex[bibtex_name] bibtex = bibtex[bibtex_name]
bibtex_string = tools.parsed2Bibtex(bibtex) bibtex_string = tools.parsed2Bibtex(bibtex)
else: else:
@ -310,7 +310,7 @@ def openFile(ident):
tools.warning("Unable to open index file.") tools.warning("Unable to open index file.")
return False return False
if ident not in bibtex.keys(): if ident not in list(bibtex.keys()):
return False return False
else: else:
subprocess.Popen(['xdg-open', bibtex[ident]['file']]) subprocess.Popen(['xdg-open', bibtex[ident]['file']])
@ -337,7 +337,7 @@ def resync():
if filename == '': if filename == '':
break break
else: else:
if 'doi' in entry.keys(): if 'doi' in list(entry.keys()):
doi = fetcher.findDOI(filename) doi = fetcher.findDOI(filename)
if doi is not False and doi != entry['doi']: if doi is not False and doi != entry['doi']:
loop = tools.rawInput("Found DOI does not " + loop = tools.rawInput("Found DOI does not " +
@ -345,7 +345,7 @@ def resync():
"DOI, continue anyway " + "DOI, continue anyway " +
"? [y/N]") "? [y/N]")
loop = (loop.lower() != 'y') loop = (loop.lower() != 'y')
if 'Eprint' in entry.keys(): if 'Eprint' in list(entry.keys()):
arxiv = fetcher.findArXivId(filename) arxiv = fetcher.findArXivId(filename)
if arxiv is not False and arxiv != entry['Eprint']: if arxiv is not False and arxiv != entry['Eprint']:
loop = tools.rawInput("Found arXiv id does " + loop = tools.rawInput("Found arXiv id does " +
@ -353,7 +353,7 @@ def resync():
"entry arxiv id, " + "entry arxiv id, " +
"continue anyway ? [y/N]") "continue anyway ? [y/N]")
loop = (loop.lower() != 'y') loop = (loop.lower() != 'y')
if 'isbn' in entry.keys(): if 'isbn' in list(entry.keys()):
isbn = fetcher.findISBN(filename) isbn = fetcher.findISBN(filename)
if isbn is not False and isbn != entry['isbn']: if isbn is not False and isbn != entry['isbn']:
loop = tools.rawInput("Found ISBN does not " + loop = tools.rawInput("Found ISBN does not " +

View File

@ -247,7 +247,7 @@ def doi2Bib(doi):
try: try:
if dict(r.info())['Content-Type'] == 'application/x-bibtex': if dict(r.info())['Content-Type'] == 'application/x-bibtex':
return r.read() return r.read().decode('utf-8')
else: else:
return '' return ''
except KeyError: except KeyError: