How to use the manubot.__version__ function in manubot

To help you get started, we’ve selected a few manubot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github manubot / manubot / tests / test_command.py View on Github external
def test_version():
    stdout = subprocess.check_output(
        ['manubot', '--version'],
        universal_newlines=True,
    )
    version_str = f'v{manubot.__version__}'
    assert version_str == stdout.rstrip()
github manubot / manubot / manubot / cite / citekey.py View on Github external
Generate a CSL Item (Python dictionary) for the input citekey.
    """
    from manubot.cite.csl_item import CSL_Item
    from manubot import __version__ as manubot_version

    citekey == standardize_citekey(citekey, warn_if_changed=True)
    source, identifier = citekey.split(":", 1)

    if source not in citeproc_retrievers:
        msg = f"Unsupported citation source {source!r} in {citekey!r}"
        raise ValueError(msg)
    citeproc_retriever = import_function(citeproc_retrievers[source])
    csl_item = citeproc_retriever(identifier)
    csl_item = CSL_Item(csl_item)

    note_text = f"This CSL JSON Item was automatically generated by Manubot v{manubot_version} using citation-by-identifier."
    note_dict = {"standard_id": citekey}
    csl_item.note_append_text(note_text)
    csl_item.note_append_dict(note_dict)

    short_citekey = shorten_citekey(citekey)
    csl_item.set_id(short_citekey)
    csl_item.clean(prune=prune)

    return csl_item
github manubot / manubot / manubot / process / metadata.py View on Github external
def get_software_versions() -> dict:
    """
    Return a dictionary of software versions for softwares components:

    - manubot_version: the semantic version number of the manubot python package.
    - rootstock_commit: the version of the rootstock repository, as a commit hash,
      included in the manuscript repository.

    Values whose detection fails are set to None.
    """
    from manubot import __version__ as manubot_version

    return {
        "manubot_version": manubot_version,
        "rootstock_commit": get_rootstock_commit(),
    }
github manubot / manubot / manubot / command.py View on Github external
def parse_arguments():
    """
    Read and process command line arguments.
    """
    parser = argparse.ArgumentParser(
        description="Manubot: the manuscript bot for scholarly writing"
    )
    parser.add_argument(
        "--version", action="version", version=f"v{manubot.__version__}"
    )
    subparsers = parser.add_subparsers(
        title="subcommands", description="All operations are done through subcommands:"
    )
    # Require specifying a sub-command
    subparsers.required = True  # https://bugs.python.org/issue26510
    subparsers.dest = "subcommand"  # https://bugs.python.org/msg186387
    add_subparser_process(subparsers)
    add_subparser_cite(subparsers)
    add_subparser_webpage(subparsers)
    for subparser in subparsers.choices.values():
        subparser.add_argument(
            "--log-level",
            default="WARNING",
            choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
            help="Set the logging level for stderr logging",
github manubot / manubot / manubot / process / bibliography.py View on Github external
JSON CSL stored as a Python object, to be used in addition to the CSL JSON
    stored as text in the file specified by path. Set paths=[] to only use extra_csl_items.
    """
    from manubot.cite.csl_item import CSL_Item

    csl_items = []
    for path in paths:
        path = pathlib.Path(path)
        if not path.is_file():
            logging.warning(
                f"process.load_bibliographies is skipping a non-existent path: {path}"
            )
            continue
        for csl_item in load_bibliography(path):
            csl_item.note_append_text(
                f"This CSL JSON Item was loaded by Manubot v{manubot_version} from a manual reference file."
            )
            csl_item.note_append_dict({"manual_reference_filename": path.name})
            csl_items.append(csl_item)
    csl_items.extend(map(CSL_Item, extra_csl_items))
    manual_refs = dict()
    for csl_item in csl_items:
        try:
            csl_item.standardize_id()
        except Exception:
            csl_item_str = json.dumps(csl_item, indent=2)
            logging.info(
                f"Skipping csl_item where setting standard_id failed:\n{csl_item_str}",
                exc_info=True,
            )
            continue
        standard_id = csl_item["id"]