Move file if filename edited in checkBibtex()
This commit is contained in:
parent
73f3fe7778
commit
453a30f4ca
12
main.py
12
main.py
@ -31,6 +31,7 @@ def checkBibtex(filename, bibtex):
|
||||
bibtex_string = ''
|
||||
print(bibtex_string)
|
||||
check = tools.rawInput("Is it correct? [Y/n] ")
|
||||
old_filename = bibtex['file']
|
||||
|
||||
while check.lower() == 'n':
|
||||
with tempfile.NamedTemporaryFile(suffix=".tmp") as tmpfile:
|
||||
@ -41,6 +42,11 @@ def checkBibtex(filename, bibtex):
|
||||
customization=homogeneize_latex_encoding)
|
||||
|
||||
bibtex = bibtex.get_entry_dict()
|
||||
if 'file' not in bibtex:
|
||||
tools.warning("Invalid bibtex entry. No filename given.")
|
||||
tools.rawInput("Press Enter to go back to editor.")
|
||||
check = 'n'
|
||||
else:
|
||||
if len(bibtex) > 0:
|
||||
bibtex_name = bibtex.keys()[0]
|
||||
bibtex = bibtex[bibtex_name]
|
||||
@ -50,6 +56,12 @@ def checkBibtex(filename, bibtex):
|
||||
print("\nThe bibtex entry for "+filename+" is:")
|
||||
print(bibtex_string)
|
||||
check = tools.rawInput("Is it correct? [Y/n] ")
|
||||
if old_filename != bibtex['file']:
|
||||
try:
|
||||
shutil.move(old_filename, bibtex['file'])
|
||||
except:
|
||||
tools.warning("Unable to move file "+old_filename+" to " +
|
||||
bibtex['file']+". You should check it manually.")
|
||||
return bibtex
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user