From e58ae98b93b8364a07fd5f5f452ba88ad332c948 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Fri, 18 Jan 2019 13:51:39 +0900 Subject: [PATCH] fix for 187 --- pubs/commands/import_cmd.py | 1 - pubs/endecoder.py | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pubs/commands/import_cmd.py b/pubs/commands/import_cmd.py index 6d51488..948d10d 100644 --- a/pubs/commands/import_cmd.py +++ b/pubs/commands/import_cmd.py @@ -54,7 +54,6 @@ def many_from_path(ui, bibpath, ignore=False): bibpath = system_path(bibpath) if os.path.isdir(bibpath): - print([os.path.splitext(f)[-1][1:] for f in os.listdir(bibpath)]) all_files = [os.path.join(bibpath, f) for f in os.listdir(bibpath) if os.path.splitext(f)[-1][1:] == 'bib'] else: diff --git a/pubs/endecoder.py b/pubs/endecoder.py index abac0f1..0322b02 100644 --- a/pubs/endecoder.py +++ b/pubs/endecoder.py @@ -122,7 +122,7 @@ class EnDecoder(object): def decode_bibdata(self, bibdata): """Decodes bibdata from string. - If the decoding fails, returns a BibParseError. + If the decoding fails, returns a BibDecodingError. """ if len(bibdata) == 0: error_msg = 'parsing error: the provided string has length zero.' @@ -131,7 +131,6 @@ class EnDecoder(object): entries = bp.bparser.BibTexParser( bibdata, common_strings=True, customization=customizations, homogenize_fields=True).get_entry_dict() - # Remove id from bibtexparser attribute which is stored as citekey for e in entries: entries[e].pop(BP_ID_KEY) @@ -140,6 +139,9 @@ class EnDecoder(object): entries[e][TYPE_KEY] = t if len(entries) > 0: return entries + else: + raise self.BibDecodingError(('no valid entry found in the provided data: ' + ' {}').format(bibdata), bibdata) except (pyparsing.ParseException, pyparsing.ParseSyntaxException) as e: error_msg = self._format_parsing_error(e) raise self.BibDecodingError(error_msg, bibdata)