ran pep8 on pubs/utils
This commit is contained in:
parent
aa408e9b2d
commit
098cb4d1bf
@ -6,25 +6,29 @@ from . import pretty
|
|||||||
|
|
||||||
|
|
||||||
def resolve_citekey(repo, citekey, ui=None, exit_on_fail=True):
|
def resolve_citekey(repo, citekey, ui=None, exit_on_fail=True):
|
||||||
"""Check that a citekey exists, or autocompletes it if not ambiguous."""
|
"""Check that a citekey exists, or autocompletes it if not ambiguous.
|
||||||
""" :returns found citekey """
|
:returns found citekey
|
||||||
|
"""
|
||||||
# FIXME. Make me optionally non ui interactive/exiting
|
# FIXME. Make me optionally non ui interactive/exiting
|
||||||
citekeys = repo.citekeys_from_prefix(citekey)
|
citekeys = repo.citekeys_from_prefix(citekey)
|
||||||
if len(citekeys) == 0:
|
if len(citekeys) == 0:
|
||||||
if ui is not None:
|
if ui is not None:
|
||||||
ui.error("No citekey named or beginning with '{}'".format(color.dye_out(citekey, 'citekey')))
|
ui.error("No citekey named or beginning with '{}'".format(
|
||||||
|
color.dye_out(citekey, 'citekey')))
|
||||||
if exit_on_fail:
|
if exit_on_fail:
|
||||||
ui.exit()
|
ui.exit()
|
||||||
elif len(citekeys) == 1:
|
elif len(citekeys) == 1:
|
||||||
if citekeys[0] != citekey:
|
if citekeys[0] != citekey:
|
||||||
if ui is not None:
|
if ui is not None:
|
||||||
ui.info("'{}' has been autocompleted into '{}'.".format(color.dye_out(citekey, 'citekey'), color.dye_out(citekeys[0], 'citekey')))
|
ui.info("'{}' has been autocompleted into '{}'.".format(
|
||||||
|
color.dye_out(citekey, 'citekey'),
|
||||||
|
color.dye_out(citekeys[0], 'citekey')))
|
||||||
citekey = citekeys[0]
|
citekey = citekeys[0]
|
||||||
elif citekey not in citekeys:
|
elif citekey not in citekeys:
|
||||||
if ui is not None:
|
if ui is not None:
|
||||||
citekeys = sorted(citekeys)
|
citekeys = sorted(citekeys)
|
||||||
ui.error("Be more specific; '{}' matches multiples citekeys:".format(
|
ui.error("Be more specific; '{}' matches multiples "
|
||||||
citekey))
|
"citekeys:".format(citekey))
|
||||||
for c in citekeys:
|
for c in citekeys:
|
||||||
p = repo.pull_paper(c)
|
p = repo.pull_paper(c)
|
||||||
ui.message(u' {}'.format(pretty.paper_oneliner(p)))
|
ui.message(u' {}'.format(pretty.paper_oneliner(p)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user