Bugfixes in checkBibtex

* except too wide on first y / N
* clean user input for isbn (remove '-' and ' ')
* forgot a tools.
This commit is contained in:
Phyks 2014-06-11 14:50:57 +02:00
parent e538c16a42
commit 855e6fa1fc
2 changed files with 8 additions and 4 deletions

View File

@ -142,7 +142,6 @@ 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. A list of ideas and TODO. Don't hesitate to give feedback on the ones you really want or to propose your owns.
0. Add book
60. Unittest 60. Unittest
80. Search engine 80. Search engine
85. Anti-duplicate ? 85. Anti-duplicate ?

9
bmc.py
View File

@ -27,11 +27,16 @@ def checkBibtex(filename, bibtex_string):
bibtex = bibtex[bibtex.keys()[0]] bibtex = bibtex[bibtex.keys()[0]]
# Check entries are correct # Check entries are correct
assert bibtex['title'] assert bibtex['title']
if bibtex['type'] == 'article':
assert bibtex['authors'] assert bibtex['authors']
elif bibtex['type'] == 'book':
assert bibtex['author']
assert bibtex['year'] assert bibtex['year']
# Print the bibtex and confirm # Print the bibtex and confirm
print(parsed2Bibtex(bibtex)) print(tools.parsed2Bibtex(bibtex))
check = tools.rawInput("Is it correct? [Y/n] ") check = tools.rawInput("Is it correct? [Y/n] ")
except KeyboardInterrupt:
sys.exit()
except: except:
check = 'n' check = 'n'
@ -139,7 +144,7 @@ def addFile(src, filetype, manual, autoconfirm, tag):
while isbn_manual not in ['isbn', 'manual', 'skip']: while isbn_manual not in ['isbn', 'manual', 'skip']:
isbn_manual = tools.rawInput("ISBN / manual / skip? ").lower() isbn_manual = tools.rawInput("ISBN / manual / skip? ").lower()
if isbn_manual == 'isbn': if isbn_manual == 'isbn':
isbn = tools.rawInput('ISBN? ') isbn = tools.rawInput('ISBN? ').replace(' ', '').replace('-', '')
elif isbn_manual == 'skip': elif isbn_manual == 'skip':
return False return False
elif doi is not False: elif doi is not False: