From 3a4acb9fa9e9ff3b95ef09ead222888b1763cac3 Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Thu, 17 Jan 2019 22:40:18 -0800 Subject: [PATCH 1/3] Partial fix for #188 --- pubs/endecoder.py | 7 ++++++- tests/data/many_fields.bib | 16 ++++++++++++++++ tests/test_usecase.py | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tests/data/many_fields.bib diff --git a/pubs/endecoder.py b/pubs/endecoder.py index 0322b02..e334eb1 100644 --- a/pubs/endecoder.py +++ b/pubs/endecoder.py @@ -113,7 +113,7 @@ class EnDecoder(object): author for author in entry['author']) if 'editor' in entry: entry['editor'] = ' and '.join( - editor['name'] for editor in entry['editor']) + editor for editor in entry['editor']) if 'keyword' in entry: entry['keyword'] = ', '.join( keyword for keyword in entry['keyword']) @@ -137,6 +137,11 @@ class EnDecoder(object): # Convert bibtexparser entrytype key to internal 'type' t = entries[e].pop(BP_ENTRYTYPE_KEY) entries[e][TYPE_KEY] = t + # Temporary fix to #188 (to be fully fixed when the upstream + # issue: sciunto-org/python-bibtexparser/#229 is fixed too) + if 'editor' in entries[e]: + entries[e]['editor'] = [ + editor['name'] for editor in entries[e]['editor']] if len(entries) > 0: return entries else: diff --git a/tests/data/many_fields.bib b/tests/data/many_fields.bib new file mode 100644 index 0000000..0a4c11f --- /dev/null +++ b/tests/data/many_fields.bib @@ -0,0 +1,16 @@ +@ARTICLE{Cesar2013, + authors = {Jean César}, + title = {An amazing title}, + year = {2013}, + month = "jan", + volume = {12}, + pages = {12-23}, + journal = {Nice Journal}, + abstract = {This is an abstract. This line should be long enough to test +multilines... and with a french érudit word}, + comments = {A comment}, + editors = {Edith Or and Anne Other}, + keywords = {keyword1, keyword2}, + links = {http://my.link/to-content}, + subjects = "Some topic of interest", +} diff --git a/tests/test_usecase.py b/tests/test_usecase.py index 952cb1b..c83a626 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -861,7 +861,7 @@ class TestUsecase(DataCommandTestCase): ] outs = self.execute_cmds(cmds) - self.assertEqual(8, len(outs[-1].split('\n'))) + self.assertEqual(9, len(outs[-1].split('\n'))) def test_import_one(self): cmds = ['pubs init', From 33fc910925245daad1a2a5c2aa77640b5bcbe7bd Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Thu, 17 Jan 2019 22:49:30 -0800 Subject: [PATCH 2/3] Makes the fix robust to the expected future change in bibtexparser --- pubs/endecoder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubs/endecoder.py b/pubs/endecoder.py index e334eb1..346af3a 100644 --- a/pubs/endecoder.py +++ b/pubs/endecoder.py @@ -141,7 +141,8 @@ class EnDecoder(object): # issue: sciunto-org/python-bibtexparser/#229 is fixed too) if 'editor' in entries[e]: entries[e]['editor'] = [ - editor['name'] for editor in entries[e]['editor']] + editor['name'] if isinstance(editor, dict) else editor + for editor in entries[e]['editor']] if len(entries) > 0: return entries else: @@ -154,7 +155,6 @@ class EnDecoder(object): error_msg = 'parsing error: undefined string in provided data: {}'.format(e) raise self.BibDecodingError(error_msg, bibdata) - @classmethod def _format_parsing_error(cls, e): """Transform a pyparsing exception into an error message From dca084d6f287ad49a410de4ba9b00aa1c51dad2c Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Thu, 17 Jan 2019 22:52:38 -0800 Subject: [PATCH 3/3] Adds a post-release version to force cache rebuild. --- pubs/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubs/version.py b/pubs/version.py index 4ca39e7..2b0631f 100644 --- a/pubs/version.py +++ b/pubs/version.py @@ -1 +1 @@ -__version__ = '0.8.2' +__version__ = '0.8.2-r1'