diff --git a/pubs/commands/export_cmd.py b/pubs/commands/export_cmd.py index cab8201..65bc1cc 100644 --- a/pubs/commands/export_cmd.py +++ b/pubs/commands/export_cmd.py @@ -1,18 +1,16 @@ from __future__ import print_function -import sys from .. import repo from ..configs import config from ..uis import get_ui from .. import endecoder + def parser(subparsers): - parser = subparsers.add_parser('export', - help='export bibliography') + parser = subparsers.add_parser('export', help='export bibliography') # parser.add_argument('-f', '--bib-format', default='bibtex', # help='export format') - parser.add_argument('citekeys', nargs='*', - help='one or several citekeys') + parser.add_argument('citekeys', nargs='*', help='one or several citekeys') return parser @@ -27,7 +25,7 @@ def command(args): try: papers = [rp.pull_paper(c) for c in args.citekeys] - except repo.InvalidReference, v: + except repo.InvalidReference as v: ui.error(v) ui.exit(1) @@ -36,9 +34,6 @@ def command(args): bib = {} for p in papers: bib[p.citekey] = p.bibentry - try: - exporter = endecoder.EnDecoder() - bibdata_raw = exporter.encode_bibdata(bib) - print(bibdata_raw, end='') - except KeyError: - ui.error("Invalid output format: %s." % bib_format) + exporter = endecoder.EnDecoder() + bibdata_raw = exporter.encode_bibdata(bib) + ui.print_(bibdata_raw)