diff --git a/.gitignore b/.gitignore index 114bd34..18d17b5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ build/ dist/ *~ *.pyc -papers.egg-info +*.egg-info .DS_Store diff --git a/papers/commands/update_cmd.py b/papers/commands/update_cmd.py deleted file mode 100644 index e693090..0000000 --- a/papers/commands/update_cmd.py +++ /dev/null @@ -1,63 +0,0 @@ -import sys - -from .. import repo -from .. import color -from ..configs import config -from ..uis import get_ui -from ..__init__ import __version__ - -def parser(subparsers): - parser = subparsers.add_parser('update', help='update the repository to the lastest format') - return parser - - -def command(args): - - ui = get_ui() - - code_version = __version__ - repo_version = int(config().version) - - if repo_version == code_version: - ui.print_('You papers repository is up-to-date.') - sys.exit(0) - elif repo_version > code_version: - ui.print_('Your repository was generated with an newer version of papers.\n' - 'You should not use papers until you install the newest version.') - sys.exit(0) - else: - msg = ("You should backup the paper directory {} before continuing." - "Continue ?").format(color.dye(config().papers_dir, color.filepath)) - sure = ui.input_yn(question=msg, default='n') - if not sure: - sys.exit(0) - - if repo_version == 1: - rp = repo.Repository(config()) - for p in rp.all_papers(): - tags = set(p.metadata['tags']) - tags = tags.union(p.metadata['labels']) - p.metadata.pop('labels', []) - rp.save_paper(p) - repo_version = 2 - - - if repo_version == 2: - # update config - cfg_update = [('papers-directory', 'papers_dir'), - ('open-cmd', 'open_cmd'), - ('edit-cmd', 'edit_cmd'), - ('import-copy', 'import_copy'), - ('import-move', 'import_move'), - ] - for old, new in cfg_update: - try: - config()._cfg.set('papers', new, config()._cfg.get('papers', old)) - config()._cfg.remove_option('papers', old) - except Exception: - pass - config().save() - repo_version = 3 - - config().version = repo_version - config().save() diff --git a/papers/papers b/papers/papers deleted file mode 100755 index 1cc68db..0000000 --- a/papers/papers +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding:utf-8 -*- - -from papers import papers_cmd -papers_cmd.execute() \ No newline at end of file diff --git a/papers/__init__.py b/pubs/__init__.py similarity index 100% rename from papers/__init__.py rename to pubs/__init__.py diff --git a/papers/beets_ui.py b/pubs/beets_ui.py similarity index 100% rename from papers/beets_ui.py rename to pubs/beets_ui.py diff --git a/papers/bibstruct.py b/pubs/bibstruct.py similarity index 100% rename from papers/bibstruct.py rename to pubs/bibstruct.py diff --git a/papers/color.py b/pubs/color.py similarity index 100% rename from papers/color.py rename to pubs/color.py diff --git a/papers/commands/__init__.py b/pubs/commands/__init__.py similarity index 100% rename from papers/commands/__init__.py rename to pubs/commands/__init__.py diff --git a/papers/commands/add_cmd.py b/pubs/commands/add_cmd.py similarity index 100% rename from papers/commands/add_cmd.py rename to pubs/commands/add_cmd.py diff --git a/papers/commands/attach_cmd.py b/pubs/commands/attach_cmd.py similarity index 100% rename from papers/commands/attach_cmd.py rename to pubs/commands/attach_cmd.py diff --git a/papers/commands/edit_cmd.py b/pubs/commands/edit_cmd.py similarity index 76% rename from papers/commands/edit_cmd.py rename to pubs/commands/edit_cmd.py index 2f8dcd3..676e545 100644 --- a/papers/commands/edit_cmd.py +++ b/pubs/commands/edit_cmd.py @@ -1,7 +1,6 @@ -from ..files import editor_input +from ..content import editor_input from .. import repo from ..paper import get_bibentry_from_string, get_safe_metadata_from_content -from .helpers import add_references_argument, parse_reference from ..configs import config from ..uis import get_ui @@ -11,7 +10,8 @@ def parser(subparsers): help='open the paper bibliographic file in an editor') parser.add_argument('-m', '--meta', action='store_true', default=False, help='edit metadata') - add_references_argument(parser, single=True) + parser.add_argument('citekey', + help='citekey of the paper') return parser @@ -19,12 +19,15 @@ def command(args): ui = get_ui() meta = args.meta - reference = args.reference + citekey = args.citekey rp = repo.Repository(config()) - key = parse_reference(rp, reference) - paper = rp.get_paper(key) - filepath = rp._metafile(key) if meta else rp._bibfile(key) + coder = endecoder.EnDecoder() + if meta: + filepath = os.path.join(rp.databroker.databroker.filebroker.metadir(), citekey+'.yaml') + else: + filepath = os.path.join(rp.databroker.databroker.filebroker.bibdir(), citekey+'.bibyaml') + with open(filepath) as f: content = f.read() @@ -49,7 +52,7 @@ def command(args): options = ['overwrite', 'edit again', 'abort'] choice = options[ui.input_choice( options, ['o', 'e', 'a'], - question='A paper already exist with this citekey.' + question='A paper already exists with this citekey.' )] if choice == 'abort': diff --git a/papers/commands/export_cmd.py b/pubs/commands/export_cmd.py similarity index 100% rename from papers/commands/export_cmd.py rename to pubs/commands/export_cmd.py diff --git a/papers/commands/import_cmd.py b/pubs/commands/import_cmd.py similarity index 100% rename from papers/commands/import_cmd.py rename to pubs/commands/import_cmd.py diff --git a/papers/commands/init_cmd.py b/pubs/commands/init_cmd.py similarity index 79% rename from papers/commands/init_cmd.py rename to pubs/commands/init_cmd.py index 622581d..27a018d 100644 --- a/papers/commands/init_cmd.py +++ b/pubs/commands/init_cmd.py @@ -10,9 +10,9 @@ from .. import color def parser(subparsers): parser = subparsers.add_parser('init', - help="initialize the papers directory") + help="initialize the pubs directory") parser.add_argument('-p', '--pubsdir', default=None, - help='path to papers directory (if none, ~/.papers is used)') + help='path to pubs directory (if none, ~/.ubs is used)') parser.add_argument('-d', '--docsdir', default='docsdir://', help=('path to document directory (if not specified, documents will' 'be stored in /path/to/pubsdir/doc/)')) @@ -20,14 +20,14 @@ def parser(subparsers): def command(args): - """Create a .papers directory""" + """Create a .pubs directory""" ui = get_ui() pubsdir = args.pubsdir docsdir = args.docsdir if pubsdir is None: - pubsdir = '~/.papers' + pubsdir = '~/.pubs' pubsdir = os.path.normpath(os.path.abspath(os.path.expanduser(pubsdir))) @@ -36,7 +36,7 @@ def command(args): color.dye(pubsdir, color.filepath))) ui.exit() - ui.print_('Initializing papers in {}.'.format( + ui.print_('Initializing pubs in {}.'.format( color.dye(pubsdir, color.filepath))) config().pubsdir = pubsdir diff --git a/papers/commands/list_cmd.py b/pubs/commands/list_cmd.py similarity index 100% rename from papers/commands/list_cmd.py rename to pubs/commands/list_cmd.py diff --git a/papers/commands/note_cmd.py b/pubs/commands/note_cmd.py similarity index 100% rename from papers/commands/note_cmd.py rename to pubs/commands/note_cmd.py diff --git a/papers/commands/open_cmd.py b/pubs/commands/open_cmd.py similarity index 100% rename from papers/commands/open_cmd.py rename to pubs/commands/open_cmd.py diff --git a/papers/commands/remove_cmd.py b/pubs/commands/remove_cmd.py similarity index 100% rename from papers/commands/remove_cmd.py rename to pubs/commands/remove_cmd.py diff --git a/papers/commands/rename_cmd.py b/pubs/commands/rename_cmd.py similarity index 100% rename from papers/commands/rename_cmd.py rename to pubs/commands/rename_cmd.py diff --git a/papers/commands/tag_cmd.py b/pubs/commands/tag_cmd.py similarity index 94% rename from papers/commands/tag_cmd.py rename to pubs/commands/tag_cmd.py index 2395a9d..d978eb1 100644 --- a/papers/commands/tag_cmd.py +++ b/pubs/commands/tag_cmd.py @@ -1,19 +1,19 @@ """ This command is all about tags. The different use cases are : -1. > papers tag +1. > pubs tag Returns the list of all tags -2. > papers tag citekey +2. > pubs tag citekey Return the list of tags of the given citekey -3. > papers tag citekey math +3. > pubs tag citekey math Add 'math' to the list of tags of the given citekey -4. > papers tag citekey :math +4. > pubs tag citekey :math Remove 'math' for the list of tags of the given citekey -5. > papers tag citekey math+romance-war +5. > pubs tag citekey math+romance-war Add 'math' and 'romance' tags to the given citekey, and remove the 'war' tag -6. > papers tag math +6. > pubs tag math If 'math' is not a citekey, then display all papers with the tag 'math' -7. > papers tag -war+math+romance +7. > pubs tag -war+math+romance display all papers with the tag 'math', 'romance' but not 'war' """ diff --git a/pubs/commands/update_cmd.py b/pubs/commands/update_cmd.py new file mode 100644 index 0000000..48b1741 --- /dev/null +++ b/pubs/commands/update_cmd.py @@ -0,0 +1,37 @@ +import sys + +from .. import repo +from .. import color +from ..configs import config +from ..uis import get_ui +from ..__init__ import __version__ + +def parser(subparsers): + parser = subparsers.add_parser('update', help='update the repository to the lastest format') + return parser + + +def command(args): + + ui = get_ui() + + code_version = __version__ + repo_version = int(config().version) + + if repo_version == code_version: + ui.print_('Your pubs repository is up-to-date.') + sys.exit(0) + elif repo_version > code_version: + ui.print_('Your repository was generated with an newer version of pubs.\n' + 'You should not use pubs until you install the newest version.') + sys.exit(0) + else: + msg = ("You should backup the pubs directory {} before continuing." + "Continue ?").format(color.dye(config().papers_dir, color.filepath)) + sure = ui.input_yn(question=msg, default='n') + if not sure: + sys.exit(0) + + +# config().version = repo_version +# config().save() diff --git a/papers/commands/websearch_cmd.py b/pubs/commands/websearch_cmd.py similarity index 100% rename from papers/commands/websearch_cmd.py rename to pubs/commands/websearch_cmd.py diff --git a/papers/configs.py b/pubs/configs.py similarity index 94% rename from papers/configs.py rename to pubs/configs.py index c538154..9d1a446 100644 --- a/papers/configs.py +++ b/pubs/configs.py @@ -5,8 +5,8 @@ from .p3 import configparser # constant stuff (DFT = DEFAULT) -MAIN_SECTION = 'papers' -DFT_CONFIG_PATH = os.path.expanduser('~/.papersrc') +MAIN_SECTION = 'pubs' +DFT_CONFIG_PATH = os.path.expanduser('~/.pubsrc') try: DFT_EDIT_CMD = os.environ['EDITOR'] except KeyError: @@ -15,7 +15,7 @@ except KeyError: DFT_PLUGINS = '' DFT_CONFIG = collections.OrderedDict([ - ('pubsdir', os.path.expanduser('~/.papers')), + ('pubsdir', os.path.expanduser('~/.pubs')), ('docsdir', ''), ('import_copy', True), ('import_move', False), diff --git a/papers/content.py b/pubs/content.py similarity index 100% rename from papers/content.py rename to pubs/content.py diff --git a/papers/databroker.py b/pubs/databroker.py similarity index 100% rename from papers/databroker.py rename to pubs/databroker.py diff --git a/papers/datacache.py b/pubs/datacache.py similarity index 100% rename from papers/datacache.py rename to pubs/datacache.py diff --git a/papers/endecoder.py b/pubs/endecoder.py similarity index 100% rename from papers/endecoder.py rename to pubs/endecoder.py diff --git a/papers/events.py b/pubs/events.py similarity index 100% rename from papers/events.py rename to pubs/events.py diff --git a/papers/filebroker.py b/pubs/filebroker.py similarity index 100% rename from papers/filebroker.py rename to pubs/filebroker.py diff --git a/papers/p3.py b/pubs/p3.py similarity index 100% rename from papers/p3.py rename to pubs/p3.py diff --git a/papers/paper.py b/pubs/paper.py similarity index 100% rename from papers/paper.py rename to pubs/paper.py diff --git a/papers/plugins.py b/pubs/plugins.py similarity index 95% rename from papers/plugins.py rename to pubs/plugins.py index af33e4a..d7c54cd 100644 --- a/papers/plugins.py +++ b/pubs/plugins.py @@ -35,7 +35,7 @@ def load_plugins(ui, names): PapersPlugin subclasses desired. """ for name in names: - modname = '%s.%s.%s.%s' % ('papers', PLUGIN_NAMESPACE, name, name) + modname = '%s.%s.%s.%s' % ('pubs', PLUGIN_NAMESPACE, name, name) try: namespace = importlib.import_module(modname) except ImportError as exc: diff --git a/papers/plugs/__init__.py b/pubs/plugs/__init__.py similarity index 100% rename from papers/plugs/__init__.py rename to pubs/plugs/__init__.py diff --git a/papers/plugs/alias/__init__.py b/pubs/plugs/alias/__init__.py similarity index 100% rename from papers/plugs/alias/__init__.py rename to pubs/plugs/alias/__init__.py diff --git a/papers/plugs/alias/alias.py b/pubs/plugs/alias/alias.py similarity index 98% rename from papers/plugs/alias/alias.py rename to pubs/plugs/alias/alias.py index 078f8ac..0c6da43 100644 --- a/papers/plugs/alias/alias.py +++ b/pubs/plugs/alias/alias.py @@ -3,7 +3,7 @@ import shlex from ...plugins import PapersPlugin from ...configs import config -from ...papers_cmd import execute +from ...pubs_cmd import execute class Alias(object): diff --git a/papers/plugs/texnote/__init__.py b/pubs/plugs/texnote/__init__.py similarity index 100% rename from papers/plugs/texnote/__init__.py rename to pubs/plugs/texnote/__init__.py diff --git a/papers/plugs/texnote/autofill_tools.py b/pubs/plugs/texnote/autofill_tools.py similarity index 100% rename from papers/plugs/texnote/autofill_tools.py rename to pubs/plugs/texnote/autofill_tools.py diff --git a/papers/plugs/texnote/default_body.tex b/pubs/plugs/texnote/default_body.tex similarity index 100% rename from papers/plugs/texnote/default_body.tex rename to pubs/plugs/texnote/default_body.tex diff --git a/papers/plugs/texnote/default_style.sty b/pubs/plugs/texnote/default_style.sty similarity index 100% rename from papers/plugs/texnote/default_style.sty rename to pubs/plugs/texnote/default_style.sty diff --git a/papers/plugs/texnote/latex_tools.py b/pubs/plugs/texnote/latex_tools.py similarity index 100% rename from papers/plugs/texnote/latex_tools.py rename to pubs/plugs/texnote/latex_tools.py diff --git a/papers/plugs/texnote/texnote.py b/pubs/plugs/texnote/texnote.py similarity index 100% rename from papers/plugs/texnote/texnote.py rename to pubs/plugs/texnote/texnote.py diff --git a/papers/pretty.py b/pubs/pretty.py similarity index 100% rename from papers/pretty.py rename to pubs/pretty.py diff --git a/pubs/pubs b/pubs/pubs new file mode 100755 index 0000000..99991d4 --- /dev/null +++ b/pubs/pubs @@ -0,0 +1,5 @@ +#!/usr/bin/env python2 +# -*- coding:utf-8 -*- + +from pubs import pubs_cmd +pubs_cmd.execute() \ No newline at end of file diff --git a/papers/papers_cmd.py b/pubs/pubs_cmd.py similarity index 92% rename from papers/papers_cmd.py rename to pubs/pubs_cmd.py index 0433fc5..7f513e7 100644 --- a/papers/papers_cmd.py +++ b/pubs/pubs_cmd.py @@ -41,17 +41,17 @@ def _update_check(config, ui): if repo_version > code_version: ui.warning( 'your repository was generated with an newer version' - ' of papers (v{}) than the one you are using (v{}).' + ' of pubs (v{}) than the one you are using (v{}).' '\n'.format(repo_version, code_version) + - 'You should not use papers until you install the ' - 'newest version. (use version_warning in you papersrc ' + 'You should not use pubs until you install the ' + 'newest version. (use version_warning in you pubsrc ' 'to bypass this error)') sys.exit() elif repo_version < code_version: ui.print_( 'warning: your repository version (v{})'.format(repo_version) + 'must be updated to version {}.\n'.format(code_version) - + "run 'papers update'.") + + "run 'pubs update'.") sys.exit() diff --git a/papers/repo.py b/pubs/repo.py similarity index 100% rename from papers/repo.py rename to pubs/repo.py diff --git a/papers/uis.py b/pubs/uis.py similarity index 100% rename from papers/uis.py rename to pubs/uis.py diff --git a/setup.py b/setup.py index 05fd26f..3a9a9fe 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages -setup(name='papers', +setup(name='pubs', version='4', author='Fabien Benureau, Olivier Mangin, Jonathan Grizou', author_email='fabien.benureau+inria@gmail.com', @@ -11,7 +11,7 @@ setup(name='papers', requires=['pybtex'], packages=find_packages(), package_data={'': ['*.tex', '*.sty']}, - scripts=['papers/papers'] + scripts=['pubs/pubs'] ) # TODO include proper package data from plugins (08/06/2013) diff --git a/tests/fake_env.py b/tests/fake_env.py index a8f480c..09c49e3 100644 --- a/tests/fake_env.py +++ b/tests/fake_env.py @@ -11,8 +11,8 @@ import fake_filesystem import fake_filesystem_shutil import fake_filesystem_glob -from papers import color -from papers.p3 import io, input +from pubs import color +from pubs.p3 import io, input # code for fake fs @@ -26,13 +26,13 @@ real_glob = glob # def _mod_list(): # ml = [] -# import papers +# import pubs # for importer, modname, ispkg in pkgutil.walk_packages( -# path=papers.__path__, -# prefix=papers.__name__ + '.', +# path=pubs.__path__, +# prefix=pubs.__name__ + '.', # onerror=lambda x: None): # # HACK to not load textnote -# if not modname.startswith('papers.plugs.texnote'): +# if not modname.startswith('pubs.plugs.texnote'): # ml.append((modname, __import__(modname, fromlist='dummy'))) # return ml diff --git a/tests/fixtures.py b/tests/fixtures.py index 23f1413..78b15e0 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -1,6 +1,8 @@ from pybtex.database import Person -from papers.paper import Paper, get_bibentry_from_string +import testenv +from pubs import endecoder +import str_fixtures turing1950 = Paper() turing1950.bibentry.fields['title'] = u'Computing machinery and intelligence.' @@ -16,35 +18,7 @@ doe2013.bibentry.fields['year'] = u'2013' doe2013.bibentry.persons['author'] = [Person(u'John Doe')] doe2013.citekey = doe2013.generate_citekey() +coder = endecoder.EnDecoder() +bibdata = coder.decode_bibdata(str_fixtures.bibtex_external0, fmt='bibtex') +page99 = Paper(bibdata) -pagerankbib = """ -@techreport{Page99, - number = {1999-66}, - month = {November}, - author = {Lawrence Page and Sergey Brin and Rajeev Motwani and Terry Winograd}, - note = {Previous number = SIDL-WP-1999-0120}, - title = {The PageRank Citation Ranking: Bringing Order to the Web.}, - type = {Technical Report}, - publisher = {Stanford InfoLab}, - year = {1999}, -institution = {Stanford InfoLab}, - url = {http://ilpubs.stanford.edu:8090/422/}, -} -""" - -page99 = Paper(bibentry=get_bibentry_from_string(pagerankbib)[1]) - -pagerankbib_generated = """@techreport{ - Page99, - author = "Page, Lawrence and Brin, Sergey and Motwani, Rajeev and Winograd, Terry", - publisher = "Stanford InfoLab", - title = "The PageRank Citation Ranking: Bringing Order to the Web.", - url = "http://ilpubs.stanford.edu:8090/422/", - number = "1999-66", - month = "November", - note = "Previous number = SIDL-WP-1999-0120", - year = "1999", - institution = "Stanford InfoLab" -} - -""" diff --git a/tests/test.sh b/tests/test.sh index c9e2521..fcb7404 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash rm -Rf tmpdir/*; -papers init -p tmpdir/; -papers add -d data/pagerank.pdf -b data/pagerank.bib; -papers list; -papers tag; -papers tag Page99 network+search; -papers tag Page99; -papers tag search; -papers tag 0; +pubs init -p tmpdir/; +pubs add -d data/pagerank.pdf -b data/pagerank.bib; +pubs list; +pubs tag; +pubs tag Page99 network+search; +pubs tag Page99; +pubs tag search; +pubs tag 0; #rm -Rf tmpdir/*; diff --git a/tests/test_color.py b/tests/test_color.py index 4dd1b01..6c08b28 100644 --- a/tests/test_color.py +++ b/tests/test_color.py @@ -1,5 +1,5 @@ import testenv -from papers import color +from pubs import color def perf_color(): s = str(range(1000)) diff --git a/tests/test_config.py b/tests/test_config.py index 1f7faa6..d1fe85f 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -2,9 +2,9 @@ import unittest import testenv -from papers import configs -from papers.configs import config -from papers.p3 import configparser +from pubs import configs +from pubs.configs import config +from pubs.p3 import configparser class TestConfig(unittest.TestCase): @@ -17,7 +17,7 @@ class TestConfig(unittest.TestCase): a = configs.Config() a.as_global() - self.assertEqual(config().papers_dir, configs.DFT_CONFIG['papers_dir']) + self.assertEqual(config().pubs_dir, configs.DFT_CONFIG['pubs_dir']) self.assertEqual(config().color, configs.str2bool(configs.DFT_CONFIG['color'])) def test_set(self): @@ -25,11 +25,11 @@ class TestConfig(unittest.TestCase): a.as_global() config().color = 'no' self.assertEqual(config().color, False) - self.assertEqual(config('papers').color, False) + self.assertEqual(config('pubs').color, False) # booleans type for new variables are memorized, but not saved. config().bla = True self.assertEqual(config().bla, True) - self.assertEqual(config('papers').bla, True) + self.assertEqual(config('pubs').bla, True) with self.assertRaises(configparser.NoOptionError): config()._cfg.get(configs.MAIN_SECTION, '_section') @@ -65,5 +65,5 @@ class TestConfig(unittest.TestCase): self.assertEqual(config(section = 'bla3').get('color', default = config().color), True) def test_keywords(self): - a = configs.Config(papers_dir = '/blabla') - self.assertEqual(a.papers_dir, '/blabla') + a = configs.Config(pubs_dir = '/blabla') + self.assertEqual(a.pubs_dir, '/blabla') diff --git a/tests/test_databroker.py b/tests/test_databroker.py index 7e4971a..daab329 100644 --- a/tests/test_databroker.py +++ b/tests/test_databroker.py @@ -5,10 +5,10 @@ import os import testenv import fake_env -from papers import content, filebroker, databroker, datacache +from pubs import content, filebroker, databroker, datacache import str_fixtures -from papers import endecoder +from pubs import endecoder class TestFakeFs(unittest.TestCase): """Abstract TestCase intializing the fake filesystem.""" diff --git a/tests/test_endecoder.py b/tests/test_endecoder.py index 2e31e76..4c6910f 100644 --- a/tests/test_endecoder.py +++ b/tests/test_endecoder.py @@ -4,7 +4,7 @@ import unittest import yaml import testenv -from papers import endecoder +from pubs import endecoder from str_fixtures import bibyaml_raw0, bibtexml_raw0, bibtex_raw0, metadata_raw0 diff --git a/tests/test_events.py b/tests/test_events.py index 0339d84..c12ec7f 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -1,7 +1,7 @@ from unittest import TestCase import testenv -from papers.events import Event +from pubs.events import Event _output = None diff --git a/tests/test_filebroker.py b/tests/test_filebroker.py index 32833a8..47c257d 100644 --- a/tests/test_filebroker.py +++ b/tests/test_filebroker.py @@ -5,7 +5,7 @@ import os import testenv import fake_env -from papers import content, filebroker +from pubs import content, filebroker class TestFakeFs(unittest.TestCase): """Abstract TestCase intializing the fake filesystem.""" diff --git a/tests/test_queries.py b/tests/test_queries.py index 0b63af2..bafa009 100644 --- a/tests/test_queries.py +++ b/tests/test_queries.py @@ -66,24 +66,24 @@ class TestCheckQueryBlock(TestCase): class TestFilterPaper(TestCase): def test_case(self): - self.assertTrue(filter_paper(fixtures.doe2013, ['title:nice'])) - self.assertTrue(filter_paper(fixtures.doe2013, ['title:Nice'])) + self.assertTrue (filter_paper(fixtures.doe2013, ['title:nice'])) + self.assertTrue (filter_paper(fixtures.doe2013, ['title:Nice'])) self.assertFalse(filter_paper(fixtures.doe2013, ['title:nIce'])) def test_fields(self): - self.assertTrue(filter_paper(fixtures.doe2013, ['year:2013'])) + self.assertTrue (filter_paper(fixtures.doe2013, ['year:2013'])) self.assertFalse(filter_paper(fixtures.doe2013, ['year:2014'])) - self.assertTrue(filter_paper(fixtures.doe2013, ['author:doe'])) - self.assertTrue(filter_paper(fixtures.doe2013, ['author:Doe'])) + self.assertTrue (filter_paper(fixtures.doe2013, ['author:doe'])) + self.assertTrue (filter_paper(fixtures.doe2013, ['author:Doe'])) def test_tags(self): - self.assertTrue(filter_paper(fixtures.turing1950, ['tag:computer'])) + self.assertTrue (filter_paper(fixtures.turing1950, ['tag:computer'])) self.assertFalse(filter_paper(fixtures.turing1950, ['tag:Ai'])) - self.assertTrue(filter_paper(fixtures.turing1950, ['tag:AI'])) - self.assertTrue(filter_paper(fixtures.turing1950, ['tag:ai'])) + self.assertTrue (filter_paper(fixtures.turing1950, ['tag:AI'])) + self.assertTrue (filter_paper(fixtures.turing1950, ['tag:ai'])) def test_multiple(self): - self.assertTrue(filter_paper(fixtures.doe2013, + self.assertTrue (filter_paper(fixtures.doe2013, ['author:doe', 'year:2013'])) self.assertFalse(filter_paper(fixtures.doe2013, ['author:doe', 'year:2014'])) diff --git a/tests/test_repo.py b/tests/test_repo.py index 398a742..b57372c 100644 --- a/tests/test_repo.py +++ b/tests/test_repo.py @@ -4,10 +4,10 @@ import shutil import os import fixtures -from papers.repo import (Repository, _base27, BIB_DIR, META_DIR, +from pubs.repo import (Repository, _base27, BIB_DIR, META_DIR, CiteKeyCollision) -from papers.paper import PaperInRepo -from papers import configs, files +from pubs.paper import PaperInRepo +from pubs import configs, files class TestCitekeyGeneration(unittest.TestCase): @@ -30,7 +30,7 @@ class TestRepo(unittest.TestCase): def setUp(self): self.tmpdir = tempfile.mkdtemp() - self.repo = Repository(configs.Config(papers_dir=self.tmpdir), load=False) + self.repo = Repository(configs.Config(pubs_dir=self.tmpdir), load=False) self.repo.save() self.repo.add_paper(fixtures.turing1950) diff --git a/tests/test_tag.py b/tests/test_tag.py index 299bdf9..f2db3a7 100644 --- a/tests/test_tag.py +++ b/tests/test_tag.py @@ -2,7 +2,7 @@ import unittest import testenv -from papers.commands.tag_cmd import _parse_tags, _tag_groups +from pubs.commands.tag_cmd import _parse_tags, _tag_groups class TestTag(unittest.TestCase): diff --git a/tests/test_usecase.py b/tests/test_usecase.py index b6c7c77..903a0f1 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -5,12 +5,12 @@ import os import testenv import fake_env -from papers import papers_cmd -from papers import color, content, filebroker, uis, beets_ui, p3 +from pubs import pubs_cmd +from pubs import color, content, filebroker, uis, beets_ui, p3 import str_fixtures -from papers.commands import init_cmd, import_cmd +from pubs.commands import init_cmd, import_cmd # code for fake fs @@ -65,7 +65,7 @@ class CommandTestCase(unittest.TestCase): input = fake_env.FakeInput(cmd[1], [content, uis, beets_ui, p3]) input.as_global() - _, stdout, stderr = fake_env.redirect(papers_cmd.execute)(cmd[0].split()) + _, stdout, stderr = fake_env.redirect(pubs_cmd.execute)(cmd[0].split()) if len(cmd) == 3: actual_out = color.undye(stdout.getvalue()) correct_out = color.undye(cmd[2]) @@ -73,7 +73,7 @@ class CommandTestCase(unittest.TestCase): else: assert type(cmd) == str - _, stdout, stderr = fake_env.redirect(papers_cmd.execute)(cmd.split()) + _, stdout, stderr = fake_env.redirect(pubs_cmd.execute)(cmd.split()) assert(stderr.getvalue() == '') outs.append(color.undye(stdout.getvalue())) @@ -97,28 +97,28 @@ class DataCommandTestCase(CommandTestCase): class TestInit(CommandTestCase): def test_init(self): - pubsdir = os.path.expanduser('~/papers_test2') - papers_cmd.execute('papers init -p {}'.format(pubsdir).split()) + pubsdir = os.path.expanduser('~/pubs_test2') + pubs_cmd.execute('pubs init -p {}'.format(pubsdir).split()) self.assertEqual(set(self.fs['os'].listdir(pubsdir)), {'bib', 'doc', 'meta', 'notes'}) def test_init2(self): - pubsdir = os.path.expanduser('~/.papers') - papers_cmd.execute('papers init'.split()) + pubsdir = os.path.expanduser('~/.pubs') + pubs_cmd.execute('pubs init'.split()) self.assertEqual(set(self.fs['os'].listdir(pubsdir)), {'bib', 'doc', 'meta', 'notes'}) class TestAdd(DataCommandTestCase): def test_add(self): - cmds = ['papers init', - 'papers add -b /data/pagerank.bib -d /data/pagerank.pdf', + cmds = ['pubs init', + 'pubs add -b /data/pagerank.bib -d /data/pagerank.pdf', ] self.execute_cmds(cmds) def test_add2(self): - cmds = ['papers init -p /not_default', - 'papers add -b /data/pagerank.bib -d /data/pagerank.pdf', + cmds = ['pubs init -p /not_default', + 'pubs add -b /data/pagerank.bib -d /data/pagerank.pdf', ] self.execute_cmds(cmds) self.assertEqual(set(self.fs['os'].listdir('/not_default/doc')), {'Page99.pdf'}) @@ -127,37 +127,37 @@ class TestAdd(DataCommandTestCase): class TestList(DataCommandTestCase): def test_list(self): - cmds = ['papers init -p /not_default2', - 'papers list', - 'papers add -b /data/pagerank.bib -d /data/pagerank.pdf', - 'papers list', + cmds = ['pubs init -p /not_default2', + 'pubs list', + 'pubs add -b /data/pagerank.bib -d /data/pagerank.pdf', + 'pubs list', ] self.execute_cmds(cmds) def test_list_smart_case(self): - cmds = ['papers init', - 'papers list', - 'papers import data/', - 'papers list title:language author:Saunders', + cmds = ['pubs init', + 'pubs list', + 'pubs import data/', + 'pubs list title:language author:Saunders', ] outs = self.execute_cmds(cmds) print outs[-1] self.assertEquals(1, len(outs[-1].split('/n'))) def test_list_ignore_case(self): - cmds = ['papers init', - 'papers list', - 'papers import data/', - 'papers list --ignore-case title:lAnguAge author:saunders', + cmds = ['pubs init', + 'pubs list', + 'pubs import data/', + 'pubs list --ignore-case title:lAnguAge author:saunders', ] outs = self.execute_cmds(cmds) self.assertEquals(1, len(outs[-1].split('/n'))) def test_list_force_case(self): - cmds = ['papers init', - 'papers list', - 'papers import data/', - 'papers list --force-case title:Language author:saunders', + cmds = ['pubs init', + 'pubs list', + 'pubs import data/', + 'pubs list --force-case title:Language author:saunders', ] outs = self.execute_cmds(cmds) self.assertEquals(0 + 1, len(outs[-1].split('/n'))) @@ -167,7 +167,7 @@ class TestList(DataCommandTestCase): class TestUsecase(DataCommandTestCase): def test_first(self): - correct = ['Initializing papers in /paper_first.\n', + correct = ['Initializing pubs in /paper_first.\n', '', '[Page99] L. Page et al. "The PageRank Citation Ranking Bringing Order to the Web" (1999) \n', '', @@ -176,55 +176,55 @@ class TestUsecase(DataCommandTestCase): '[Page99] L. Page et al. "The PageRank Citation Ranking Bringing Order to the Web" (1999) search network\n' ] - cmds = ['papers init -p paper_first/', - 'papers add -d data/pagerank.pdf -b data/pagerank.bib', - 'papers list', - 'papers tag', - 'papers tag Page99 network+search', - 'papers tag Page99', - 'papers tag search', + cmds = ['pubs init -p paper_first/', + 'pubs add -d data/pagerank.pdf -b data/pagerank.bib', + 'pubs list', + 'pubs tag', + 'pubs tag Page99 network+search', + 'pubs tag Page99', + 'pubs tag search', ] self.assertEqual(correct, self.execute_cmds(cmds)) def test_second(self): - cmds = ['papers init -p paper_second/', - 'papers add -b data/pagerank.bib', - 'papers add -d data/turing-mind-1950.pdf -b data/turing1950.bib', - 'papers add -b data/martius.bib', - 'papers add -b data/10.1371%2Fjournal.pone.0038236.bib', - 'papers list', - 'papers attach Page99 data/pagerank.pdf' + cmds = ['pubs init -p paper_second/', + 'pubs add -b data/pagerank.bib', + 'pubs add -d data/turing-mind-1950.pdf -b data/turing1950.bib', + 'pubs add -b data/martius.bib', + 'pubs add -b data/10.1371%2Fjournal.pone.0038236.bib', + 'pubs list', + 'pubs attach Page99 data/pagerank.pdf' ] self.execute_cmds(cmds) def test_third(self): - cmds = ['papers init', - 'papers add -b data/pagerank.bib', - 'papers add -d data/turing-mind-1950.pdf -b data/turing1950.bib', - 'papers add -b data/martius.bib', - 'papers add -b data/10.1371%2Fjournal.pone.0038236.bib', - 'papers list', - 'papers attach Page99 data/pagerank.pdf', - ('papers remove Page99', ['y']), - 'papers remove -f turing1950computing', + cmds = ['pubs init', + 'pubs add -b data/pagerank.bib', + 'pubs add -d data/turing-mind-1950.pdf -b data/turing1950.bib', + 'pubs add -b data/martius.bib', + 'pubs add -b data/10.1371%2Fjournal.pone.0038236.bib', + 'pubs list', + 'pubs attach Page99 data/pagerank.pdf', + ('pubs remove Page99', ['y']), + 'pubs remove -f turing1950computing', ] self.execute_cmds(cmds) def test_editor_abort(self): with self.assertRaises(SystemExit): - cmds = ['papers init', - ('papers add', ['abc', 'n']), - ('papers add', ['abc', 'y', 'abc', 'n']), - 'papers add -b data/pagerank.bib', - ('papers edit Page99', ['', 'a']), + cmds = ['pubs init', + ('pubs add', ['abc', 'n']), + ('pubs add', ['abc', 'y', 'abc', 'n']), + 'pubs add -b data/pagerank.bib', + ('pubs edit Page99', ['', 'a']), ] self.execute_cmds(cmds) def test_editor_success(self): - cmds = ['papers init', - ('papers add', [str_fixtures.bibtex_external0]), - ('papers remove Page99', ['y']), + cmds = ['pubs init', + ('pubs add', [str_fixtures.bibtex_external0]), + ('pubs remove Page99', ['y']), ] self.execute_cmds(cmds) @@ -239,64 +239,64 @@ class TestUsecase(DataCommandTestCase): line2 = re.sub('L. Page', 'L. Ridge', line1) line3 = re.sub('Page99', 'Ridge07', line2) - cmds = ['papers init', - 'papers add -b data/pagerank.bib', - ('papers list', [], line), - ('papers edit Page99', [bib1]), - ('papers list', [], line1), - ('papers edit Page99', [bib2]), - ('papers list', [], line2), - ('papers edit Page99', [bib3]), - ('papers list', [], line3), + cmds = ['pubs init', + 'pubs add -b data/pagerank.bib', + ('pubs list', [], line), + ('pubs edit Page99', [bib1]), + ('pubs list', [], line1), + ('pubs edit Page99', [bib2]), + ('pubs list', [], line2), + ('pubs edit Page99', [bib3]), + ('pubs list', [], line3), ] self.execute_cmds(cmds) def test_export(self): - cmds = ['papers init', - ('papers add', [str_fixtures.bibtex_external0]), - 'papers export Page99', - ('papers export Page99 -f bibtex', [], str_fixtures.bibtex_raw0), - 'papers export Page99 -f bibyaml', + cmds = ['pubs init', + ('pubs add', [str_fixtures.bibtex_external0]), + 'pubs export Page99', + ('pubs export Page99 -f bibtex', [], str_fixtures.bibtex_raw0), + 'pubs export Page99 -f bibyaml', ] self.execute_cmds(cmds) def test_import(self): - cmds = ['papers init', - 'papers import data/', - 'papers list' + cmds = ['pubs init', + 'pubs import data/', + 'pubs list' ] outs = self.execute_cmds(cmds) self.assertEqual(4 + 1, len(outs[-1].split('\n'))) def test_import_one(self): - cmds = ['papers init', - 'papers import data/ Page99', - 'papers list' + cmds = ['pubs init', + 'pubs import data/ Page99', + 'pubs list' ] outs = self.execute_cmds(cmds) self.assertEqual(1 + 1, len(outs[-1].split('\n'))) def test_open(self): - cmds = ['papers init', - 'papers add -b data/pagerank.bib', - 'papers open Page99' + cmds = ['pubs init', + 'pubs add -b data/pagerank.bib', + 'pubs open Page99' ] with self.assertRaises(SystemExit): self.execute_cmds(cmds) with self.assertRaises(SystemExit): - cmds[-1] == 'papers open Page8' + cmds[-1] == 'pubs open Page8' self.execute_cmds(cmds) def test_update(self): - cmds = ['papers init', - 'papers add -b data/pagerank.bib', - 'papers update' + cmds = ['pubs init', + 'pubs add -b data/pagerank.bib', + 'pubs update' ] with self.assertRaises(SystemExit):