|
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
|
|
|
|
|
|
|
|
|
|
|
from .. import repo
|
|
|
|
from .. import repo
|
|
|
|
from .. import color
|
|
|
|
from .. import color
|
|
|
|
|
|
|
|
from .. import pretty
|
|
|
|
from ..uis import get_ui
|
|
|
|
from ..uis import get_ui
|
|
|
|
from ..utils import resolve_citekey_list
|
|
|
|
from ..utils import resolve_citekey_list
|
|
|
|
from ..p3 import ustr, u_maybe
|
|
|
|
from ..p3 import ustr, u_maybe
|
|
|
@ -25,11 +26,15 @@ def command(conf, args):
|
|
|
|
rp = repo.Repository(conf)
|
|
|
|
rp = repo.Repository(conf)
|
|
|
|
|
|
|
|
|
|
|
|
keys = resolve_citekey_list(repo=rp, citekeys=args.citekeys, ui=ui, exit_on_fail=True)
|
|
|
|
keys = resolve_citekey_list(repo=rp, citekeys=args.citekeys, ui=ui, exit_on_fail=True)
|
|
|
|
|
|
|
|
plural = 's' if len(keys) > 1 else ''
|
|
|
|
|
|
|
|
|
|
|
|
if force is None:
|
|
|
|
if force is None:
|
|
|
|
are_you_sure = (("Are you sure you want to delete the publication(s) [{}]"
|
|
|
|
to_remove_str = '\n'.join(pretty.paper_oneliner(rp.pull_paper(key),
|
|
|
|
" (this will also delete associated documents)?")
|
|
|
|
n_authors=conf['main']['n_authors'])
|
|
|
|
.format(', '.join([color.dye_out(c, 'citekey') for c in args.citekeys])))
|
|
|
|
for key in keys)
|
|
|
|
|
|
|
|
are_you_sure = (("Are you sure you want to delete the following publication{}"
|
|
|
|
|
|
|
|
" (this will also delete associated documents)?:\n{}\n")
|
|
|
|
|
|
|
|
.format(plural, to_remove_str))
|
|
|
|
sure = ui.input_yn(question=are_you_sure, default='n')
|
|
|
|
sure = ui.input_yn(question=are_you_sure, default='n')
|
|
|
|
if force or sure:
|
|
|
|
if force or sure:
|
|
|
|
failed = False # Whether something failed
|
|
|
|
failed = False # Whether something failed
|
|
|
@ -42,11 +47,12 @@ def command(conf, args):
|
|
|
|
if failed:
|
|
|
|
if failed:
|
|
|
|
ui.exit() # Exit with nonzero error code
|
|
|
|
ui.exit() # Exit with nonzero error code
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
ui.message('The publication(s) [{}] were removed'.format(
|
|
|
|
|
|
|
|
|
|
|
|
ui.message('The publication{} {} were removed'.format(plural,
|
|
|
|
', '.join([color.dye_out(c, 'citekey') for c in keys])))
|
|
|
|
', '.join([color.dye_out(c, 'citekey') for c in keys])))
|
|
|
|
|
|
|
|
|
|
|
|
# FIXME: print should check that removal proceeded well.
|
|
|
|
# FIXME: print should check that removal proceeded well.
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
ui.message('The publication(s) [{}] were {} removed'.format(
|
|
|
|
ui.message('The publication{} {} were {} removed'.format(plural,
|
|
|
|
', '.join([color.dye_out(c, 'citekey') for c in keys]),
|
|
|
|
', '.join([color.dye_out(c, 'citekey') for c in keys]),
|
|
|
|
color.dye_out('not','bold')))
|
|
|
|
color.dye_out('not','bold')))
|
|
|
|