From 3a4acb9fa9e9ff3b95ef09ead222888b1763cac3 Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Thu, 17 Jan 2019 22:40:18 -0800 Subject: [PATCH] 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',