示例#1
0
def update_by(corpus, **kwargs):
    """Reindex a document by author name and/or title. """

    with click_spinner.spinner():
        kwargs["path"] = Path(kwargs["path"])
        c = Corpus(corpus)
        docix = c.update_by(**kwargs)

    if docix in [doc["docix"] for doc in c.iter_docs()]:
        click.echo(f"[+] updated document {docix} in '{corpus}'")
    else:
        click.echo(f"[-] failed")
示例#2
0
def index(corpus):
    """List indexed works in a corpus. """

    c = Corpus(corpus)
    docs = sorted(c.iter_docs(), key=lambda x: x[0])

    if docs:
        for docix, doc in docs:
            if "author" in doc and "title" in doc:
                click.echo(
                    f"[{doc['docix']}] {doc['author']}, {doc['title']} [{doc['filename']}]"
                )
            else:
                click.echo(f"[{doc['docix']}] {doc['filename']}")
    else:
        click.echo(f"[-] nothing indexed for '{corpus}'")