Merges PR #66
This commit is contained in:
commit
6dd4b319ea
@ -20,6 +20,8 @@ def parser(subparsers, conf):
|
|||||||
help="don't copy document files, just create a link.")
|
help="don't copy document files, just create a link.")
|
||||||
parser.add_argument('keys', nargs='*',
|
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")
|
||||||
|
parser.add_argument('-O', '--overwrite', action='store_true', default=False,
|
||||||
|
help="Overwrite keys already in the database")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -78,7 +80,7 @@ def command(conf, args):
|
|||||||
if isinstance(p, Exception):
|
if isinstance(p, Exception):
|
||||||
ui.error(u'Could not load entry for citekey {}.'.format(k))
|
ui.error(u'Could not load entry for citekey {}.'.format(k))
|
||||||
else:
|
else:
|
||||||
rp.push_paper(p)
|
rp.push_paper(p, overwrite=args.overwrite)
|
||||||
ui.info(u'{} imported.'.format(color.dye_out(p.citekey, 'citekey')))
|
ui.info(u'{} imported.'.format(color.dye_out(p.citekey, 'citekey')))
|
||||||
docfile = bibstruct.extract_docfile(p.bibdata)
|
docfile = bibstruct.extract_docfile(p.bibdata)
|
||||||
if docfile is None:
|
if docfile is None:
|
||||||
|
@ -687,6 +687,26 @@ class TestUsecase(DataCommandTestCase):
|
|||||||
outs = self.execute_cmds(cmds)
|
outs = self.execute_cmds(cmds)
|
||||||
self.assertEqual(1 + 1, len(outs[-1].split('\n')))
|
self.assertEqual(1 + 1, len(outs[-1].split('\n')))
|
||||||
|
|
||||||
|
def test_import_does_not_overwrite(self):
|
||||||
|
cmds = ['pubs init',
|
||||||
|
'pubs import data/ Page99',
|
||||||
|
'pubs import data/',
|
||||||
|
'pubs list'
|
||||||
|
]
|
||||||
|
|
||||||
|
with self.assertRaises(FakeSystemExit):
|
||||||
|
self.execute_cmds(cmds)
|
||||||
|
|
||||||
|
def test_import_overwrites(self):
|
||||||
|
cmds = ['pubs init',
|
||||||
|
'pubs import data/ Page99',
|
||||||
|
'pubs import --overwrite data/ Page99',
|
||||||
|
'pubs list'
|
||||||
|
]
|
||||||
|
|
||||||
|
outs = self.execute_cmds(cmds)
|
||||||
|
self.assertEqual(1 + 1, len(outs[-1].split('\n')))
|
||||||
|
|
||||||
def test_update(self):
|
def test_update(self):
|
||||||
cmds = ['pubs init',
|
cmds = ['pubs init',
|
||||||
'pubs add data/pagerank.bib',
|
'pubs add data/pagerank.bib',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user