papers renamed 'pubs'

main
Fabien Benureau 11 years ago
parent b03b899c5a
commit 8d91545472

2
.gitignore vendored

@ -2,5 +2,5 @@ build/
dist/
*~
*.pyc
papers.egg-info
*.egg-info
.DS_Store

@ -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()

@ -1,5 +0,0 @@
#!/usr/bin/env python2
# -*- coding:utf-8 -*-
from papers import papers_cmd
papers_cmd.execute()

@ -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':

@ -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

@ -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'
"""

@ -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()

@ -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),

@ -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:

@ -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):

@ -0,0 +1,5 @@
#!/usr/bin/env python2
# -*- coding:utf-8 -*-
from pubs import pubs_cmd
pubs_cmd.execute()

@ -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()

@ -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)

@ -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

@ -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"
}
"""

@ -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/*;

@ -1,5 +1,5 @@
import testenv
from papers import color
from pubs import color
def perf_color():
s = str(range(1000))

@ -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')

@ -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."""

@ -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

@ -1,7 +1,7 @@
from unittest import TestCase
import testenv
from papers.events import Event
from pubs.events import Event
_output = None

@ -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."""

@ -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']))

@ -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)

@ -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):

@ -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):

Loading…
Cancel
Save