Merge pull request #123 from benureau/fix/common_strings
Fix/common strings Fix the regression on translating month abbreviations into full month names in bibtex files.
This commit is contained in:
commit
0a0ed06c92
@ -113,14 +113,10 @@ class EnDecoder(object):
|
|||||||
def decode_bibdata(self, bibdata):
|
def decode_bibdata(self, bibdata):
|
||||||
""""""
|
""""""
|
||||||
try:
|
try:
|
||||||
try:
|
entries = bp.bparser.BibTexParser(
|
||||||
entries = bp.bparser.BibTexParser(
|
bibdata, common_strings=True,
|
||||||
bibdata, homogenize_fields=True,
|
customization=customizations,
|
||||||
customization=customizations).get_entry_dict()
|
homogenize_fields=True).get_entry_dict()
|
||||||
except TypeError:
|
|
||||||
entries = bp.bparser.BibTexParser(
|
|
||||||
bibdata,
|
|
||||||
customization=customizations).get_entry_dict()
|
|
||||||
|
|
||||||
# Remove id from bibtexparser attribute which is stored as citekey
|
# Remove id from bibtexparser attribute which is stored as citekey
|
||||||
for e in entries:
|
for e in entries:
|
||||||
|
2
setup.py
2
setup.py
@ -25,7 +25,7 @@ setup(
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
install_requires=['pyyaml', 'bibtexparser>=1.0.1', 'python-dateutil', 'requests',
|
install_requires=['pyyaml', 'bibtexparser>=1.0', 'python-dateutil', 'requests',
|
||||||
'configobj',
|
'configobj',
|
||||||
'beautifulsoup4'], # to be made optional?
|
'beautifulsoup4'], # to be made optional?
|
||||||
tests_require=['pyfakefs>=2.7'],
|
tests_require=['pyfakefs>=2.7'],
|
||||||
|
@ -69,6 +69,14 @@ bibtex_no_citekey = """@Manual{,
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
bibtex_month= """@inproceedings{Goyal2017,
|
||||||
|
author = {Goyal, Anirudh and Sordoni, Alessandro and C{\^{o}}t{\'{e}}, Marc-Alexandre and Ke, Nan Rosemary and Bengio, Yoshua},
|
||||||
|
title = {Z-Forcing: Training Stochastic Recurrent Networks},
|
||||||
|
year = {2017},
|
||||||
|
month = dec,
|
||||||
|
pages = {6716--6726},
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
sample_conf = """
|
sample_conf = """
|
||||||
[main]
|
[main]
|
||||||
|
@ -9,7 +9,7 @@ from pubs import endecoder
|
|||||||
from pubs.p3 import ustr
|
from pubs.p3 import ustr
|
||||||
|
|
||||||
from fixtures import dummy_metadata
|
from fixtures import dummy_metadata
|
||||||
from str_fixtures import bibtex_raw0, metadata_raw0, turing_bib
|
from str_fixtures import bibtex_raw0, metadata_raw0, turing_bib, bibtex_month
|
||||||
|
|
||||||
|
|
||||||
def compare_yaml_str(s1, s2):
|
def compare_yaml_str(s1, s2):
|
||||||
@ -35,6 +35,7 @@ class TestEnDecode(unittest.TestCase):
|
|||||||
self.assertIsInstance(data, ustr)
|
self.assertIsInstance(data, ustr)
|
||||||
|
|
||||||
def test_endecode_bibtex(self):
|
def test_endecode_bibtex(self):
|
||||||
|
"""Test that multiple encode/decode step preserve data"""
|
||||||
decoder = endecoder.EnDecoder()
|
decoder = endecoder.EnDecoder()
|
||||||
entry = decoder.decode_bibdata(bibtex_raw0)
|
entry = decoder.decode_bibdata(bibtex_raw0)
|
||||||
|
|
||||||
@ -51,6 +52,14 @@ class TestEnDecode(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(bibraw1, bibraw2)
|
self.assertEqual(bibraw1, bibraw2)
|
||||||
|
|
||||||
|
def test_endecode_bibtex(self):
|
||||||
|
"""Test if `month=dec` is correctly recognized and transformed into
|
||||||
|
`month={December}`"""
|
||||||
|
decoder = endecoder.EnDecoder()
|
||||||
|
entry = decoder.decode_bibdata(bibtex_month)['Goyal2017']
|
||||||
|
|
||||||
|
self.assertEqual(entry['month'], 'December')
|
||||||
|
|
||||||
def test_endecode_bibtex_editor(self):
|
def test_endecode_bibtex_editor(self):
|
||||||
decoder = endecoder.EnDecoder()
|
decoder = endecoder.EnDecoder()
|
||||||
entry = decoder.decode_bibdata(turing_bib)
|
entry = decoder.decode_bibdata(turing_bib)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user