From 855e6fa1fca8248c4157644573f0f9469a8e884f Mon Sep 17 00:00:00 2001 From: Phyks Date: Wed, 11 Jun 2014 14:50:57 +0200 Subject: [PATCH] Bugfixes in checkBibtex * except too wide on first y / N * clean user input for isbn (remove '-' and ' ') * forgot a tools. --- README.md | 1 - bmc.py | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c10746d..48991c9 100644 --- a/README.md +++ b/README.md @@ -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. -0. Add book 60. Unittest 80. Search engine 85. Anti-duplicate ? diff --git a/bmc.py b/bmc.py index 96d1654..bff711c 100755 --- a/bmc.py +++ b/bmc.py @@ -27,11 +27,16 @@ def checkBibtex(filename, bibtex_string): bibtex = bibtex[bibtex.keys()[0]] # Check entries are correct assert bibtex['title'] - assert bibtex['authors'] + if bibtex['type'] == 'article': + assert bibtex['authors'] + elif bibtex['type'] == 'book': + assert bibtex['author'] assert bibtex['year'] # Print the bibtex and confirm - print(parsed2Bibtex(bibtex)) + print(tools.parsed2Bibtex(bibtex)) check = tools.rawInput("Is it correct? [Y/n] ") + except KeyboardInterrupt: + sys.exit() except: check = 'n' @@ -139,7 +144,7 @@ def addFile(src, filetype, manual, autoconfirm, tag): while isbn_manual not in ['isbn', 'manual', 'skip']: isbn_manual = tools.rawInput("ISBN / manual / skip? ").lower() if isbn_manual == 'isbn': - isbn = tools.rawInput('ISBN? ') + isbn = tools.rawInput('ISBN? ').replace(' ', '').replace('-', '') elif isbn_manual == 'skip': return False elif doi is not False: