def cli(query: str, doc_folder: str, tool: str, folder: bool, sort_field: Optional[str], sort_reverse: bool, _all: bool, mark: bool) -> None: """Open document from a given library""" if tool: papis.config.set("opentool", tool) logger = logging.getLogger('cli:run') if doc_folder: documents = [from_folder(doc_folder)] else: documents = papis.database.get().query(query) if sort_field: documents = papis.document.sort(documents, sort_field, sort_reverse) if not documents: logger.warning(papis.strings.no_documents_retrieved_message) return if not _all: documents = [d for d in papis.pick.pick_doc(documents)] for document in documents: run(document, folder=folder, mark=mark)
def cli(query, doc_folder, tool, folder, all, mark): """Open document from a given library""" if tool: papis.config.set("opentool", tool) logger = logging.getLogger('cli:run') documents = papis.database.get().query(query) if doc_folder: documents = [from_folder(doc_folder)] if not documents: logger.warning(papis.strings.no_documents_retrieved_message) return 0 if not all: documents = [papis.api.pick_doc(documents)] documents = [d for d in documents if d] for document in documents: run(document, folder=folder, mark=mark)
def test_from_folder() -> None: doc = from_folder( os.path.join(os.path.dirname(__file__), 'resources', 'document')) assert (isinstance(doc, Document)) assert (doc['author'] == 'Russell, Bertrand')