"""A papis script to interact with bibtex files""" global explorer_mgr ctx.obj = {'documents': []} if no_auto_read: logger.info('Setting auto-read to False') config.set('auto-read', 'False', section='bibtex') bibfile = config.get('default-read-bibfile', section='bibtex') if (bool(config.getboolean('auto-read', section='bibtex')) and bibfile and os.path.exists(bibfile)): logger.info("auto reading {0}".format(bibfile)) explorer_mgr['bibtex'].plugin.callback(bibfile) cli.add_command(explorer_mgr['bibtex'].plugin, 'read') @cli.command('add') @papis.cli.query_option() @click.help_option('-h', '--help') @papis.cli.all_option() @click.pass_context def _add(ctx: click.Context, query: str, _all: bool) -> None: """Add a refrence to the bibtex file""" docs = papis.api.get_documents_in_lib(search=query) if not _all: docs = list(papis.api.pick_doc(docs)) ctx.obj['documents'].extend(docs)
papis explore crossref -m 200 -a 'Schrodinger' \\ pick cmd 'papis scihub {doc[doi]}' """ from subprocess import call import shlex logger = logging.getLogger('explore:cmd') docs = ctx.obj['documents'] for doc in docs: fcommand = papis.document.format_doc(command, doc) splitted_command = shlex.split(fcommand) logger.info('Calling %s' % splitted_command) call(splitted_command) @click.group("explore", cls=papis.cli.AliasedGroup, invoke_without_command=False, chain=True) @click.help_option('--help', '-h') @click.pass_context def cli(ctx: click.Context) -> None: """ Explore new documents using a variety of resources """ ctx.obj = {'documents': []} for _explorer in get_available_explorers(): cli.add_command(_explorer)