From 41de8b5aabee2aa2b0ed2f26285f2949d209ba0b Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Wed, 26 Sep 2018 23:29:02 -0700 Subject: [PATCH 01/39] Fixes code blocks in readme.md. --- readme.md | 84 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/readme.md b/readme.md index 5b43e56..5e618e0 100644 --- a/readme.md +++ b/readme.md @@ -16,20 +16,23 @@ Pubs is built with the following principles in mind: ## Installation You can install the latest stable version of `pubs` through Pypi, with: - - pip install pubs + ``` + pip install pubs + ``` Alternatively, you can: - install the latest development version with pip: - + ``` pip install --upgrade git+https://github.com/pubs/pubs + ``` - clone the repository and install it manually: - + ``` git clone https://github.com/pubs/pubs cd pubs python setup.py install [--user] + ``` Arch Linux users can also use the [pubs-git](https://aur.archlinux.org/packages/pubs-git/) AUR package. @@ -37,28 +40,34 @@ Arch Linux users can also use the [pubs-git](https://aur.archlinux.org/packages/ ## Getting started Create your library (by default, goes to `~/.pubs/`). - - pubs init + ``` + pubs init + ``` Import existing data from bibtex (pubs will try to automatically copy documents defined as 'file' in bibtex): - - pubs import path/to/collection.bib + ``` + pubs import path/to/collection.bib + ``` or for a .bib file containing a single reference: - - pubs add reference.bib -d article.pdf + ``` + pubs add reference.bib -d article.pdf + ``` pubs can also automatically retrieve the bibtex from a doi: - - pubs add -D 10.1007/s00422-012-0514-6 -d article.pdf + ``` + pubs add -D 10.1007/s00422-012-0514-6 -d article.pdf + ``` or an ISBN (dashes are ignored): - - pubs add -I 978-0822324669 -d article.pdf + ``` + pubs add -I 978-0822324669 -d article.pdf + ``` or an arXiv id (automatically downloading arXiv article is in the works): - - pubs add -X math/9501234 -d article.pdf + ``` + pubs add -X math/9501234 -d article.pdf + ``` ## References always up-to-date @@ -66,8 +75,9 @@ or an arXiv id (automatically downloading arXiv article is in the works): If you use latex, you can automatize references, by running `pubs export > references.bib` each time you update your library, which also fits well as a `makefile` rule. This ensures that your reference file is always up-to-date; you can cite a paper in your manuscript a soon as you add it in pubs. This means that if you have, for instance, a doi on a webpage, you only need to do: - - pubs add -D 10.1007/s00422-012-0514-6 + ``` + pubs add -D 10.1007/s00422-012-0514-6 + ``` and then add `\cite{Loeb_2012}` in your manuscript. After exporting the bibliography, the citation will correctly appear in your compiled pdf. @@ -75,23 +85,25 @@ and then add `\cite{Loeb_2012}` in your manuscript. After exporting the bibliogr ## Document management You can attach a document to a reference: - - pubs add Loeb2012_downloaded.pdf Loeb_2012 + ``` + pubs add Loeb2012_downloaded.pdf Loeb_2012 + ``` And open your documents automatically from the command line: - - pubs doc open Loeb_2012 - pubs doc open --with lp Loeb_2012 # Opens the document with `lp` to actually print it. - + ``` + pubs doc open Loeb_2012 + pubs doc open --with lp Loeb_2012 # Opens the document with `lp` to actually print it. + ``` ## Customization Pubs is designed to interact well with your command line tool chain. You can add custom commands to pubs by defining aliases in your configuration file (make sure that the alias plugin is activated in your configuration by using `pubs conf`). - - [[alias]] - evince = open --with evince - count = !pubs list -k "$@" | wc -l + ```ini + [[alias]] + evince = open --with evince + count = !pubs list -k "$@" | wc -l + ``` The first command defines a new subcommand: `pubs open --with evince` will be executed when `pubs evince` is typed. The second starts with a bang: `!`, and is treated as a shell command. If other arguments are provided they are passed to the shell command as in a script. In the example above the `count` alias can take arguments that are be passed to the `pubs list -k` command, hence enabling filters like `pubs count year:2012`. @@ -102,14 +114,14 @@ The second starts with a bang: `!`, and is treated as a shell command. If other For autocompletion to work, you need the [argcomplete](https://argcomplete.readthedocs.io) Python package, and Bash 4.2 or newer. For activating *bash* or *tsch* completion, consult the [argcomplete documentation](https://argcomplete.readthedocs.io/en/latest/#global-completion). For *zsh* completion, the global activation is not supported but bash completion compatibility can be used for pubs. For that, add the following to your `.zshrc`: - - # Enable and load bashcompinit - autoload -Uz compinit bashcompinit - compinit - bashcompinit - # Argcomplete explicit registration for pubs - eval "$(register-python-argcomplete pubs)" - + ```shell + # Enable and load bashcompinit + autoload -Uz compinit bashcompinit + compinit + bashcompinit + # Argcomplete explicit registration for pubs + eval "$(register-python-argcomplete pubs)" + ``` ## Need more help ? From d931b977e493cd1b324e80766e0a2eacf77fdcdd Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Tue, 4 Dec 2018 20:36:36 -0800 Subject: [PATCH 02/39] Fix #173: add MANIFEST.in with readme. Also add package data for test fixtures. --- MANIFEST.in | 1 + setup.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..1a69f4c --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include readme.md diff --git a/setup.py b/setup.py index aa0cded..ee088a2 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ import unittest from setuptools import setup + with open('pubs/version.py') as f: exec(f.read()) # defines __version__ @@ -11,11 +12,13 @@ here = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(here, 'readme.md'), 'r') as fd: long_description = fd.read() + def pubs_test_suite(): test_loader = unittest.TestLoader() test_suite = test_loader.discover('tests', pattern='test_*.py') return test_suite + setup( name='pubs', version=__version__, @@ -40,6 +43,8 @@ setup( ], }, + include_package_data=True, + install_requires=['pyyaml', 'bibtexparser>=1.0', 'python-dateutil', 'six', 'requests', 'configobj', 'beautifulsoup4', 'feedparser'], extras_require={'autocompletion': ['argcomplete'], @@ -54,7 +59,7 @@ setup( 'Intended Audience :: Science/Research', ], - test_suite= 'tests', + test_suite='tests', tests_require=['pyfakefs>=3.4', 'mock', 'ddt'], # in order to avoid 'zipimport.ZipImportError: bad local file header' From a6c7376b51e2c674e81db78865ce8c2809196c0c Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Tue, 4 Dec 2018 20:40:34 -0800 Subject: [PATCH 03/39] Version 0.8.2 --- changelog.md | 11 ++++++++++- pubs/version.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index f3e3036..3cd48aa 100644 --- a/changelog.md +++ b/changelog.md @@ -3,7 +3,7 @@ ## Current master -[Full Changelog](https://github.com/pubs/pubs/compare/v0.8.1...master) +[Full Changelog](https://github.com/pubs/pubs/compare/v0.8.2...master) ### Implemented enhancements @@ -13,6 +13,15 @@ ### Fixed bugs +## [v0.8.2](https://github.com/pubs/pubs/compare/v0.8.1...v0.8.2) (2018-12-04) + +Fixes install on python2. + +### Fixed bugs + +- Fix missing readme.md for python2 pip install. [(#174)](https://github.com/pubs/pubs/pull/174) + + ## [v0.8.1](https://github.com/pubs/pubs/compare/v0.8.0...v0.8.1) (2018-08-28) A hotfix release. All users of 0.8.0 are urged to upgrade. diff --git a/pubs/version.py b/pubs/version.py index ef72cc0..4ca39e7 100644 --- a/pubs/version.py +++ b/pubs/version.py @@ -1 +1 @@ -__version__ = '0.8.1' +__version__ = '0.8.2' From 3c6d547a9184b55cf0edf476cb1e88d8ae07b2b5 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Fri, 4 Jan 2019 13:13:08 +0900 Subject: [PATCH 04/39] allow python 3.3's travis job to fail --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9e31abd..2c998bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,9 @@ matrix: - python3 -m venv env - source env/bin/activate + allow_failures: + - python: 3.3 + # command to install dependencies install: - python --version From b99c5b43faf35d8492dd3f1a68efe58cc199935e Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Fri, 4 Jan 2019 23:15:11 +0900 Subject: [PATCH 05/39] handle / in citekeys --- pubs/apis.py | 5 +- pubs/bibstruct.py | 2 +- pubs/commands/__init__.py | 1 + pubs/commands/add_cmd.py | 32 ++++--- pubs/commands/import_cmd.py | 14 +-- pubs/p3.py | 6 +- pubs/pubs_cmd.py | 1 + pubs/repo.py | 12 ++- readme.md | 2 +- tests/data/collection.bib | 41 +++++++++ tests/{readme.txt => readme.md} | 10 ++- tests/test_apis.py | 6 +- tests/test_apis_data.json | 152 +++++++++++++++++++++++++++++--- tests/test_repo.py | 6 +- tests/test_usecase.py | 38 ++++++-- 15 files changed, 279 insertions(+), 49 deletions(-) create mode 100644 tests/data/collection.bib rename tests/{readme.txt => readme.md} (53%) diff --git a/pubs/apis.py b/pubs/apis.py index aef5c5d..064d23a 100644 --- a/pubs/apis.py +++ b/pubs/apis.py @@ -15,7 +15,7 @@ class ReferenceNotFoundError(Exception): pass -def get_bibentry_from_api(id_str, id_type, try_doi=True, ui=None): +def get_bibentry_from_api(id_str, id_type, try_doi=True, ui=None, raw=False): """Return a bibtex string from various ID methods. This is a wrapper around functions that will return a bibtex string given @@ -50,6 +50,9 @@ def get_bibentry_from_api(id_str, id_type, try_doi=True, ui=None): raise ValueError('id_type must be one of `doi`, `isbn`, or `arxiv`.') bibentry_raw = id_fns[id_type](id_str, try_doi=try_doi, ui=ui) + if raw: + return bibentry_raw + bibentry = endecoder.EnDecoder().decode_bibdata(bibentry_raw) if bibentry is None: raise ReferenceNotFoundError( diff --git a/pubs/bibstruct.py b/pubs/bibstruct.py index 541d4b6..9e3e3f4 100644 --- a/pubs/bibstruct.py +++ b/pubs/bibstruct.py @@ -51,7 +51,7 @@ def author_last(author_str): return author_str.split(',')[0] -def generate_citekey(bibdata): +def generate_citekey(bibdata, generate=True): """ Generate a citekey from bib_data. :param generate: if False, return the citekey defined in the file, diff --git a/pubs/commands/__init__.py b/pubs/commands/__init__.py index ed5defa..ddd40ad 100644 --- a/pubs/commands/__init__.py +++ b/pubs/commands/__init__.py @@ -18,3 +18,4 @@ from . import import_cmd # bonus from . import websearch_cmd from . import url_cmd +#from . import bibtex_cmd diff --git a/pubs/commands/add_cmd.py b/pubs/commands/add_cmd.py index 12b87cd..1aa2ec7 100644 --- a/pubs/commands/add_cmd.py +++ b/pubs/commands/add_cmd.py @@ -72,6 +72,22 @@ def bibentry_from_editor(conf, ui): return bibentry +def bibentry_from_api(args, ui, raw=False): + try: + if args.doi is not None: + return apis.get_bibentry_from_api(args.doi, 'doi', ui=ui, raw=raw) + elif args.isbn is not None: + return apis.get_bibentry_from_api(args.isbn, 'isbn', ui=ui, raw=raw) + # TODO distinguish between cases, offer to open the error page in a webbrowser. + # TODO offer to confirm/change citekey + elif args.arxiv is not None: + return apis.get_bibentry_from_api(args.arxiv, 'arxiv', ui=ui, raw=raw) + except apis.ReferenceNotFoundError as e: + ui.error(str(e)) + ui.exit(1) + + + def command(conf, args): """ :param bibfile: bibtex file (in .bib, .bibml or .yaml format. @@ -92,19 +108,7 @@ def command(conf, args): if args.doi is None and args.isbn is None and args.arxiv is None: bibentry = bibentry_from_editor(conf, ui) else: - bibentry = None - try: - if args.doi is not None: - bibentry = apis.get_bibentry_from_api(args.doi, 'doi', ui=ui) - elif args.isbn is not None: - bibentry = apis.get_bibentry_from_api(args.isbn, 'isbn', ui=ui) - # TODO distinguish between cases, offer to open the error page in a webbrowser. - # TODO offer to confirm/change citekey - elif args.arxiv is not None: - bibentry = apis.get_bibentry_from_api(args.arxiv, 'arxiv', ui=ui) - except apis.ReferenceNotFoundError as e: - ui.error(str(e)) - ui.exit(1) + bibentry = bibentry_from_api(args, ui) else: bibentry_raw = content.get_content(bibfile, ui=ui) bibentry = decoder.decode_bibdata(bibentry_raw) @@ -116,7 +120,7 @@ def command(conf, args): citekey = args.citekey if citekey is None: base_key = bibstruct.extract_citekey(bibentry) - citekey = rp.unique_citekey(base_key) + citekey = rp.unique_citekey(base_key, bibentry) elif citekey in rp: ui.error('citekey already exist {}.'.format(citekey)) ui.exit(1) diff --git a/pubs/commands/import_cmd.py b/pubs/commands/import_cmd.py index 7cbf3b6..6d51488 100644 --- a/pubs/commands/import_cmd.py +++ b/pubs/commands/import_cmd.py @@ -14,26 +14,28 @@ from ..content import system_path, read_text_file from ..command_utils import add_doc_copy_arguments -_ABORT_USE_IGNORE_MSG = "Aborting import. Use --ignore-malformed to ignore." +_ABORT_USE_IGNORE_MSG = " Aborting import. Use --ignore-malformed to ignore." _IGNORING_MSG = " Ignoring it." def parser(subparsers, conf): parser = subparsers.add_parser( 'import', - help='import paper(s) to the repository') + help='import paper(s) to the repository.') parser.add_argument( 'bibpath', - help='path to bibtex, bibtexml or bibyaml file (or directory)') + help=("path to bibtex, bibtexml or bibyaml file, or a directory " + "containing such files; will not recurse into subdirectories.")) parser.add_argument( 'keys', nargs='*', - help="one or several keys to import from the file") + help=("one or several keys to import from the file; if not provided," + " all entries will be imported.")) parser.add_argument( '-O', '--overwrite', action='store_true', default=False, - help="Overwrite keys already in the database") + help="overwrite keys already in the database.") parser.add_argument( '-i', '--ignore-malformed', action='store_true', default=False, - help="Ignore malformed and unreadable files and entries") + help="ignore malformed and unreadable files and entries.") add_doc_copy_arguments(parser, copy=False) return parser diff --git a/pubs/p3.py b/pubs/p3.py index 197d26f..c78fa7e 100644 --- a/pubs/p3.py +++ b/pubs/p3.py @@ -87,10 +87,14 @@ else: super(StdIO, self).__init__(*args, **kwargs) def write(self, s): + super(StdIO, self).write(s) if self.additional_out is not None: + try: + s = s.decode() + except AttributeError: + pass self.additional_out.write(s) - super(StdIO, self).write(s) # Only for tests to capture std{out,err} def _fake_stdio(additional_out=False): diff --git a/pubs/pubs_cmd.py b/pubs/pubs_cmd.py index 740c709..08911cb 100644 --- a/pubs/pubs_cmd.py +++ b/pubs/pubs_cmd.py @@ -32,6 +32,7 @@ CORE_CMDS = collections.OrderedDict([ ('websearch', commands.websearch_cmd), ('url', commands.url_cmd), + #('bibtex', commands.bibtex_cmd), ]) diff --git a/pubs/repo.py b/pubs/repo.py index 51cd666..bb687b6 100644 --- a/pubs/repo.py +++ b/pubs/repo.py @@ -192,8 +192,16 @@ class Repository(object): p.docpath = docfile self.push_paper(p, overwrite=True, event=False) - def unique_citekey(self, base_key): - """Create a unique citekey for a given basekey.""" + def unique_citekey(self, base_key, bibentry): + """Create a unique citekey for a given base key. + + :param base_key: the base key in question. + :param bibentry: the bib entry to possibly generate the citekey. + """ + # can't have `/` in citekeys + # FIXME: a bit crude, but efficient for now (and allows unicode citekeys) + if '/' in base_key: + base_key = bibstruct.generate_citekey(bibentry) for n in itertools.count(): if not base_key + _base27(n) in self.citekeys: return base_key + _base27(n) diff --git a/readme.md b/readme.md index 5e618e0..dd2d902 100644 --- a/readme.md +++ b/readme.md @@ -86,7 +86,7 @@ and then add `\cite{Loeb_2012}` in your manuscript. After exporting the bibliogr You can attach a document to a reference: ``` - pubs add Loeb2012_downloaded.pdf Loeb_2012 + pubs doc add Loeb2012_downloaded.pdf Loeb_2012 ``` And open your documents automatically from the command line: diff --git a/tests/data/collection.bib b/tests/data/collection.bib new file mode 100644 index 0000000..2c240fe --- /dev/null +++ b/tests/data/collection.bib @@ -0,0 +1,41 @@ +@article{Einstein_1935, + doi = {10.1103/physrev.47.777}, + url = {https://doi.org/10.1103%2Fphysrev.47.777}, + year = 1935, + month = {may}, + publisher = {American Physical Society ({APS})}, + volume = {47}, + number = {10}, + pages = {777--780}, + author = {A. Einstein and B. Podolsky and N. Rosen}, + title = {Can Quantum-Mechanical Description of Physical Reality Be Considered Complete?}, + journal = {Physical Review} +} + +@article{Schrodinger_1935, + doi = {10.1017/s0305004100013554}, + url = {https://doi.org/10.1017%2Fs0305004100013554}, + year = 1935, + month = {oct}, + publisher = {Cambridge University Press ({CUP})}, + volume = {31}, + number = {04}, + pages = {555}, + author = {E. Schrödinger and M. Born}, + title = {Discussion of Probability Relations between Separated Systems}, + journal = {Mathematical Proceedings of the Cambridge Philosophical Society} +} + +@article{Bell_1964, + doi = {10.1103/physicsphysiquefizika.1.195}, + url = {https://doi.org/10.1103%2Fphysicsphysiquefizika.1.195}, + year = 1964, + month = {nov}, + publisher = {American Physical Society ({APS})}, + volume = {1}, + number = {3}, + pages = {195--200}, + author = {J. S. Bell}, + title = {On the Einstein Podolsky Rosen paradox}, + journal = {Physics Physique {\cyrchar\cyrf}{\cyrchar\cyri}{\cyrchar\cyrz}{\cyrchar\cyri}{\cyrchar\cyrk}{\cyrchar\cyra}} +} diff --git a/tests/readme.txt b/tests/readme.md similarity index 53% rename from tests/readme.txt rename to tests/readme.md index 88a6a13..356786e 100644 --- a/tests/readme.txt +++ b/tests/readme.md @@ -1,7 +1,11 @@ 1. Install the dependencies using: -> pip install -r requirements.txt +``` +pip install -r ../dev_requirements.txt +``` 2. Run the tests using: -> python -m unittest discover +``` +python setup.py test +``` -If you use nosetest, it will complain about addExpectedFailure, which you can safely disregard. +If you use nosetest, it will complain about addExpectedFailure, which you can safely disregard. diff --git a/tests/test_apis.py b/tests/test_apis.py index 0a7feb9..e4d9d4b 100644 --- a/tests/test_apis.py +++ b/tests/test_apis.py @@ -16,8 +16,12 @@ import mock_requests class APITests(unittest.TestCase): - pass + @mock.patch('pubs.apis.requests.get', side_effect=mock_requests.mock_requests_get) + def test_readme(self, reqget): + apis.doi2bibtex('10.1007/s00422-012-0514-6') + apis.isbn2bibtex('978-0822324669') + apis.arxiv2bibtex('math/9501234') class TestDOI2Bibtex(APITests): diff --git a/tests/test_apis_data.json b/tests/test_apis_data.json index 8fe73aa..14e76d9 100644 --- a/tests/test_apis_data.json +++ b/tests/test_apis_data.json @@ -25,6 +25,58 @@ 200, null ], + [ + [ + "https://dx.doi.org/10.1007/s00422-012-0514-6" + ], + { + "headers": { + "accept": "application/x-bibtex" + } + }, + "@article{Loeb_2012,\n\tdoi = {10.1007/s00422-012-0514-6},\n\turl = {https://doi.org/10.1007%2Fs00422-012-0514-6},\n\tyear = 2012,\n\tmonth = {aug},\n\tpublisher = {Springer Nature},\n\tvolume = {106},\n\tnumber = {11-12},\n\tpages = {757--765},\n\tauthor = {Gerald E. Loeb},\n\ttitle = {Optimal isn't good enough},\n\tjournal = {Biological Cybernetics}\n}", + 200, + null + ], + [ + [ + "https://dx.doi.org/10.1007/s00422-012-0514-6" + ], + { + "headers": { + "accept": "application/x-bibtex" + } + }, + "@article{Loeb_2012,\n\tdoi = {10.1007/s00422-012-0514-6},\n\turl = {https://doi.org/10.1007%2Fs00422-012-0514-6},\n\tyear = 2012,\n\tmonth = {aug},\n\tpublisher = {Springer Nature},\n\tvolume = {106},\n\tnumber = {11-12},\n\tpages = {757--765},\n\tauthor = {Gerald E. Loeb},\n\ttitle = {Optimal isn't good enough},\n\tjournal = {Biological Cybernetics}\n}", + 200, + null + ], + [ + [ + "https://dx.doi.org/10.1007/s00422-012-0514-6" + ], + { + "headers": { + "accept": "application/x-bibtex" + } + }, + "@article{Loeb_2012,\n\tdoi = {10.1007/s00422-012-0514-6},\n\turl = {https://doi.org/10.1007%2Fs00422-012-0514-6},\n\tyear = 2012,\n\tmonth = {aug},\n\tpublisher = {Springer Nature},\n\tvolume = {106},\n\tnumber = {11-12},\n\tpages = {757--765},\n\tauthor = {Gerald E. Loeb},\n\ttitle = {Optimal isn't good enough},\n\tjournal = {Biological Cybernetics}\n}", + 200, + null + ], + [ + [ + "https://dx.doi.org/10.1007/s00422-012-0514-6" + ], + { + "headers": { + "accept": "application/x-bibtex" + } + }, + "@article{Loeb_2012,\n\tdoi = {10.1007/s00422-012-0514-6},\n\turl = {https://doi.org/10.1007%2Fs00422-012-0514-6},\n\tyear = 2012,\n\tmonth = {aug},\n\tpublisher = {Springer Nature},\n\tvolume = {106},\n\tnumber = {11-12},\n\tpages = {757--765},\n\tauthor = {Gerald E. Loeb},\n\ttitle = {Optimal isn't good enough},\n\tjournal = {Biological Cybernetics}\n}", + 200, + null + ], [ [ "https://dx.doi.org/10.1086/307221" @@ -95,7 +147,7 @@ "https://export.arxiv.org/api/query?id_list=1312.2021" ], {}, - "\n\n \n ArXiv Query: search_query=&id_list=1312.2021&start=0&max_results=10\n http://arxiv.org/api/eXBvi61X4ShcFWF7lwJgRo7KSFk\n 2018-08-14T00:00:00-04:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/1312.2021v1\n 2013-12-06T21:33:40Z\n 2013-12-06T21:33:40Z\n Living with the Wrong Sign\n We describe a UV complete asymptotically fragile Lorentz-invariant theory\nexhibiting superluminal signal propagation. Its low energy effective action\ncontains \"wrong\" sign higher dimensional operators. Nevertheless, the theory\ngives rise to an S-matrix, which is defined at all energies. As expected for a\nnon-local theory, the corresponding scattering amplitudes are not exponentially\nbounded on the physical sheet, but otherwise are healthy. We study some of the\nphysical consequences of this S-matrix.\n\n \n Patrick Cooper\n \n \n Sergei Dubovsky\n \n \n Ali Mohsen\n \n 10.1103/INVALIDDOI.89.084044\n \n Phys. Rev. D 89, 084044 (2014)\n \n \n \n \n \n \n\n", + "\n\n \n ArXiv Query: search_query=&id_list=1312.2021&start=0&max_results=10\n http://arxiv.org/api/eXBvi61X4ShcFWF7lwJgRo7KSFk\n 2019-01-04T00:00:00-05:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/1312.2021v1\n 2013-12-06T21:33:40Z\n 2013-12-06T21:33:40Z\n Living with the Wrong Sign\n We describe a UV complete asymptotically fragile Lorentz-invariant theory\nexhibiting superluminal signal propagation. Its low energy effective action\ncontains \"wrong\" sign higher dimensional operators. Nevertheless, the theory\ngives rise to an S-matrix, which is defined at all energies. As expected for a\nnon-local theory, the corresponding scattering amplitudes are not exponentially\nbounded on the physical sheet, but otherwise are healthy. We study some of the\nphysical consequences of this S-matrix.\n\n \n Patrick Cooper\n \n \n Sergei Dubovsky\n \n \n Ali Mohsen\n \n 10.1103/INVALIDDOI.89.084044\n \n Phys. Rev. D 89, 084044 (2014)\n \n \n \n \n \n \n\n", 200, null ], @@ -104,7 +156,7 @@ "https://export.arxiv.org/api/query?id_list=1710.08557" ], {}, - "\n\n \n ArXiv Query: search_query=&id_list=1710.08557&start=0&max_results=10\n http://arxiv.org/api/bNB5RPNlUYbELau5YJ4IzaIq1x8\n 2018-08-14T00:00:00-04:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/1710.08557v1\n 2017-10-24T00:21:32Z\n 2017-10-24T00:21:32Z\n On Neuromechanical Approaches for the Study of Biological Grasp and\n Manipulation\n Biological and robotic grasp and manipulation are undeniably similar at the\nlevel of mechanical task performance. However, their underlying fundamental\nbiological vs. engineering mechanisms are, by definition, dramatically\ndifferent and can even be antithetical. Even our approach to each is\ndiametrically opposite: inductive science for the study of biological systems\nvs. engineering synthesis for the design and construction of robotic systems.\nThe past 20 years have seen several conceptual advances in both fields and the\nquest to unify them. Chief among them is the reluctant recognition that their\nunderlying fundamental mechanisms may actually share limited common ground,\nwhile exhibiting many fundamental differences. This recognition is particularly\nliberating because it allows us to resolve and move beyond multiple paradoxes\nand contradictions that arose from the initial reasonable assumption of a large\ncommon ground. Here, we begin by introducing the perspective of neuromechanics,\nwhich emphasizes that real-world behavior emerges from the intimate\ninteractions among the physical structure of the system, the mechanical\nrequirements of a task, the feasible neural control actions to produce it, and\nthe ability of the neuromuscular system to adapt through interactions with the\nenvironment. This allows us to articulate a succinct overview of a few salient\nconceptual paradoxes and contradictions regarding under-determined vs.\nover-determined mechanics, under- vs. over-actuated control, prescribed vs.\nemergent function, learning vs. implementation vs. adaptation, prescriptive vs.\ndescriptive synergies, and optimal vs. habitual performance. We conclude by\npresenting open questions and suggesting directions for future research. We\nhope this frank assessment of the state-of-the-art will encourage and guide\nthese communities to continue to interact and make progress in these important\nareas.\n\n \n Francisco J Valero-Cuevas\n \n \n Marco Santello\n \n 10.1186/s12984-017-0305-3\n \n Journal of NeuroEngineering and Rehabilitation, 2017\n \n \n \n \n \n\n", + "\n\n \n ArXiv Query: search_query=&id_list=1710.08557&start=0&max_results=10\n http://arxiv.org/api/bNB5RPNlUYbELau5YJ4IzaIq1x8\n 2019-01-04T00:00:00-05:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/1710.08557v1\n 2017-10-24T00:21:32Z\n 2017-10-24T00:21:32Z\n On Neuromechanical Approaches for the Study of Biological Grasp and\n Manipulation\n Biological and robotic grasp and manipulation are undeniably similar at the\nlevel of mechanical task performance. However, their underlying fundamental\nbiological vs. engineering mechanisms are, by definition, dramatically\ndifferent and can even be antithetical. Even our approach to each is\ndiametrically opposite: inductive science for the study of biological systems\nvs. engineering synthesis for the design and construction of robotic systems.\nThe past 20 years have seen several conceptual advances in both fields and the\nquest to unify them. Chief among them is the reluctant recognition that their\nunderlying fundamental mechanisms may actually share limited common ground,\nwhile exhibiting many fundamental differences. This recognition is particularly\nliberating because it allows us to resolve and move beyond multiple paradoxes\nand contradictions that arose from the initial reasonable assumption of a large\ncommon ground. Here, we begin by introducing the perspective of neuromechanics,\nwhich emphasizes that real-world behavior emerges from the intimate\ninteractions among the physical structure of the system, the mechanical\nrequirements of a task, the feasible neural control actions to produce it, and\nthe ability of the neuromuscular system to adapt through interactions with the\nenvironment. This allows us to articulate a succinct overview of a few salient\nconceptual paradoxes and contradictions regarding under-determined vs.\nover-determined mechanics, under- vs. over-actuated control, prescribed vs.\nemergent function, learning vs. implementation vs. adaptation, prescriptive vs.\ndescriptive synergies, and optimal vs. habitual performance. We conclude by\npresenting open questions and suggesting directions for future research. We\nhope this frank assessment of the state-of-the-art will encourage and guide\nthese communities to continue to interact and make progress in these important\nareas.\n\n \n Francisco J Valero-Cuevas\n \n \n Marco Santello\n \n 10.1186/s12984-017-0305-3\n \n Journal of NeuroEngineering and Rehabilitation, 2017\n \n \n \n \n \n\n", 200, null ], @@ -113,7 +165,7 @@ "https://export.arxiv.org/api/query?id_list=1710.08557" ], {}, - "\n\n \n ArXiv Query: search_query=&id_list=1710.08557&start=0&max_results=10\n http://arxiv.org/api/bNB5RPNlUYbELau5YJ4IzaIq1x8\n 2018-08-14T00:00:00-04:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/1710.08557v1\n 2017-10-24T00:21:32Z\n 2017-10-24T00:21:32Z\n On Neuromechanical Approaches for the Study of Biological Grasp and\n Manipulation\n Biological and robotic grasp and manipulation are undeniably similar at the\nlevel of mechanical task performance. However, their underlying fundamental\nbiological vs. engineering mechanisms are, by definition, dramatically\ndifferent and can even be antithetical. Even our approach to each is\ndiametrically opposite: inductive science for the study of biological systems\nvs. engineering synthesis for the design and construction of robotic systems.\nThe past 20 years have seen several conceptual advances in both fields and the\nquest to unify them. Chief among them is the reluctant recognition that their\nunderlying fundamental mechanisms may actually share limited common ground,\nwhile exhibiting many fundamental differences. This recognition is particularly\nliberating because it allows us to resolve and move beyond multiple paradoxes\nand contradictions that arose from the initial reasonable assumption of a large\ncommon ground. Here, we begin by introducing the perspective of neuromechanics,\nwhich emphasizes that real-world behavior emerges from the intimate\ninteractions among the physical structure of the system, the mechanical\nrequirements of a task, the feasible neural control actions to produce it, and\nthe ability of the neuromuscular system to adapt through interactions with the\nenvironment. This allows us to articulate a succinct overview of a few salient\nconceptual paradoxes and contradictions regarding under-determined vs.\nover-determined mechanics, under- vs. over-actuated control, prescribed vs.\nemergent function, learning vs. implementation vs. adaptation, prescriptive vs.\ndescriptive synergies, and optimal vs. habitual performance. We conclude by\npresenting open questions and suggesting directions for future research. We\nhope this frank assessment of the state-of-the-art will encourage and guide\nthese communities to continue to interact and make progress in these important\nareas.\n\n \n Francisco J Valero-Cuevas\n \n \n Marco Santello\n \n 10.1186/s12984-017-0305-3\n \n Journal of NeuroEngineering and Rehabilitation, 2017\n \n \n \n \n \n\n", + "\n\n \n ArXiv Query: search_query=&id_list=1710.08557&start=0&max_results=10\n http://arxiv.org/api/bNB5RPNlUYbELau5YJ4IzaIq1x8\n 2019-01-04T00:00:00-05:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/1710.08557v1\n 2017-10-24T00:21:32Z\n 2017-10-24T00:21:32Z\n On Neuromechanical Approaches for the Study of Biological Grasp and\n Manipulation\n Biological and robotic grasp and manipulation are undeniably similar at the\nlevel of mechanical task performance. However, their underlying fundamental\nbiological vs. engineering mechanisms are, by definition, dramatically\ndifferent and can even be antithetical. Even our approach to each is\ndiametrically opposite: inductive science for the study of biological systems\nvs. engineering synthesis for the design and construction of robotic systems.\nThe past 20 years have seen several conceptual advances in both fields and the\nquest to unify them. Chief among them is the reluctant recognition that their\nunderlying fundamental mechanisms may actually share limited common ground,\nwhile exhibiting many fundamental differences. This recognition is particularly\nliberating because it allows us to resolve and move beyond multiple paradoxes\nand contradictions that arose from the initial reasonable assumption of a large\ncommon ground. Here, we begin by introducing the perspective of neuromechanics,\nwhich emphasizes that real-world behavior emerges from the intimate\ninteractions among the physical structure of the system, the mechanical\nrequirements of a task, the feasible neural control actions to produce it, and\nthe ability of the neuromuscular system to adapt through interactions with the\nenvironment. This allows us to articulate a succinct overview of a few salient\nconceptual paradoxes and contradictions regarding under-determined vs.\nover-determined mechanics, under- vs. over-actuated control, prescribed vs.\nemergent function, learning vs. implementation vs. adaptation, prescriptive vs.\ndescriptive synergies, and optimal vs. habitual performance. We conclude by\npresenting open questions and suggesting directions for future research. We\nhope this frank assessment of the state-of-the-art will encourage and guide\nthese communities to continue to interact and make progress in these important\nareas.\n\n \n Francisco J Valero-Cuevas\n \n \n Marco Santello\n \n 10.1186/s12984-017-0305-3\n \n Journal of NeuroEngineering and Rehabilitation, 2017\n \n \n \n \n \n\n", 200, null ], @@ -122,7 +174,7 @@ "https://export.arxiv.org/api/query?id_list=INVALIDID" ], {}, - "\n\n \n ArXiv Query: search_query=&id_list=INVALIDID\n http://arxiv.org/api//TMQrv7hMz9PNtlUyGrhFtefYFQ\n 2018-08-14T00:00:00-04:00\n 1\n 0\n 1\n \n http://arxiv.org/api/errors#incorrect_id_format_for_INVALIDID\n Error\n incorrect id format for INVALIDID\n 2018-08-14T00:00:00-04:00\n \n \n arXiv api core\n \n \n\n", + "\n\n \n ArXiv Query: search_query=&id_list=INVALIDID\n http://arxiv.org/api//TMQrv7hMz9PNtlUyGrhFtefYFQ\n 2019-01-04T00:00:00-05:00\n 1\n 0\n 1\n \n http://arxiv.org/api/errors#incorrect_id_format_for_INVALIDID\n Error\n incorrect id format for INVALIDID\n 2019-01-04T00:00:00-05:00\n \n \n arXiv api core\n \n \n\n", 400, "400 Client Error: Bad Request for url: https://export.arxiv.org/api/query?id_list=INVALIDID" ], @@ -131,7 +183,7 @@ "https://export.arxiv.org/api/query?id_list=astro-ph/9812133" ], {}, - "\n\n \n ArXiv Query: search_query=&id_list=astro-ph/9812133&start=0&max_results=10\n http://arxiv.org/api/SfKekabpSjI/htnxCLpK3q9AsUs\n 2018-08-14T00:00:00-04:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/astro-ph/9812133v1\n 1998-12-08T03:27:34Z\n 1998-12-08T03:27:34Z\n Measurements of Omega and Lambda from 42 High-Redshift Supernovae\n We report measurements of the mass density, Omega_M, and\ncosmological-constant energy density, Omega_Lambda, of the universe based on\nthe analysis of 42 Type Ia supernovae discovered by the Supernova Cosmology\nProject. The magnitude-redshift data for these SNe, at redshifts between 0.18\nand 0.83, are fit jointly with a set of SNe from the Calan/Tololo Supernova\nSurvey, at redshifts below 0.1, to yield values for the cosmological\nparameters. All SN peak magnitudes are standardized using a SN Ia lightcurve\nwidth-luminosity relation. The measurement yields a joint probability\ndistribution of the cosmological parameters that is approximated by the\nrelation 0.8 Omega_M - 0.6 Omega_Lambda ~= -0.2 +/- 0.1 in the region of\ninterest (Omega_M <~ 1.5). For a flat (Omega_M + Omega_Lambda = 1) cosmology we\nfind Omega_M = 0.28{+0.09,-0.08} (1 sigma statistical) {+0.05,-0.04}\n(identified systematics). The data are strongly inconsistent with a Lambda = 0\nflat cosmology, the simplest inflationary universe model. An open, Lambda = 0\ncosmology also does not fit the data well: the data indicate that the\ncosmological constant is non-zero and positive, with a confidence of P(Lambda >\n0) = 99%, including the identified systematic uncertainties. The best-fit age\nof the universe relative to the Hubble time is t_0 = 14.9{+1.4,-1.1} (0.63/h)\nGyr for a flat cosmology. The size of our sample allows us to perform a variety\nof statistical tests to check for possible systematic errors and biases. We\nfind no significant differences in either the host reddening distribution or\nMalmquist bias between the low-redshift Calan/Tololo sample and our\nhigh-redshift sample. The conclusions are robust whether or not a\nwidth-luminosity relation is used to standardize the SN peak magnitudes.\n\n \n S. Perlmutter\n The Supernova Cosmology Project\n \n \n G. Aldering\n The Supernova Cosmology Project\n \n \n G. Goldhaber\n The Supernova Cosmology Project\n \n \n R. A. Knop\n The Supernova Cosmology Project\n \n \n P. Nugent\n The Supernova Cosmology Project\n \n \n P. G. Castro\n The Supernova Cosmology Project\n \n \n S. Deustua\n The Supernova Cosmology Project\n \n \n S. Fabbro\n The Supernova Cosmology Project\n \n \n A. Goobar\n The Supernova Cosmology Project\n \n \n D. E. Groom\n The Supernova Cosmology Project\n \n \n I. M. Hook\n The Supernova Cosmology Project\n \n \n A. G. Kim\n The Supernova Cosmology Project\n \n \n M. Y. Kim\n The Supernova Cosmology Project\n \n \n J. C. Lee\n The Supernova Cosmology Project\n \n \n N. J. Nunes\n The Supernova Cosmology Project\n \n \n R. Pain\n The Supernova Cosmology Project\n \n \n C. R. Pennypacker\n The Supernova Cosmology Project\n \n \n R. Quimby\n The Supernova Cosmology Project\n \n \n C. Lidman\n The Supernova Cosmology Project\n \n \n R. S. Ellis\n The Supernova Cosmology Project\n \n \n M. Irwin\n The Supernova Cosmology Project\n \n \n R. G. McMahon\n The Supernova Cosmology Project\n \n \n P. Ruiz-Lapuente\n The Supernova Cosmology Project\n \n \n N. Walton\n The Supernova Cosmology Project\n \n \n B. Schaefer\n The Supernova Cosmology Project\n \n \n B. J. Boyle\n The Supernova Cosmology Project\n \n \n A. V. Filippenko\n The Supernova Cosmology Project\n \n \n T. Matheson\n The Supernova Cosmology Project\n \n \n A. S. Fruchter\n The Supernova Cosmology Project\n \n \n N. Panagia\n The Supernova Cosmology Project\n \n \n H. J. M. Newberg\n The Supernova Cosmology Project\n \n \n W. J. Couch\n The Supernova Cosmology Project\n \n 10.1086/307221\n \n 21 pages and 10 figures. Accepted for publication in the\n Astrophysical Journal. Individual color figures, supplementary tables, and\n preprint also available at http://www-supernova.lbl.gov/\n Astrophys.J.517:565-586,1999\n \n \n \n \n \n \n \n\n", + "\n\n \n ArXiv Query: search_query=&id_list=astro-ph/9812133&start=0&max_results=10\n http://arxiv.org/api/SfKekabpSjI/htnxCLpK3q9AsUs\n 2019-01-04T00:00:00-05:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/astro-ph/9812133v1\n 1998-12-08T03:27:34Z\n 1998-12-08T03:27:34Z\n Measurements of Omega and Lambda from 42 High-Redshift Supernovae\n We report measurements of the mass density, Omega_M, and\ncosmological-constant energy density, Omega_Lambda, of the universe based on\nthe analysis of 42 Type Ia supernovae discovered by the Supernova Cosmology\nProject. The magnitude-redshift data for these SNe, at redshifts between 0.18\nand 0.83, are fit jointly with a set of SNe from the Calan/Tololo Supernova\nSurvey, at redshifts below 0.1, to yield values for the cosmological\nparameters. All SN peak magnitudes are standardized using a SN Ia lightcurve\nwidth-luminosity relation. The measurement yields a joint probability\ndistribution of the cosmological parameters that is approximated by the\nrelation 0.8 Omega_M - 0.6 Omega_Lambda ~= -0.2 +/- 0.1 in the region of\ninterest (Omega_M <~ 1.5). For a flat (Omega_M + Omega_Lambda = 1) cosmology we\nfind Omega_M = 0.28{+0.09,-0.08} (1 sigma statistical) {+0.05,-0.04}\n(identified systematics). The data are strongly inconsistent with a Lambda = 0\nflat cosmology, the simplest inflationary universe model. An open, Lambda = 0\ncosmology also does not fit the data well: the data indicate that the\ncosmological constant is non-zero and positive, with a confidence of P(Lambda >\n0) = 99%, including the identified systematic uncertainties. The best-fit age\nof the universe relative to the Hubble time is t_0 = 14.9{+1.4,-1.1} (0.63/h)\nGyr for a flat cosmology. The size of our sample allows us to perform a variety\nof statistical tests to check for possible systematic errors and biases. We\nfind no significant differences in either the host reddening distribution or\nMalmquist bias between the low-redshift Calan/Tololo sample and our\nhigh-redshift sample. The conclusions are robust whether or not a\nwidth-luminosity relation is used to standardize the SN peak magnitudes.\n\n \n S. Perlmutter\n The Supernova Cosmology Project\n \n \n G. Aldering\n The Supernova Cosmology Project\n \n \n G. Goldhaber\n The Supernova Cosmology Project\n \n \n R. A. Knop\n The Supernova Cosmology Project\n \n \n P. Nugent\n The Supernova Cosmology Project\n \n \n P. G. Castro\n The Supernova Cosmology Project\n \n \n S. Deustua\n The Supernova Cosmology Project\n \n \n S. Fabbro\n The Supernova Cosmology Project\n \n \n A. Goobar\n The Supernova Cosmology Project\n \n \n D. E. Groom\n The Supernova Cosmology Project\n \n \n I. M. Hook\n The Supernova Cosmology Project\n \n \n A. G. Kim\n The Supernova Cosmology Project\n \n \n M. Y. Kim\n The Supernova Cosmology Project\n \n \n J. C. Lee\n The Supernova Cosmology Project\n \n \n N. J. Nunes\n The Supernova Cosmology Project\n \n \n R. Pain\n The Supernova Cosmology Project\n \n \n C. R. Pennypacker\n The Supernova Cosmology Project\n \n \n R. Quimby\n The Supernova Cosmology Project\n \n \n C. Lidman\n The Supernova Cosmology Project\n \n \n R. S. Ellis\n The Supernova Cosmology Project\n \n \n M. Irwin\n The Supernova Cosmology Project\n \n \n R. G. McMahon\n The Supernova Cosmology Project\n \n \n P. Ruiz-Lapuente\n The Supernova Cosmology Project\n \n \n N. Walton\n The Supernova Cosmology Project\n \n \n B. Schaefer\n The Supernova Cosmology Project\n \n \n B. J. Boyle\n The Supernova Cosmology Project\n \n \n A. V. Filippenko\n The Supernova Cosmology Project\n \n \n T. Matheson\n The Supernova Cosmology Project\n \n \n A. S. Fruchter\n The Supernova Cosmology Project\n \n \n N. Panagia\n The Supernova Cosmology Project\n \n \n H. J. M. Newberg\n The Supernova Cosmology Project\n \n \n W. J. Couch\n The Supernova Cosmology Project\n \n 10.1086/307221\n \n 21 pages and 10 figures. Accepted for publication in the\n Astrophysical Journal. Individual color figures, supplementary tables, and\n preprint also available at http://www-supernova.lbl.gov/\n Astrophys.J.517:565-586,1999\n \n \n \n \n \n \n \n\n", 200, null ], @@ -140,7 +192,7 @@ "https://export.arxiv.org/api/query?id_list=astro-ph/9812133" ], {}, - "\n\n \n ArXiv Query: search_query=&id_list=astro-ph/9812133&start=0&max_results=10\n http://arxiv.org/api/SfKekabpSjI/htnxCLpK3q9AsUs\n 2018-08-14T00:00:00-04:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/astro-ph/9812133v1\n 1998-12-08T03:27:34Z\n 1998-12-08T03:27:34Z\n Measurements of Omega and Lambda from 42 High-Redshift Supernovae\n We report measurements of the mass density, Omega_M, and\ncosmological-constant energy density, Omega_Lambda, of the universe based on\nthe analysis of 42 Type Ia supernovae discovered by the Supernova Cosmology\nProject. The magnitude-redshift data for these SNe, at redshifts between 0.18\nand 0.83, are fit jointly with a set of SNe from the Calan/Tololo Supernova\nSurvey, at redshifts below 0.1, to yield values for the cosmological\nparameters. All SN peak magnitudes are standardized using a SN Ia lightcurve\nwidth-luminosity relation. The measurement yields a joint probability\ndistribution of the cosmological parameters that is approximated by the\nrelation 0.8 Omega_M - 0.6 Omega_Lambda ~= -0.2 +/- 0.1 in the region of\ninterest (Omega_M <~ 1.5). For a flat (Omega_M + Omega_Lambda = 1) cosmology we\nfind Omega_M = 0.28{+0.09,-0.08} (1 sigma statistical) {+0.05,-0.04}\n(identified systematics). The data are strongly inconsistent with a Lambda = 0\nflat cosmology, the simplest inflationary universe model. An open, Lambda = 0\ncosmology also does not fit the data well: the data indicate that the\ncosmological constant is non-zero and positive, with a confidence of P(Lambda >\n0) = 99%, including the identified systematic uncertainties. The best-fit age\nof the universe relative to the Hubble time is t_0 = 14.9{+1.4,-1.1} (0.63/h)\nGyr for a flat cosmology. The size of our sample allows us to perform a variety\nof statistical tests to check for possible systematic errors and biases. We\nfind no significant differences in either the host reddening distribution or\nMalmquist bias between the low-redshift Calan/Tololo sample and our\nhigh-redshift sample. The conclusions are robust whether or not a\nwidth-luminosity relation is used to standardize the SN peak magnitudes.\n\n \n S. Perlmutter\n The Supernova Cosmology Project\n \n \n G. Aldering\n The Supernova Cosmology Project\n \n \n G. Goldhaber\n The Supernova Cosmology Project\n \n \n R. A. Knop\n The Supernova Cosmology Project\n \n \n P. Nugent\n The Supernova Cosmology Project\n \n \n P. G. Castro\n The Supernova Cosmology Project\n \n \n S. Deustua\n The Supernova Cosmology Project\n \n \n S. Fabbro\n The Supernova Cosmology Project\n \n \n A. Goobar\n The Supernova Cosmology Project\n \n \n D. E. Groom\n The Supernova Cosmology Project\n \n \n I. M. Hook\n The Supernova Cosmology Project\n \n \n A. G. Kim\n The Supernova Cosmology Project\n \n \n M. Y. Kim\n The Supernova Cosmology Project\n \n \n J. C. Lee\n The Supernova Cosmology Project\n \n \n N. J. Nunes\n The Supernova Cosmology Project\n \n \n R. Pain\n The Supernova Cosmology Project\n \n \n C. R. Pennypacker\n The Supernova Cosmology Project\n \n \n R. Quimby\n The Supernova Cosmology Project\n \n \n C. Lidman\n The Supernova Cosmology Project\n \n \n R. S. Ellis\n The Supernova Cosmology Project\n \n \n M. Irwin\n The Supernova Cosmology Project\n \n \n R. G. McMahon\n The Supernova Cosmology Project\n \n \n P. Ruiz-Lapuente\n The Supernova Cosmology Project\n \n \n N. Walton\n The Supernova Cosmology Project\n \n \n B. Schaefer\n The Supernova Cosmology Project\n \n \n B. J. Boyle\n The Supernova Cosmology Project\n \n \n A. V. Filippenko\n The Supernova Cosmology Project\n \n \n T. Matheson\n The Supernova Cosmology Project\n \n \n A. S. Fruchter\n The Supernova Cosmology Project\n \n \n N. Panagia\n The Supernova Cosmology Project\n \n \n H. J. M. Newberg\n The Supernova Cosmology Project\n \n \n W. J. Couch\n The Supernova Cosmology Project\n \n 10.1086/307221\n \n 21 pages and 10 figures. Accepted for publication in the\n Astrophysical Journal. Individual color figures, supplementary tables, and\n preprint also available at http://www-supernova.lbl.gov/\n Astrophys.J.517:565-586,1999\n \n \n \n \n \n \n \n\n", + "\n\n \n ArXiv Query: search_query=&id_list=astro-ph/9812133&start=0&max_results=10\n http://arxiv.org/api/SfKekabpSjI/htnxCLpK3q9AsUs\n 2019-01-04T00:00:00-05:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/astro-ph/9812133v1\n 1998-12-08T03:27:34Z\n 1998-12-08T03:27:34Z\n Measurements of Omega and Lambda from 42 High-Redshift Supernovae\n We report measurements of the mass density, Omega_M, and\ncosmological-constant energy density, Omega_Lambda, of the universe based on\nthe analysis of 42 Type Ia supernovae discovered by the Supernova Cosmology\nProject. The magnitude-redshift data for these SNe, at redshifts between 0.18\nand 0.83, are fit jointly with a set of SNe from the Calan/Tololo Supernova\nSurvey, at redshifts below 0.1, to yield values for the cosmological\nparameters. All SN peak magnitudes are standardized using a SN Ia lightcurve\nwidth-luminosity relation. The measurement yields a joint probability\ndistribution of the cosmological parameters that is approximated by the\nrelation 0.8 Omega_M - 0.6 Omega_Lambda ~= -0.2 +/- 0.1 in the region of\ninterest (Omega_M <~ 1.5). For a flat (Omega_M + Omega_Lambda = 1) cosmology we\nfind Omega_M = 0.28{+0.09,-0.08} (1 sigma statistical) {+0.05,-0.04}\n(identified systematics). The data are strongly inconsistent with a Lambda = 0\nflat cosmology, the simplest inflationary universe model. An open, Lambda = 0\ncosmology also does not fit the data well: the data indicate that the\ncosmological constant is non-zero and positive, with a confidence of P(Lambda >\n0) = 99%, including the identified systematic uncertainties. The best-fit age\nof the universe relative to the Hubble time is t_0 = 14.9{+1.4,-1.1} (0.63/h)\nGyr for a flat cosmology. The size of our sample allows us to perform a variety\nof statistical tests to check for possible systematic errors and biases. We\nfind no significant differences in either the host reddening distribution or\nMalmquist bias between the low-redshift Calan/Tololo sample and our\nhigh-redshift sample. The conclusions are robust whether or not a\nwidth-luminosity relation is used to standardize the SN peak magnitudes.\n\n \n S. Perlmutter\n The Supernova Cosmology Project\n \n \n G. Aldering\n The Supernova Cosmology Project\n \n \n G. Goldhaber\n The Supernova Cosmology Project\n \n \n R. A. Knop\n The Supernova Cosmology Project\n \n \n P. Nugent\n The Supernova Cosmology Project\n \n \n P. G. Castro\n The Supernova Cosmology Project\n \n \n S. Deustua\n The Supernova Cosmology Project\n \n \n S. Fabbro\n The Supernova Cosmology Project\n \n \n A. Goobar\n The Supernova Cosmology Project\n \n \n D. E. Groom\n The Supernova Cosmology Project\n \n \n I. M. Hook\n The Supernova Cosmology Project\n \n \n A. G. Kim\n The Supernova Cosmology Project\n \n \n M. Y. Kim\n The Supernova Cosmology Project\n \n \n J. C. Lee\n The Supernova Cosmology Project\n \n \n N. J. Nunes\n The Supernova Cosmology Project\n \n \n R. Pain\n The Supernova Cosmology Project\n \n \n C. R. Pennypacker\n The Supernova Cosmology Project\n \n \n R. Quimby\n The Supernova Cosmology Project\n \n \n C. Lidman\n The Supernova Cosmology Project\n \n \n R. S. Ellis\n The Supernova Cosmology Project\n \n \n M. Irwin\n The Supernova Cosmology Project\n \n \n R. G. McMahon\n The Supernova Cosmology Project\n \n \n P. Ruiz-Lapuente\n The Supernova Cosmology Project\n \n \n N. Walton\n The Supernova Cosmology Project\n \n \n B. Schaefer\n The Supernova Cosmology Project\n \n \n B. J. Boyle\n The Supernova Cosmology Project\n \n \n A. V. Filippenko\n The Supernova Cosmology Project\n \n \n T. Matheson\n The Supernova Cosmology Project\n \n \n A. S. Fruchter\n The Supernova Cosmology Project\n \n \n N. Panagia\n The Supernova Cosmology Project\n \n \n H. J. M. Newberg\n The Supernova Cosmology Project\n \n \n W. J. Couch\n The Supernova Cosmology Project\n \n 10.1086/307221\n \n 21 pages and 10 figures. Accepted for publication in the\n Astrophysical Journal. Individual color figures, supplementary tables, and\n preprint also available at http://www-supernova.lbl.gov/\n Astrophys.J.517:565-586,1999\n \n \n \n \n \n \n \n\n", 200, null ], @@ -149,7 +201,87 @@ "https://export.arxiv.org/api/query?id_list=math/0211159" ], {}, - "\n\n \n ArXiv Query: search_query=&id_list=math/0211159&start=0&max_results=10\n http://arxiv.org/api/4nVRTcAL5Np4oaGFQnqVPG0+c5k\n 2018-08-14T00:00:00-04:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/math/0211159v1\n 2002-11-11T16:11:49Z\n 2002-11-11T16:11:49Z\n The entropy formula for the Ricci flow and its geometric applications\n We present a monotonic expression for the Ricci flow, valid in all dimensions\nand without curvature assumptions. It is interpreted as an entropy for a\ncertain canonical ensemble. Several geometric applications are given. In\nparticular, (1) Ricci flow, considered on the space of riemannian metrics\nmodulo diffeomorphism and scaling, has no nontrivial periodic orbits (that is,\nother than fixed points); (2) In a region, where singularity is forming in\nfinite time, the injectivity radius is controlled by the curvature; (3) Ricci\nflow can not quickly turn an almost euclidean region into a very curved one, no\nmatter what happens far away. We also verify several assertions related to\nRichard Hamilton's program for the proof of Thurston geometrization conjecture\nfor closed three-manifolds, and give a sketch of an eclectic proof of this\nconjecture, making use of earlier results on collapsing with local lower\ncurvature bound.\n\n \n Grisha Perelman\n \n 39 pages\n \n \n \n \n \n \n\n", + "\n\n \n ArXiv Query: search_query=&id_list=math/0211159&start=0&max_results=10\n http://arxiv.org/api/4nVRTcAL5Np4oaGFQnqVPG0+c5k\n 2019-01-04T00:00:00-05:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/math/0211159v1\n 2002-11-11T16:11:49Z\n 2002-11-11T16:11:49Z\n The entropy formula for the Ricci flow and its geometric applications\n We present a monotonic expression for the Ricci flow, valid in all dimensions\nand without curvature assumptions. It is interpreted as an entropy for a\ncertain canonical ensemble. Several geometric applications are given. In\nparticular, (1) Ricci flow, considered on the space of riemannian metrics\nmodulo diffeomorphism and scaling, has no nontrivial periodic orbits (that is,\nother than fixed points); (2) In a region, where singularity is forming in\nfinite time, the injectivity radius is controlled by the curvature; (3) Ricci\nflow can not quickly turn an almost euclidean region into a very curved one, no\nmatter what happens far away. We also verify several assertions related to\nRichard Hamilton's program for the proof of Thurston geometrization conjecture\nfor closed three-manifolds, and give a sketch of an eclectic proof of this\nconjecture, making use of earlier results on collapsing with local lower\ncurvature bound.\n\n \n Grisha Perelman\n \n 39 pages\n \n \n \n \n \n \n\n", + 200, + null + ], + [ + [ + "https://export.arxiv.org/api/query?id_list=math/9501234" + ], + {}, + "\n\n \n ArXiv Query: search_query=&id_list=math/9501234&start=0&max_results=10\n http://arxiv.org/api/7jH0+0cTfQ0YcTJCQMYE9FyHjoA\n 2019-01-04T00:00:00-05:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/math/9501234v1\n 1995-01-23T00:00:00Z\n 1995-01-23T00:00:00Z\n Aztec diamonds, checkerboard graphs, and spanning trees\n This note derives the characteristic polynomial of a graph that represents\nnonjump moves in a generalized game of checkers. The number of spanning trees\nis also determined.\n\n \n Donald E. Knuth\n \n J. Algebraic Combin. 6 (1997), no. 3, 253--257\n \n \n \n \n \n\n", + 200, + null + ], + [ + [ + "https://export.arxiv.org/api/query?id_list=math/9501234" + ], + {}, + "\n\n \n ArXiv Query: search_query=&id_list=math/9501234&start=0&max_results=10\n http://arxiv.org/api/7jH0+0cTfQ0YcTJCQMYE9FyHjoA\n 2019-01-04T00:00:00-05:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/math/9501234v1\n 1995-01-23T00:00:00Z\n 1995-01-23T00:00:00Z\n Aztec diamonds, checkerboard graphs, and spanning trees\n This note derives the characteristic polynomial of a graph that represents\nnonjump moves in a generalized game of checkers. The number of spanning trees\nis also determined.\n\n \n Donald E. Knuth\n \n J. Algebraic Combin. 6 (1997), no. 3, 253--257\n \n \n \n \n \n\n", + 200, + null + ], + [ + [ + "https://export.arxiv.org/api/query?id_list=math/9501234" + ], + {}, + "\n\n \n ArXiv Query: search_query=&id_list=math/9501234&start=0&max_results=10\n http://arxiv.org/api/7jH0+0cTfQ0YcTJCQMYE9FyHjoA\n 2019-01-04T00:00:00-05:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/math/9501234v1\n 1995-01-23T00:00:00Z\n 1995-01-23T00:00:00Z\n Aztec diamonds, checkerboard graphs, and spanning trees\n This note derives the characteristic polynomial of a graph that represents\nnonjump moves in a generalized game of checkers. The number of spanning trees\nis also determined.\n\n \n Donald E. Knuth\n \n J. Algebraic Combin. 6 (1997), no. 3, 253--257\n \n \n \n \n \n\n", + 200, + null + ], + [ + [ + "https://export.arxiv.org/api/query?id_list=math/9501234" + ], + {}, + "\n\n \n ArXiv Query: search_query=&id_list=math/9501234&start=0&max_results=10\n http://arxiv.org/api/7jH0+0cTfQ0YcTJCQMYE9FyHjoA\n 2019-01-04T00:00:00-05:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/math/9501234v1\n 1995-01-23T00:00:00Z\n 1995-01-23T00:00:00Z\n Aztec diamonds, checkerboard graphs, and spanning trees\n This note derives the characteristic polynomial of a graph that represents\nnonjump moves in a generalized game of checkers. The number of spanning trees\nis also determined.\n\n \n Donald E. Knuth\n \n J. Algebraic Combin. 6 (1997), no. 3, 253--257\n \n \n \n \n \n\n", + 200, + null + ], + [ + [ + "https://www.ottobib.com/isbn/978-0822324669/bibtex" + ], + { + "headers": null + }, + "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n
\n

OttoBib

\n

bibtex Format

\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n

\n NOTE!\n
\n

    \n
  1. Verify accuracy of the data (particularly authors)
  2. \n
  3. Remember to do a HANGING INDENT (something I cannot do with HTML here)
  4. \n
  5. I strive for accuracy of the citations but you should treat this tool as a starting point in your works cited, because you still need to look it over.
  6. \n
\n

\n
\n
\n\n
\n \n\n \n", + 200, + null + ], + [ + [ + "https://www.ottobib.com/isbn/978-0822324669/bibtex" + ], + { + "headers": null + }, + "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n
\n

OttoBib

\n

bibtex Format

\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n

\n NOTE!\n
\n

    \n
  1. Verify accuracy of the data (particularly authors)
  2. \n
  3. Remember to do a HANGING INDENT (something I cannot do with HTML here)
  4. \n
  5. I strive for accuracy of the citations but you should treat this tool as a starting point in your works cited, because you still need to look it over.
  6. \n
\n

\n
\n
\n\n
\n \n\n \n", + 200, + null + ], + [ + [ + "https://www.ottobib.com/isbn/978-0822324669/bibtex" + ], + { + "headers": null + }, + "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n
\n

OttoBib

\n

bibtex Format

\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n

\n NOTE!\n
\n

    \n
  1. Verify accuracy of the data (particularly authors)
  2. \n
  3. Remember to do a HANGING INDENT (something I cannot do with HTML here)
  4. \n
  5. I strive for accuracy of the citations but you should treat this tool as a starting point in your works cited, because you still need to look it over.
  6. \n
\n

\n
\n
\n\n
\n \n\n \n", + 200, + null + ], + [ + [ + "https://www.ottobib.com/isbn/978-0822324669/bibtex" + ], + { + "headers": null + }, + "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n
\n

OttoBib

\n

bibtex Format

\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n

\n NOTE!\n
\n

    \n
  1. Verify accuracy of the data (particularly authors)
  2. \n
  3. Remember to do a HANGING INDENT (something I cannot do with HTML here)
  4. \n
  5. I strive for accuracy of the citations but you should treat this tool as a starting point in your works cited, because you still need to look it over.
  6. \n
\n

\n
\n
\n\n
\n \n\n \n", 200, null ], @@ -160,7 +292,7 @@ { "headers": null }, - "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n
\n

OttoBib

\n

bibtex Format

\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n

\n NOTE!\n
\n

    \n
  1. Verify accuracy of the data (particularly authors)
  2. \n
  3. Remember to do a HANGING INDENT (something I cannot do with HTML here)
  4. \n
  5. I strive for accuracy of the citations but you should treat this tool as a starting point in your works cited, because you still need to look it over.
  6. \n
\n

\n
\n
\n\n
\n \n\n \n", + "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n
\n

OttoBib

\n

bibtex Format

\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n

\n NOTE!\n
\n

    \n
  1. Verify accuracy of the data (particularly authors)
  2. \n
  3. Remember to do a HANGING INDENT (something I cannot do with HTML here)
  4. \n
  5. I strive for accuracy of the citations but you should treat this tool as a starting point in your works cited, because you still need to look it over.
  6. \n
\n

\n
\n
\n\n
\n \n\n \n", 200, null ], @@ -171,7 +303,7 @@ { "headers": null }, - "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n
\n

OttoBib

\n

bibtex Format

\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n

\n NOTE!\n
\n

    \n
  1. Verify accuracy of the data (particularly authors)
  2. \n
  3. Remember to do a HANGING INDENT (something I cannot do with HTML here)
  4. \n
  5. I strive for accuracy of the citations but you should treat this tool as a starting point in your works cited, because you still need to look it over.
  6. \n
\n

\n
\n
\n\n
\n \n\n \n", + "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n
\n

OttoBib

\n

bibtex Format

\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n

\n NOTE!\n
\n

    \n
  1. Verify accuracy of the data (particularly authors)
  2. \n
  3. Remember to do a HANGING INDENT (something I cannot do with HTML here)
  4. \n
  5. I strive for accuracy of the citations but you should treat this tool as a starting point in your works cited, because you still need to look it over.
  6. \n
\n

\n
\n
\n\n
\n \n\n \n", 200, null ], @@ -182,7 +314,7 @@ { "headers": null }, - "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n\t

OttoBib

\n\t

Make a bibliography or works cited with just an ISBN. It's free, easy and FAST

\n\t

\n\t about ottobib and history\n\t \n\t

\n\t \n

\n\t
\n
\n\n
\n
\n\n
No Results for 9999999999999
\n
\n

\n Enter ISBN of book(s) - separate with commas (,)\n

\n \n read more about ISBN on Wikipedia\n \n
\n \n \n \n \n \n\n
\n \n
\n
\n\n
\n
\n\n

Did OttoBib help you? Then help us and Like us on Facebook!

\n
\n
\n\n\n
\n\n\n\n\n
\n \n\n \n", + "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n\t

OttoBib

\n\t

Make a bibliography or works cited with just an ISBN. It's free, easy and FAST

\n\t

\n\t about ottobib and history\n\t \n\t

\n\t \n

\n\t
\n
\n\n
\n
\n\n
No Results for 9999999999999
\n
\n

\n Enter ISBN of book(s) - separate with commas (,)\n

\n \n read more about ISBN on Wikipedia\n \n
\n \n \n \n \n \n\n
\n \n
\n
\n\n
\n
\n\n

Did OttoBib help you? Then help us and Like us on Facebook!

\n
\n
\n\n\n
\n\n\n\n\n
\n \n\n \n", 200, null ] diff --git a/tests/test_repo.py b/tests/test_repo.py index e02f1b0..5bf12d1 100644 --- a/tests/test_repo.py +++ b/tests/test_repo.py @@ -29,10 +29,12 @@ class TestCitekeyGeneration(TestRepo): def test_generated_key_is_unique(self): self.repo.push_paper(Paper.from_bibentry(fixtures.doe_bibentry)) - c = self.repo.unique_citekey('Doe2013') + c = self.repo.unique_citekey('Doe2013', fixtures.doe_bibentry) self.repo.push_paper(Paper.from_bibentry(fixtures.doe_bibentry, citekey='Doe2013a')) - c = self.repo.unique_citekey('Doe2013') + c = self.repo.unique_citekey('Doe2013', fixtures.doe_bibentry) + self.assertEqual(c, 'Doe2013b') + c = self.repo.unique_citekey('bla/bla', fixtures.doe_bibentry) self.assertEqual(c, 'Doe2013b') diff --git a/tests/test_usecase.py b/tests/test_usecase.py index a1ab146..0729990 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -10,10 +10,13 @@ import mock import six import ddt +import certifi +import mock from pyfakefs.fake_filesystem import FakeFileOpen import dotdot import fake_env +import mock_requests from pubs import pubs_cmd, color, content, uis, p3, endecoder from pubs.config import conf @@ -153,9 +156,10 @@ class DataCommandTestCase(CommandTestCase): super(DataCommandTestCase, self).setUp(nsec_stat=nsec_stat) self.fs.add_real_directory(os.path.join(self.rootpath, 'data'), read_only=False) self.fs.add_real_directory(os.path.join(self.rootpath, 'bibexamples'), read_only=False) + # add certificate for web querries + self.fs.add_real_file(certifi.where(), read_only=True) + self.fs.add_real_file(mock_requests._data_filepath, read_only=False) - # fake_env.copy_dir(self.fs, os.path.join(os.path.dirname(__file__), 'data'), 'data') - # fake_env.copy_dir(self.fs, os.path.join(os.path.dirname(__file__), 'bibexamples'), 'bibexamples') def assertFileContentEqual(self, path, expected_content): self.assertTrue(os.path.isfile(path)) @@ -849,7 +853,7 @@ class TestUsecase(DataCommandTestCase): ] outs = self.execute_cmds(cmds) - self.assertEqual(4 + 1, len(outs[-1].split('\n'))) + self.assertEqual(8, len(outs[-1].split('\n'))) def test_import_one(self): cmds = ['pubs init', @@ -1002,10 +1006,10 @@ class TestUsecase(DataCommandTestCase): self.assertEqual(lines[2], 'Total tags: 3, 2 (50%) of papers have at least one tag') def test_add_no_extension(self): - # This tests checks that a paper which document has no - # extension does not raise issues when listing. This test might - # be removed if decided to prevent such documents. It would then need - # to be replaced by a check that this is prevented. + """This tests checks that a paper which document has no extension does + not raise issues when listing. This test might be removed if decided to + prevent such documents. It would then need to be replaced by a check + that this is prevented.""" self.fs.add_real_file(os.path.join(self.rootpath, 'data', 'pagerank.pdf'), target_path=os.path.join('data', 'no-ext')) correct = ['Initializing pubs in /pubs\n', @@ -1019,6 +1023,26 @@ class TestUsecase(DataCommandTestCase): ] self.assertEqual(correct, self.execute_cmds(cmds, capture_output=True)) + @mock.patch('pubs.apis.requests.get', side_effect=mock_requests.mock_requests_get) + def test_readme(self, reqget): + """Test that the readme example work.""" + self.fs.add_real_file(os.path.join(self.rootpath, 'data/pagerank.pdf'), target_path='data/Loeb_2012.pdf') + self.fs.add_real_file(os.path.join(self.rootpath, 'data/pagerank.pdf'), target_path='data/oyama2000the.pdf') + self.fs.add_real_file(os.path.join(self.rootpath, 'data/pagerank.pdf'), target_path='data/Knuth1995.pdf') + + cmds = ['pubs init', + 'pubs import data/collection.bib', + 'pubs add data/pagerank.bib -d data/pagerank.pdf', + #'pubs add -D 10.1007/s00422-012-0514-6 -d data/pagerank.pdf', + 'pubs add -I 978-0822324669 -d data/oyama2000the.pdf', + 'pubs add -X math/9501234 -d data/Knuth1995.pdf', + 'pubs add -D 10.1007/s00422-012-0514-6', + 'pubs doc add data/Loeb_2012.pdf Loeb_2012', + ] + self.execute_cmds(cmds, capture_output=True) +# self.assertEqual(correct, self.execute_cmds(cmds, capture_output=True)) + + @ddt.ddt class TestCache(DataCommandTestCase): From 31a909eed5a2f5d797724f0f2b7a3d46454ecef2 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Fri, 4 Jan 2019 23:33:25 +0900 Subject: [PATCH 06/39] update changelog --- changelog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 3cd48aa..27253c5 100644 --- a/changelog.md +++ b/changelog.md @@ -15,10 +15,11 @@ ## [v0.8.2](https://github.com/pubs/pubs/compare/v0.8.1...v0.8.2) (2018-12-04) -Fixes install on python2. +Fixes install on python2, and adding old-style arXiv references. ### Fixed bugs +- Fixes adding papers with slashes in their citekeys. [(#179)](https://github.com/pubs/pubs/pull/179) (thanks [Amlesh Sivanantham](https://github.com/zamlz) for reporting.) - Fix missing readme.md for python2 pip install. [(#174)](https://github.com/pubs/pubs/pull/174) From 6865e29d1523923f5b299619abde27f2eeaf7291 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 5 Jan 2019 00:45:25 +0900 Subject: [PATCH 07/39] fix for Python 2 --- .gitignore | 2 +- tests/test_usecase.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 50eb853..616af63 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .python-version *~ .DS_Store - +.eggs *.py[cod] diff --git a/tests/test_usecase.py b/tests/test_usecase.py index 0729990..38dc8ca 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -98,6 +98,14 @@ class CommandTestCase(fake_env.TestFakeFs): 3. the expected output on stdout, verified with assertEqual. 4. the expected output on stderr, verified with assertEqual. """ + def normalize(s): + s = color.undye(s) + try: + s = s.decode('utf-8') + except AttributeError: + pass + return s + try: outs = [] for cmd in cmds: @@ -122,8 +130,8 @@ class CommandTestCase(fake_env.TestFakeFs): capture_wrap = fake_env.capture(pubs_cmd.execute, verbose=PRINT_OUTPUT) _, stdout, stderr = capture_wrap(actual_cmd.split()) - actual_out = color.undye(stdout) - actual_err = color.undye(stderr) + actual_out = normalize(stdout) + actual_err = normalize(stderr) if expected_out is not None: self.assertEqual(p3.u_maybe(actual_out), p3.u_maybe(expected_out)) if expected_err is not None: From a484bab67d4f8f2e669b6c862d768b5b544c6083 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 5 Jan 2019 00:49:42 +0900 Subject: [PATCH 08/39] cleanup PR --- pubs/bibstruct.py | 4 +--- pubs/repo.py | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pubs/bibstruct.py b/pubs/bibstruct.py index 9e3e3f4..30af00b 100644 --- a/pubs/bibstruct.py +++ b/pubs/bibstruct.py @@ -51,11 +51,9 @@ def author_last(author_str): return author_str.split(',')[0] -def generate_citekey(bibdata, generate=True): +def generate_citekey(bibdata): """ Generate a citekey from bib_data. - :param generate: if False, return the citekey defined in the file, - does not generate a new one. :raise ValueError: if no author nor editor is defined. """ citekey, entry = get_entry(bibdata) diff --git a/pubs/repo.py b/pubs/repo.py index bb687b6..f747bf3 100644 --- a/pubs/repo.py +++ b/pubs/repo.py @@ -200,6 +200,7 @@ class Repository(object): """ # can't have `/` in citekeys # FIXME: a bit crude, but efficient for now (and allows unicode citekeys) + # TODO: check that the generated citekey does not have a slash too. if '/' in base_key: base_key = bibstruct.generate_citekey(bibentry) for n in itertools.count(): From 9bf88649a3c45138e04af6083082b4c808ae9f00 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 5 Jan 2019 01:06:44 +0900 Subject: [PATCH 09/39] fix #172 --- pubs/commands/conf_cmd.py | 4 ++-- tests/test_usecase.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pubs/commands/conf_cmd.py b/pubs/commands/conf_cmd.py index cd3e9e0..69f8677 100644 --- a/pubs/commands/conf_cmd.py +++ b/pubs/commands/conf_cmd.py @@ -17,9 +17,9 @@ def command(conf, args): while True: # get modif from user - ui.edit_file(config.get_confpath(), temporary=False) + ui.edit_file(conf.filename, temporary=False) - new_conf = config.load_conf() + new_conf = config.load_conf(path=conf.filename) try: config.check_conf(new_conf) ui.message('The configuration file was updated.') diff --git a/tests/test_usecase.py b/tests/test_usecase.py index 38dc8ca..80edea7 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -985,7 +985,7 @@ class TestUsecase(DataCommandTestCase): alt_conf = os.path.expanduser('~/.alt_conf') cmds = ['pubs -c ' + alt_conf + ' init', 'pubs --config ' + alt_conf + ' import data/ Page99', - 'pubs list -c ' + alt_conf + 'pubs list -c ' + alt_conf, ] outs = self.execute_cmds(cmds) # check if pubs works as expected @@ -994,6 +994,11 @@ class TestUsecase(DataCommandTestCase): self.assertFalse(os.path.isfile(self.default_conf_path)) self.assertTrue(os.path.isfile(alt_conf)) + with open(alt_conf, 'r') as fd: + conf_text = fd.read() + outs = self.execute_cmds([('pubs conf -c ' + alt_conf, conf_text)]) + + def test_statistics(self): cmds = ['pubs init', 'pubs statistics', From 3fee6b9403db9e90f8a99449b4ec9613f0edad2b Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 5 Jan 2019 20:57:03 +0900 Subject: [PATCH 10/39] valid_citekey function in bibstruct --- pubs/bibstruct.py | 6 ++++++ pubs/commands/__init__.py | 1 - pubs/pubs_cmd.py | 1 - pubs/repo.py | 6 ++---- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pubs/bibstruct.py b/pubs/bibstruct.py index 30af00b..a8312b0 100644 --- a/pubs/bibstruct.py +++ b/pubs/bibstruct.py @@ -51,6 +51,12 @@ def author_last(author_str): return author_str.split(',')[0] +def valid_citekey(citekey): + """Return if a citekey is a valid filename or not""" + # FIXME: a bit crude, but efficient for now (and allows unicode citekeys) + return not '/' in citekey + + def generate_citekey(bibdata): """ Generate a citekey from bib_data. diff --git a/pubs/commands/__init__.py b/pubs/commands/__init__.py index ddd40ad..ed5defa 100644 --- a/pubs/commands/__init__.py +++ b/pubs/commands/__init__.py @@ -18,4 +18,3 @@ from . import import_cmd # bonus from . import websearch_cmd from . import url_cmd -#from . import bibtex_cmd diff --git a/pubs/pubs_cmd.py b/pubs/pubs_cmd.py index 08911cb..740c709 100644 --- a/pubs/pubs_cmd.py +++ b/pubs/pubs_cmd.py @@ -32,7 +32,6 @@ CORE_CMDS = collections.OrderedDict([ ('websearch', commands.websearch_cmd), ('url', commands.url_cmd), - #('bibtex', commands.bibtex_cmd), ]) diff --git a/pubs/repo.py b/pubs/repo.py index f747bf3..69ca1d7 100644 --- a/pubs/repo.py +++ b/pubs/repo.py @@ -198,11 +198,9 @@ class Repository(object): :param base_key: the base key in question. :param bibentry: the bib entry to possibly generate the citekey. """ - # can't have `/` in citekeys - # FIXME: a bit crude, but efficient for now (and allows unicode citekeys) - # TODO: check that the generated citekey does not have a slash too. - if '/' in base_key: + if not bibstruct.valid_citekey(base_key): base_key = bibstruct.generate_citekey(bibentry) + # TODO: check that the generated citekey does not have a slash too. for n in itertools.count(): if not base_key + _base27(n) in self.citekeys: return base_key + _base27(n) From 2df986a68181ac7556288702d2a5fb11a48f2b26 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 5 Jan 2019 20:58:43 +0900 Subject: [PATCH 11/39] test pip install in travis --- .travis.yml | 81 ++++++++++++++++++++++++++++++++++++++++---------- test_script.sh | 10 +++++++ 2 files changed, 75 insertions(+), 16 deletions(-) create mode 100755 test_script.sh diff --git a/.travis.yml b/.travis.yml index 2c998bb..ea17341 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,42 +1,92 @@ # list of environments to test matrix: include: + + # Full tests (with online API) - os: linux language: python python: 2.7 + env: + - TO_TEST=TEST + - TEST_MODE=FULL - os: linux language: python - python: 3.3 + python: 3.4 + env: + - TO_TEST=TEST + - TEST_MODE=FULL - os: linux language: python - python: 3.4 + python: 3.7 + # dist: xenial + # sudo: true + env: + - TO_TEST=TEST + - TEST_MODE=FULL + - os: osx + language: generic + python: 2.7 + env: + - TO_TEST=TEST + - TEST_MODE=FULL + # before_install: + # - python2 --version + # - pip2 install -U virtualenv + # - virtualenv env -p python2 + # - source env/bin/activate + - os: osx + language: generic + python: ">=3.6" + env: + - TO_TEST=TEST + - TEST_MODE=FULL + before_install: + - brew update + - brew outdated python3 || brew install python3 || brew upgrade python3 + - python3 -m venv env + - source env/bin/activate + + # Mock tests (with mock API) + - os: linux + language: python + python: 3.3 + env: + - TO_TEST=TEST + - TEST_MODE=MOCK - os: linux language: python python: 3.5 + env: + - TO_TEST=TEST + - TEST_MODE=MOCK - os: linux language: python python: 3.6 + env: + - TO_TEST=TEST + - TEST_MODE=MOCK + + # Install tests + - os: linux + language: python + python: 2.7 + env: + - TO_TEST=INSTALL - os: linux language: python python: 3.7 - dist: xenial - sudo: true + env: + - TO_TEST=INSTALL - os: osx language: generic python: 2.7 - before_install: - - python2 --version - - pip2 install -U virtualenv - - virtualenv env -p python2 - - source env/bin/activate + env: + - TO_TEST=INSTALL - os: osx language: generic python: ">=3.6" - before_install: - - brew update - - brew outdated python3 || brew install python3 || brew upgrade python3 - - python3 -m venv env - - source env/bin/activate + env: + - TO_TEST=INSTALL allow_failures: - python: 3.3 @@ -48,5 +98,4 @@ install: # command to run tests script: - - PUBS_TESTS_MODE=MOCK python setup.py test - - PUBS_TESTS_MODE=COLLECT python setup.py test + - ./test_script.sh diff --git a/test_script.sh b/test_script.sh new file mode 100755 index 0000000..d1e9dc1 --- /dev/null +++ b/test_script.sh @@ -0,0 +1,10 @@ +if [ "$TEST_MODE" = "TEST" ]; then + PUBS_TESTS_MODE=MOCK python setup.py test; + if [ "$TO_TEST" = "FULL" ]; then PUBS_TESTS_MODE=COLLECT python setup.py test; fi; +fi + +if [ "$TEST_MODE" = "INSTALL" ]; then + pip install pubs; + pubs --help; + pip uninstall -y pubs; +fi From d1b0b4eee5211f3b4d812c4140a5473c96d17e88 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 5 Jan 2019 21:14:46 +0900 Subject: [PATCH 12/39] simplify travis checks --- .travis.yml | 40 +++++++++++++++------------------------- test_script.sh | 10 ---------- 2 files changed, 15 insertions(+), 35 deletions(-) delete mode 100755 test_script.sh diff --git a/.travis.yml b/.travis.yml index ea17341..6a3cb33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,28 +7,24 @@ matrix: language: python python: 2.7 env: - - TO_TEST=TEST - - TEST_MODE=FULL + - TO_TEST=TEST_FULL - os: linux language: python python: 3.4 env: - - TO_TEST=TEST - - TEST_MODE=FULL + - TO_TEST=TEST_FULL - os: linux language: python python: 3.7 - # dist: xenial - # sudo: true + dist: xenial + sudo: true env: - - TO_TEST=TEST - - TEST_MODE=FULL + - TO_TEST=TEST_FULL - os: osx language: generic python: 2.7 env: - - TO_TEST=TEST - - TEST_MODE=FULL + - TO_TEST=TEST_FULL # before_install: # - python2 --version # - pip2 install -U virtualenv @@ -38,10 +34,8 @@ matrix: language: generic python: ">=3.6" env: - - TO_TEST=TEST - - TEST_MODE=FULL + - TO_TEST=TEST_FULL before_install: - - brew update - brew outdated python3 || brew install python3 || brew upgrade python3 - python3 -m venv env - source env/bin/activate @@ -51,20 +45,17 @@ matrix: language: python python: 3.3 env: - - TO_TEST=TEST - - TEST_MODE=MOCK + - TO_TEST=TEST_MOCK - os: linux language: python python: 3.5 env: - - TO_TEST=TEST - - TEST_MODE=MOCK + - TO_TEST=TEST_MOCK - os: linux language: python python: 3.6 env: - - TO_TEST=TEST - - TEST_MODE=MOCK + - TO_TEST=TEST_MOCK # Install tests - os: linux @@ -91,11 +82,10 @@ matrix: allow_failures: - python: 3.3 -# command to install dependencies -install: - - python --version - - export PUBS_TESTS_MODE=ONLINE - # command to run tests script: - - ./test_script.sh + - python --version + - if [ "$TEST_MODE" = "TEST_FULL" ]; then PUBS_TESTS_MODE=MOCK python setup.py test; fi + - if [ "$TEST_MODE" = "TEST_FULL" ]; then PUBS_TESTS_MODE=COLLECT python setup.py test; fi + - if [ "$TEST_MODE" = "TEST_MOCK" ]; then PUBS_TESTS_MODE=MOCK python setup.py test; fi + - if [ "$TEST_MODE" = "INSTALL" ]; then pip install -U pip; pip install pubs; pubs --help; pip uninstall -y pubs; fi diff --git a/test_script.sh b/test_script.sh deleted file mode 100755 index d1e9dc1..0000000 --- a/test_script.sh +++ /dev/null @@ -1,10 +0,0 @@ -if [ "$TEST_MODE" = "TEST" ]; then - PUBS_TESTS_MODE=MOCK python setup.py test; - if [ "$TO_TEST" = "FULL" ]; then PUBS_TESTS_MODE=COLLECT python setup.py test; fi; -fi - -if [ "$TEST_MODE" = "INSTALL" ]; then - pip install pubs; - pubs --help; - pip uninstall -y pubs; -fi From d82536acf654e529c639635061a226fcdcd4fbba Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 5 Jan 2019 21:20:29 +0900 Subject: [PATCH 13/39] fix .travis install script --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a3cb33..65cbf6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -85,7 +85,7 @@ matrix: # command to run tests script: - python --version - - if [ "$TEST_MODE" = "TEST_FULL" ]; then PUBS_TESTS_MODE=MOCK python setup.py test; fi - - if [ "$TEST_MODE" = "TEST_FULL" ]; then PUBS_TESTS_MODE=COLLECT python setup.py test; fi - - if [ "$TEST_MODE" = "TEST_MOCK" ]; then PUBS_TESTS_MODE=MOCK python setup.py test; fi - - if [ "$TEST_MODE" = "INSTALL" ]; then pip install -U pip; pip install pubs; pubs --help; pip uninstall -y pubs; fi + - if [ "$TO_TEST" = "TEST_FULL" ]; then PUBS_TESTS_MODE=MOCK python setup.py test; fi + - if [ "$TO_TEST" = "TEST_FULL" ]; then PUBS_TESTS_MODE=COLLECT python setup.py test; fi + - if [ "$TO_TEST" = "TEST_MOCK" ]; then PUBS_TESTS_MODE=MOCK python setup.py test; fi + - if [ "$TO_TEST" = "INSTALL" ]; then pip install -U pip; pip install pubs; pubs --help; pip uninstall -y pubs; fi From 1853f90a68616340bf0ad3b7ee94d7ef4654c3da Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 5 Jan 2019 21:28:17 +0900 Subject: [PATCH 14/39] make failing install tests fail --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 65cbf6b..3483ffa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,6 +65,8 @@ matrix: - TO_TEST=INSTALL - os: linux language: python + dist: xenial + sudo: true python: 3.7 env: - TO_TEST=INSTALL @@ -88,4 +90,4 @@ script: - if [ "$TO_TEST" = "TEST_FULL" ]; then PUBS_TESTS_MODE=MOCK python setup.py test; fi - if [ "$TO_TEST" = "TEST_FULL" ]; then PUBS_TESTS_MODE=COLLECT python setup.py test; fi - if [ "$TO_TEST" = "TEST_MOCK" ]; then PUBS_TESTS_MODE=MOCK python setup.py test; fi - - if [ "$TO_TEST" = "INSTALL" ]; then pip install -U pip; pip install pubs; pubs --help; pip uninstall -y pubs; fi + - if [ "$TO_TEST" = "INSTALL" ]; then pip install -U pip && pip install pubs && pubs --help && pip uninstall -y pubs; fi From 8b32ccd9e4a9093653ef890d89d4750c2bc9e384 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 5 Jan 2019 21:38:42 +0900 Subject: [PATCH 15/39] make pubs --help work without pubs init --- pubs/pubs_cmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubs/pubs_cmd.py b/pubs/pubs_cmd.py index 740c709..033880e 100644 --- a/pubs/pubs_cmd.py +++ b/pubs/pubs_cmd.py @@ -60,7 +60,7 @@ def execute(raw_args=sys.argv): # an update happened, reload conf. conf = config.load_conf(path=conf_path) except config.ConfigurationNotFound: - if len(remaining_args) == 0 or remaining_args[0] == 'init': + if len(remaining_args) == 0 or remaining_args[0] == 'init' or remaining_args[0][0] == '-': conf = config.load_default_conf() conf.filename = conf_path else: From 23cacf2fa5abd782972f23ebefec85355df88eda Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 5 Jan 2019 21:40:29 +0900 Subject: [PATCH 16/39] make 3.4 a mock test --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3483ffa..b4c4b01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,6 @@ matrix: python: 2.7 env: - TO_TEST=TEST_FULL - - os: linux - language: python - python: 3.4 - env: - - TO_TEST=TEST_FULL - os: linux language: python python: 3.7 @@ -46,6 +41,11 @@ matrix: python: 3.3 env: - TO_TEST=TEST_MOCK + - os: linux + language: python + python: 3.4 + env: + - TO_TEST=TEST_MOCK - os: linux language: python python: 3.5 From 8bd3649f182f59f91041334118386224faef7156 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 5 Jan 2019 23:19:25 +0900 Subject: [PATCH 17/39] check that all arguments are optional when no config --- pubs/pubs_cmd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubs/pubs_cmd.py b/pubs/pubs_cmd.py index 033880e..6da78f2 100644 --- a/pubs/pubs_cmd.py +++ b/pubs/pubs_cmd.py @@ -60,7 +60,8 @@ def execute(raw_args=sys.argv): # an update happened, reload conf. conf = config.load_conf(path=conf_path) except config.ConfigurationNotFound: - if len(remaining_args) == 0 or remaining_args[0] == 'init' or remaining_args[0][0] == '-': + if (len(remaining_args) == 0 or remaining_args[0] == 'init' + or all(arg[0] == '-' for arg in remaining_args)): # only optional arguments conf = config.load_default_conf() conf.filename = conf_path else: From 7818e57eade8a6aa36c87eca1220da0fb0f1342d Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 5 Jan 2019 23:47:18 +0900 Subject: [PATCH 18/39] reduce the number of isbn test to avoid 403 status --- tests/test_apis.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_apis.py b/tests/test_apis.py index e4d9d4b..a538a36 100644 --- a/tests/test_apis.py +++ b/tests/test_apis.py @@ -49,11 +49,12 @@ class TestDOI2Bibtex(APITests): class TestISBN2Bibtex(APITests): - @mock.patch('pubs.apis.requests.get', side_effect=mock_requests.mock_requests_get) - def test_unicode(self, reqget): - bib = apis.isbn2bibtex('9782081336742') - self.assertIsInstance(bib, ustr) - self.assertIn('Poincaré, Henri', bib) + # try to avoid triggering 403 status during tests. + # @mock.patch('pubs.apis.requests.get', side_effect=mock_requests.mock_requests_get) + # def test_unicode(self, reqget): + # bib = apis.isbn2bibtex('9782081336742') + # self.assertIsInstance(bib, ustr) + # self.assertIn('Poincaré, Henri', bib) @mock.patch('pubs.apis.requests.get', side_effect=mock_requests.mock_requests_get) def test_parses_to_bibtex(self, reqget): From 4a318a46c2aa0c425a197c40997be7074eca4cf0 Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Sat, 5 Jan 2019 10:40:02 -0800 Subject: [PATCH 19/39] Only test install on scheduled builds. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index b4c4b01..d0c8cb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,6 +63,7 @@ matrix: python: 2.7 env: - TO_TEST=INSTALL + if: type = cron - os: linux language: python dist: xenial @@ -70,16 +71,19 @@ matrix: python: 3.7 env: - TO_TEST=INSTALL + if: type = cron - os: osx language: generic python: 2.7 env: - TO_TEST=INSTALL + if: type = cron - os: osx language: generic python: ">=3.6" env: - TO_TEST=INSTALL + if: type = cron allow_failures: - python: 3.3 From 3fa1604155050430f470197dc1eac009cb77b3cd Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Sun, 6 Jan 2019 12:39:45 -0800 Subject: [PATCH 20/39] Minor: fix changelog (missing features in 0.8.2) --- changelog.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 27253c5..1e1f3e0 100644 --- a/changelog.md +++ b/changelog.md @@ -7,13 +7,11 @@ ### Implemented enhancements -- [(#45)](https://github.com/pubs/pubs/issues/45) Doc extension visible in pubs list ([#168](https://github.com/pubs/pubs/pull/168)) - ### Fixed bugs -## [v0.8.2](https://github.com/pubs/pubs/compare/v0.8.1...v0.8.2) (2018-12-04) +## [v0.8.2](https://github.com/pubs/pubs/compare/v0.8.1...v0.8.2) (2019-01-06) Fixes install on python2, and adding old-style arXiv references. @@ -22,6 +20,10 @@ Fixes install on python2, and adding old-style arXiv references. - Fixes adding papers with slashes in their citekeys. [(#179)](https://github.com/pubs/pubs/pull/179) (thanks [Amlesh Sivanantham](https://github.com/zamlz) for reporting.) - Fix missing readme.md for python2 pip install. [(#174)](https://github.com/pubs/pubs/pull/174) +### Implemented enhancements + +- [(#45)](https://github.com/pubs/pubs/issues/45) Doc extension visible in pubs list ([#168](https://github.com/pubs/pubs/pull/168)) + ## [v0.8.1](https://github.com/pubs/pubs/compare/v0.8.0...v0.8.1) (2018-08-28) From fbc9b94f8d1aae767a29fc9119ea3656038073c9 Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Mon, 14 Jan 2019 22:03:53 -0800 Subject: [PATCH 21/39] Fix 177: convert latex to unicode before printing one-liner. This commit actually introduces a new method on the paper object to return a copy of the bibdata which entries' latex have been converted to unicode. --- pubs/paper.py | 6 ++++++ pubs/pretty.py | 2 +- tests/str_fixtures.py | 12 ++++++++++++ tests/test_paper.py | 17 +++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/pubs/paper.py b/pubs/paper.py index e0c10d0..365fd2a 100644 --- a/pubs/paper.py +++ b/pubs/paper.py @@ -1,6 +1,8 @@ import copy from dateutil.parser import parse as datetime_parse +from bibtexparser.customization import convert_to_unicode + from . import bibstruct from .p3 import ustr @@ -102,6 +104,10 @@ class Paper(object): def added(self, value): self.metadata['added'] = value + def get_unicode_bibdata(self): + """Converts latex in bibdata fields to unicode.""" + return convert_to_unicode(self.bibdata) + @staticmethod def from_bibentry(bibentry, citekey=None, metadata=None): bibentry_key, bibdata = bibstruct.get_entry(bibentry) diff --git a/pubs/pretty.py b/pubs/pretty.py index 645ef02..0c951e6 100644 --- a/pubs/pretty.py +++ b/pubs/pretty.py @@ -64,7 +64,7 @@ def paper_oneliner(p, citekey_only=False): if citekey_only: return p.citekey else: - bibdesc = bib_oneliner(p.bibdata) + bibdesc = bib_oneliner(p.get_unicode_bibdata()) doc_str = '' if p.docpath is not None: doc_extension = os.path.splitext(p.docpath)[1] diff --git a/tests/str_fixtures.py b/tests/str_fixtures.py index 3b6ded3..f00c01a 100644 --- a/tests/str_fixtures.py +++ b/tests/str_fixtures.py @@ -84,6 +84,18 @@ not_bibtex = """@misc{this looks, """ +bibtex_with_latex = """@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}, + journal={Science advances}, + volume={4}, + number={11}, + pages={eaar8173}, + year={2018}, + publisher={American Association for the Advancement of Science} +} +""" + sample_conf = """ [main] diff --git a/tests/test_paper.py b/tests/test_paper.py index 9c78554..21a1236 100644 --- a/tests/test_paper.py +++ b/tests/test_paper.py @@ -4,7 +4,9 @@ import unittest import dotdot import fixtures +import str_fixtures from pubs.paper import Paper +from pubs.endecoder import EnDecoder class TestAttributes(unittest.TestCase): @@ -47,5 +49,20 @@ class TestAttributes(unittest.TestCase): Paper(" ", fixtures.doe_bibdata) +class TestPaperUnicodeBibdata(unittest.TestCase): + + def test_no_latex(self): + p = Paper.from_bibentry(fixtures.page_bibentry, + metadata=fixtures.page_metadata).deepcopy() + self.assertEqual(p.bibdata, p.get_unicode_bibdata()) + + def test_latex_converted(self): + bib = EnDecoder().decode_bibdata(str_fixtures.bibtex_with_latex) + p = Paper.from_bibentry(bib) + ubib = p.get_unicode_bibdata() + self.assertEqual(ubib['author'][0], "Kjær, Kurt H") + self.assertEqual(ubib['author'][3], "Bjørk, Anders A") + + if __name__ == '__main__': unittest.main() From 52378d09039726e787eb1450f9f80dcb5ccd5e11 Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Mon, 14 Jan 2019 22:47:38 -0800 Subject: [PATCH 22/39] Adds missing test dependency to certifi. --- dev_requirements.txt | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dev_requirements.txt b/dev_requirements.txt index 0d91a9e..1891f81 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -19,6 +19,7 @@ six # those are the additional packages required to run the tests pyfakefs +certifi ddt mock pytest # optional (python setup.py test works without it), but possible nonetheless diff --git a/setup.py b/setup.py index ee088a2..90757f5 100644 --- a/setup.py +++ b/setup.py @@ -60,7 +60,7 @@ setup( ], test_suite='tests', - tests_require=['pyfakefs>=3.4', 'mock', 'ddt'], + tests_require=['pyfakefs>=3.4', 'mock', 'ddt', 'certifi'], # in order to avoid 'zipimport.ZipImportError: bad local file header' zip_safe=False, From c8352fb7dfa88af1dbc0d09b198b258c6f956760 Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Mon, 14 Jan 2019 23:00:41 -0800 Subject: [PATCH 23/39] Fixes test not passing because bitexparser's latex_to_unicode also normalizes --- tests/test_usecase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_usecase.py b/tests/test_usecase.py index 80edea7..952cb1b 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -288,7 +288,7 @@ class TestAdd(URLContentTestCase): def test_add_utf8_citekey(self): correct = ["", ("added to pubs:\n" - "[hausdorff1949grundzüge] Hausdorff, Felix \"Grundzüge der Mengenlehre\" (1949) \n"), + "[hausdorff1949grundzüge] Hausdorff, Felix \"Grundzüge der Mengenlehre\" (1949) \n"), "The 'hausdorff1949grundzüge' citekey has been renamed into 'アスキー'\n", "The 'アスキー' citekey has been renamed into 'Ḽơᶉëᶆ_ȋṕšᶙṁ'\n" ] 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 24/39] 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) From 03dc4f192baef594416c539de31f6e9f5a45a37f Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Thu, 17 Jan 2019 21:15:53 -0800 Subject: [PATCH 25/39] Fix test not passing because of bytestring on python 2.7 --- tests/test_paper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_paper.py b/tests/test_paper.py index 21a1236..1a3bae6 100644 --- a/tests/test_paper.py +++ b/tests/test_paper.py @@ -60,8 +60,8 @@ class TestPaperUnicodeBibdata(unittest.TestCase): bib = EnDecoder().decode_bibdata(str_fixtures.bibtex_with_latex) p = Paper.from_bibentry(bib) ubib = p.get_unicode_bibdata() - self.assertEqual(ubib['author'][0], "Kjær, Kurt H") - self.assertEqual(ubib['author'][3], "Bjørk, Anders A") + self.assertEqual(ubib['author'][0], u"Kjær, Kurt H") + self.assertEqual(ubib['author'][3], u"Bjørk, Anders A") if __name__ == '__main__': From 3a4acb9fa9e9ff3b95ef09ead222888b1763cac3 Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Thu, 17 Jan 2019 22:40:18 -0800 Subject: [PATCH 26/39] 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 27/39] 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 28/39] 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' From 1a181c44553b81e5495ff4bdc9bc9d9a9c3373b7 Mon Sep 17 00:00:00 2001 From: Shane Stone <12768327+shanewstone@users.noreply.github.com> Date: Wed, 20 Feb 2019 10:55:55 -0700 Subject: [PATCH 29/39] Add CitekeyFilter and FIELD_ALIAS 'key': 'citekey' to query.py --- pubs/query.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pubs/query.py b/pubs/query.py index 9e65eb1..2c82262 100644 --- a/pubs/query.py +++ b/pubs/query.py @@ -15,6 +15,7 @@ FIELD_ALIASES = { 't': 'title', 'tags': 'tag', 'y': 'year', + 'key': 'citekey', } @@ -78,6 +79,12 @@ class AuthorFilter(QueryFilter): for author in paper.bibdata['author']]) +class CitekeyFilter(QueryFilter): + + def __call__(self, paper): + return self._is_query_in(paper.citekey) + + class TagFilter(QueryFilter): def __call__(self, paper): @@ -137,6 +144,9 @@ def _query_block_to_filter(query_block, case_sensitive=None, strict=False): field, value = _get_field_value(query_block) if field == 'tag': return TagFilter(value, case_sensitive=case_sensitive, strict=strict) + elif field == 'citekey': + return CitekeyFilter(value, case_sensitive=case_sensitive, + strict=strict) elif field == 'author': return AuthorFilter(value, case_sensitive=case_sensitive, strict=strict) From c3cb713ae76528eeeaaeb948fe319a76ab3934d8 Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Thu, 28 Feb 2019 22:51:27 -0800 Subject: [PATCH 30/39] Fix test broken likely by pyyaml update by making it more explicit - does not test a specific output from pyyaml dump anymore, - explicitely check decode and encode-decode step. --- tests/test_endecoder.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test_endecoder.py b/tests/test_endecoder.py index 11d5306..d9ade7f 100644 --- a/tests/test_endecoder.py +++ b/tests/test_endecoder.py @@ -26,7 +26,7 @@ class TestEnDecode(unittest.TestCase): def test_decode_emptystring(self): decoder = endecoder.EnDecoder() with self.assertRaises(decoder.BibDecodingError): - entry = decoder.decode_bibdata('') + decoder.decode_bibdata('') def test_encode_bibtex_is_unicode(self): decoder = endecoder.EnDecoder() @@ -117,11 +117,21 @@ class TestEnDecode(unittest.TestCase): self.assertIn('keyword', entry) self.assertEqual(set(keywords), set(entry['keyword'])) + def test_decode_metadata(self): + decoder = endecoder.EnDecoder() + entry = decoder.decode_metadata(metadata_raw0) + expected = {'docfile': 'docsdir://Page99.pdf', + 'tags': ['search', 'network'], + 'added': '2013-11-14 13:14:20', + } + self.assertEqual(entry, expected) + def test_endecode_metadata(self): decoder = endecoder.EnDecoder() entry = decoder.decode_metadata(metadata_raw0) metadata_output0 = decoder.encode_metadata(entry) - self.assertEqual(set(metadata_raw0.split('\n')), set(metadata_output0.split('\n'))) + entry_from_encode = decoder.decode_metadata(metadata_output0) + self.assertEqual(entry, entry_from_encode) def test_endecode_bibtex_field_order(self): decoder = endecoder.EnDecoder() From 9754ed721c71ae886855799f0e28483f955935f8 Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Thu, 28 Feb 2019 22:59:26 -0800 Subject: [PATCH 31/39] Adds missing python 3.7 tests to Travis. --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index d0c8cb0..6910657 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,6 +56,14 @@ matrix: python: 3.6 env: - TO_TEST=TEST_MOCK + - os: linux + language: python + dist: xenial + python: 3.7 + sudo: true + env: + - TO_TEST=TEST_MOCK + # Install tests - os: linux From 7c5ec2ae1e81bab34d70701d228d58da4a37a3cc Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Thu, 28 Feb 2019 23:01:17 -0800 Subject: [PATCH 32/39] Factors mock in travis script. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6910657..cbd0ad2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -99,7 +99,7 @@ matrix: # command to run tests script: - python --version - - if [ "$TO_TEST" = "TEST_FULL" ]; then PUBS_TESTS_MODE=MOCK python setup.py test; fi + - if [ "$TO_TEST" = "TEST_MOCK" ] || + [ "$TO_TEST" = "TEST_FULL" ]; then PUBS_TESTS_MODE=MOCK python setup.py test; fi - if [ "$TO_TEST" = "TEST_FULL" ]; then PUBS_TESTS_MODE=COLLECT python setup.py test; fi - - if [ "$TO_TEST" = "TEST_MOCK" ]; then PUBS_TESTS_MODE=MOCK python setup.py test; fi - if [ "$TO_TEST" = "INSTALL" ]; then pip install -U pip && pip install pubs && pubs --help && pip uninstall -y pubs; fi From d626fe4251836c59b0c84091a95b8844c9289e93 Mon Sep 17 00:00:00 2001 From: Shane Stone <12768327+shanewstone@users.noreply.github.com> Date: Wed, 6 Mar 2019 15:17:31 -0700 Subject: [PATCH 33/39] Add unit tests for CitekeyFilter --- tests/test_queries.py | 49 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/tests/test_queries.py b/tests/test_queries.py index d8cfa86..207c4fc 100644 --- a/tests/test_queries.py +++ b/tests/test_queries.py @@ -4,9 +4,9 @@ from __future__ import unicode_literals import unittest import dotdot -from pubs.query import (AuthorFilter, FieldFilter, YearFilter, - _query_block_to_filter, get_paper_filter, - InvalidQuery) +from pubs.query import (AuthorFilter, CitekeyFilter, FieldFilter, + YearFilter, _query_block_to_filter, + get_paper_filter, InvalidQuery) from pubs.paper import Paper @@ -43,6 +43,49 @@ class TestAuthorFilter(unittest.TestCase): self.assertFalse(AuthorFilter('lawrence')(page_paper)) +class TestCitekeyFilter(unittest.TestCase): + + def test_fails_if_no_citekey(self): + no_citekey = doe_paper.deepcopy() + no_citekey.citekey = '' + self.assertFalse(CitekeyFilter('whatever')(no_citekey)) + + def test_match_case(self): + self.assertTrue(CitekeyFilter('doe201')(doe_paper)) + self.assertTrue(CitekeyFilter('doe201', case_sensitive=False)(doe_paper)) + self.assertTrue(CitekeyFilter('Doe201')(doe_paper)) + + def test_do_not_match_case(self): + self.assertFalse(CitekeyFilter('dOe201')(doe_paper)) + self.assertFalse(CitekeyFilter('dOe201', case_sensitive=True)(doe_paper)) + self.assertFalse(CitekeyFilter('doe201', case_sensitive=True)(doe_paper)) + self.assertTrue(CitekeyFilter('dOe201', case_sensitive=False)(doe_paper)) + + def test_latex_enc(self): + latexenc_paper = doe_paper.deepcopy() + latexenc_paper.citekey = "{G}r{\\\"u}n2013" + self.assertTrue(CitekeyFilter('Grün')(latexenc_paper)) + self.assertTrue(CitekeyFilter('Gr{\\\"u}n')(latexenc_paper)) + + def test_normalize_unicode(self): + latexenc_paper = doe_paper.deepcopy() + latexenc_paper.citekey = "Jalape\u00f1o2013" + self.assertTrue(CitekeyFilter("Jalapen\u0303o")(latexenc_paper)) + + def test_strict(self): + latexenc_paper = doe_paper.deepcopy() + latexenc_paper.citekey = "Jalape\u00f1o2013" + self.assertFalse(CitekeyFilter("Jalapen\u0303o", strict=True)(latexenc_paper)) + latexenc_paper.citekey = "{G}ros2013" + self.assertFalse(CitekeyFilter("Gros", strict=True)(latexenc_paper)) + + def test_strict_implies_case(self): + latexenc_paper = doe_paper.deepcopy() + latexenc_paper.citekey = "Gros2013" + self.assertFalse( + CitekeyFilter("gros", case_sensitive=False, strict=True)(latexenc_paper)) + + class TestCheckTag(unittest.TestCase): pass From 1f967853292ae89856ae60743ee489d78cbeb585 Mon Sep 17 00:00:00 2001 From: Shane Stone <12768327+shanewstone@users.noreply.github.com> Date: Sun, 17 Mar 2019 16:04:53 -0700 Subject: [PATCH 34/39] Add citekey usage example to QUERY_HELP --- pubs/query.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubs/query.py b/pubs/query.py index 2c82262..ef43230 100644 --- a/pubs/query.py +++ b/pubs/query.py @@ -6,7 +6,8 @@ from . import bibstruct QUERY_HELP = ('Paper query ("author:Einstein", "title:learning",' - '"year:2000", "year:2000-2010", or "tags:math")') + ' "year:2000", "year:2000-2010", "citekey:Einstein_1935",' + ' or "tags:math")') FIELD_ALIASES = { From 0125c1816b2d39927907fde4329f245039bd75c8 Mon Sep 17 00:00:00 2001 From: Shane Stone <12768327+shanewstone@users.noreply.github.com> Date: Sun, 17 Mar 2019 16:06:06 -0700 Subject: [PATCH 35/39] Fix indentation in _query_block_to_filter --- pubs/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubs/query.py b/pubs/query.py index ef43230..7bcb656 100644 --- a/pubs/query.py +++ b/pubs/query.py @@ -147,7 +147,7 @@ def _query_block_to_filter(query_block, case_sensitive=None, strict=False): return TagFilter(value, case_sensitive=case_sensitive, strict=strict) elif field == 'citekey': return CitekeyFilter(value, case_sensitive=case_sensitive, - strict=strict) + strict=strict) elif field == 'author': return AuthorFilter(value, case_sensitive=case_sensitive, strict=strict) From 7645b0949c1dde43e1476c1e30d31bb971f52ae6 Mon Sep 17 00:00:00 2001 From: Shane Stone <12768327+shanewstone@users.noreply.github.com> Date: Sun, 17 Mar 2019 16:11:32 -0700 Subject: [PATCH 36/39] Add test for pubs list using citekey filter in test_usecase.py --- tests/test_usecase.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_usecase.py b/tests/test_usecase.py index c83a626..48b1e81 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -505,6 +505,18 @@ class TestList(DataCommandTestCase): outs = self.execute_cmds(cmds) self.assertEqual(1 + 1, len(outs[-1].split('\n'))) + def test_list_with_citekey_query(self): + cmds = ['pubs init', + 'pubs import data/', + 'pubs list citekey:Page99', + 'pubs list key:eiNstein_1935', + 'pubs list --ignore-case key:eiNstein_1935', + ] + outs = self.execute_cmds(cmds) + self.assertEqual(1, len(outs[2].splitlines())) + self.assertEqual(0, len(outs[3].splitlines())) + self.assertEqual(1, len(outs[4].splitlines())) + class TestTag(DataCommandTestCase): From e7fdda080b2f210af2d0e59c4ffb246de683a17a Mon Sep 17 00:00:00 2001 From: Shane Stone <12768327+shanewstone@users.noreply.github.com> Date: Sun, 17 Mar 2019 16:20:04 -0700 Subject: [PATCH 37/39] Add line to changelog.md for citekey filter --- changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.md b/changelog.md index 1e1f3e0..73db144 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,8 @@ ### Implemented enhancements +- Add `citekey` filter to `query` ([#193](https://github.com/pubs/pubs/pull/193) by [Shane Stone](https://github.com/shanewstone)) + ### Fixed bugs From 607f3af23fa085f3440ae7a9f42ac5a832421ae2 Mon Sep 17 00:00:00 2001 From: Shane Stone <12768327+shanewstone@users.noreply.github.com> Date: Sun, 17 Mar 2019 16:23:02 -0700 Subject: [PATCH 38/39] Add myself to contributors in readme.md --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index dd2d902..a2c8c2c 100644 --- a/readme.md +++ b/readme.md @@ -142,3 +142,4 @@ You can access the self-documented configuration by using `pubs conf`, and all t - [Dennis Wilson](https://github.com/d9w) - [Bill Flynn](https://github.com/wflynny) - [ksunden](https://github.com/ksunden) +- [Shane Stone](https://github.com/shanewstone) From 3b6751ea1b7b597c757188ba4e1045674a6abda6 Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Tue, 19 Mar 2019 22:08:36 -0700 Subject: [PATCH 39/39] Minor: Removes duplicate mock import in test_usecase --- tests/test_usecase.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_usecase.py b/tests/test_usecase.py index 48b1e81..da22cd2 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -6,7 +6,6 @@ import os import re import sys import shutil -import mock import six import ddt