From c9aa8ddd41bb13835e4a5c0d694ec7b6a0e85b7c Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sun, 10 May 2020 09:53:04 +0900 Subject: [PATCH] fix side-effects of merge, and deprecation warnings --- changelog.md | 2 +- pubs/color.py | 2 +- pubs/commands/remove_cmd.py | 2 +- pubs/filebroker.py | 2 +- tests/str_fixtures.py | 20 ++++++++++---------- tests/test_queries.py | 8 ++++---- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/changelog.md b/changelog.md index fe627c4..f7aeafb 100644 --- a/changelog.md +++ b/changelog.md @@ -8,7 +8,7 @@ ### Implemented enhancements - Added support for non-standard bibtex types, e.g. @collection, @software, etc. ([#226](https://github.com/pubs/pubs/pull/226) -- The number of displayed authors in listings is now configurable, as the `n_authors` value in the `main` section of the configuration. ([#225](https://github.com/pubs/pubs/pull/225) +- The number of displayed authors in listings is now configurable, as the `max_authors` value in the `main` section of the configuration. ([#225](https://github.com/pubs/pubs/pull/225) ### Fixed bugs diff --git a/pubs/color.py b/pubs/color.py index 86e8622..0e41cf9 100644 --- a/pubs/color.py +++ b/pubs/color.py @@ -144,7 +144,7 @@ def setup(conf, force_colors=False): # undye -undye_re = re.compile('\x1b\[[;\d]*[A-Za-z]') +undye_re = re.compile('\x1b\\[[;\d]*[A-Za-z]') def undye(s): """Purge string s of color""" diff --git a/pubs/commands/remove_cmd.py b/pubs/commands/remove_cmd.py index cad1fda..e09039c 100644 --- a/pubs/commands/remove_cmd.py +++ b/pubs/commands/remove_cmd.py @@ -30,7 +30,7 @@ def command(conf, args): if force is None: to_remove_str = '\n'.join(pretty.paper_oneliner(rp.pull_paper(key), - n_authors=conf['main']['n_authors']) + max_authors=conf['main']['max_authors']) for key in keys) are_you_sure = (("Are you sure you want to delete the following publication{}" " (this will also delete associated documents)?:\n{}\n") diff --git a/pubs/filebroker.py b/pubs/filebroker.py index f48ba93..7043f4c 100644 --- a/pubs/filebroker.py +++ b/pubs/filebroker.py @@ -16,7 +16,7 @@ def filter_filename(filename, ext): """ Return the filename without the extension if the extension matches ext. Otherwise return None """ - pattern = '.*\{}$'.format(ext) + pattern = '.*\\{}$'.format(ext) if re.match(pattern, filename) is not None: return u_maybe(filename[:-len(ext)]) diff --git a/tests/str_fixtures.py b/tests/str_fixtures.py index 1372a80..d2fbfec 100644 --- a/tests/str_fixtures.py +++ b/tests/str_fixtures.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals -bibtex_external0 = """ +bibtex_external0 = r""" @techreport{Page99, number = {1999-66}, month = {November}, @@ -17,7 +17,7 @@ institution = {Stanford InfoLab}, } """ -bibtex_external_alt = """ +bibtex_external_alt = r""" @techreport{Page99, number = {1999-66}, month = {November}, @@ -33,7 +33,7 @@ institution = {Stanford InfoLab}, } """ -bibtex_raw0 = """@techreport{ +bibtex_raw0 = r"""@techreport{ Page99, author = "Page, Lawrence and Brin, Sergey and Motwani, Rajeev and Winograd, Terry", publisher = "Stanford InfoLab", @@ -50,12 +50,12 @@ bibtex_raw0 = """@techreport{ """ -metadata_raw0 = """docfile: docsdir://Page99.pdf +metadata_raw0 = r"""docfile: docsdir://Page99.pdf tags: [search, network] added: '2013-11-14 13:14:20' """ -turing_bib = """@article{turing1950computing, +turing_bib = r"""@article{turing1950computing, title={Computing machinery and intelligence}, author={Turing, Alan M}, journal={Mind}, @@ -75,7 +75,7 @@ added: '2013-11-14 13:14:20' """ # Should not parse (see #113) -bibtex_no_citekey = """@Manual{, +bibtex_no_citekey = r"""@Manual{, title = {R: A Language and Environment for Statistical Computing}, author = {{R Core Team}}, organization = {R Foundation for Statistical Computing}, @@ -85,7 +85,7 @@ bibtex_no_citekey = """@Manual{, } """ -bibtex_month = """@inproceedings{Goyal2017, +bibtex_month = r"""@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}, @@ -94,15 +94,15 @@ bibtex_month = """@inproceedings{Goyal2017, } """ -not_bibtex = """@misc{this looks, +not_bibtex = r"""@misc{this looks, like = a = bibtex file but , is not a real one! """ -bibtex_with_latex = """@article{kjaer2018large, +bibtex_with_latex = r"""@article{kjaer2018large, title={A large impact crater beneath Hiawatha Glacier in northwest Greenland}, - author={Kj{\\ae}r, Kurt H and Larsen, Nicolaj K and Binder, Tobias and Bj{\\o}rk, Anders A and Eisen, Olaf and Fahnestock, Mark A and Funder, Svend and Garde, Adam A and Haack, Henning and Helm, Veit and others}, + author={Kj{\ae}r, Kurt H and Larsen, Nicolaj K and Binder, Tobias and Bj{\o}rk, Anders A and Eisen, Olaf and Fahnestock, Mark A and Funder, Svend and Garde, Adam A and Haack, Henning and Helm, Veit and others}, journal={Science advances}, volume={4}, number={11}, diff --git a/tests/test_queries.py b/tests/test_queries.py index 207c4fc..a0ca6c7 100644 --- a/tests/test_queries.py +++ b/tests/test_queries.py @@ -200,8 +200,8 @@ class TestFilterPaper(unittest.TestCase): def test_latex_enc(self): latexenc_paper = doe_paper.deepcopy() - latexenc_paper.bibentry['Doe2013']['title'] = "{E}l Ni{\~n}o" - latexenc_paper.bibentry['Doe2013']['author'][0] = "Erd\H{o}s, Paul" + latexenc_paper.bibentry['Doe2013']['title'] = r"{E}l Ni{\~n}o" + latexenc_paper.bibentry['Doe2013']['author'][0] = r"Erd\H{o}s, Paul" self.assertTrue(get_paper_filter(['title:El'])(latexenc_paper)) self.assertTrue(get_paper_filter(['title:Niño'])(latexenc_paper)) self.assertTrue(get_paper_filter(['author:erdős'])(latexenc_paper)) @@ -209,12 +209,12 @@ class TestFilterPaper(unittest.TestCase): def test_normalize_unicode(self): latexenc_paper = doe_paper.deepcopy() - latexenc_paper.bibentry['Doe2013']['title'] = "{E}l Ni{\~n}o" + latexenc_paper.bibentry['Doe2013']['title'] = r"{E}l Ni{\~n}o" self.assertTrue(get_paper_filter(['title:Nin\u0303o'])(latexenc_paper)) def test_strict(self): latexenc_paper = doe_paper.deepcopy() - latexenc_paper.bibentry['Doe2013']['title'] = "El Ni{\~n}o" + latexenc_paper.bibentry['Doe2013']['title'] = r"El Ni{\~n}o" self.assertFalse(get_paper_filter( ['title:Nin\u0303o'], strict=True)(latexenc_paper))