ran pep8 on pubs/utils

main
Bill Flynn 7 years ago
parent aa408e9b2d
commit 098cb4d1bf

@ -6,25 +6,29 @@ from . import pretty
def resolve_citekey(repo, citekey, ui=None, exit_on_fail=True):
"""Check that a citekey exists, or autocompletes it if not ambiguous."""
""" :returns found citekey """
"""Check that a citekey exists, or autocompletes it if not ambiguous.
:returns found citekey
"""
# FIXME. Make me optionally non ui interactive/exiting
citekeys = repo.citekeys_from_prefix(citekey)
if len(citekeys) == 0:
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:
ui.exit()
elif len(citekeys) == 1:
if citekeys[0] != citekey:
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]
elif citekey not in citekeys:
if ui is not None:
citekeys = sorted(citekeys)
ui.error("Be more specific; '{}' matches multiples citekeys:".format(
citekey))
ui.error("Be more specific; '{}' matches multiples "
"citekeys:".format(citekey))
for c in citekeys:
p = repo.pull_paper(c)
ui.message(u' {}'.format(pretty.paper_oneliner(p)))

Loading…
Cancel
Save