# sphobjinv.cli.load

Module for `sphobjinv` CLI `Inventory` loading.

`sphobjinv` is a toolkit for manipulation and inspection of Sphinx objects.inv files.

Author

  Brian Skinn (brian.skinn@gmail.com)

File Created

  17 Nov 2020

Copyright

  (c) Brian Skinn 2016-2024

Source Repository

  https://github.com/bskinn/sphobjinv

Documentation

  https://sphobjinv.readthedocs.io/en/stable

License

  Code: MIT License

  Docs & Docstrings: CC BY 4.0 International License

  See LICENSE.txt for full license terms.

Members

import_infile(in_path)

  Attempt import of indicated file.

  Convenience function wrapping attempts to load an `Inventory` from a local path.

  Parameters:

    in_path – `str` – Path to input file

  Returns:

    inv – `Inventory` or `None` – If instantiation with the file at in_path succeeds, the resulting `Inventory` instance; otherwise, `None`

inv_local(params)

  Create `Inventory` from local source.

  Uses `resolve_inpath()` to sanity-check and/or convert `INFILE`.

  Calls `sys.exit()` internally in error-exit situations.

  Parameters:

    params – `dict` – Parameters/values mapping from the active subparser

  Returns:

    - inv – `Inventory` – Object representation of the inventory at `INFILE`

    - in_path – `str` – Input file path as resolved/checked by `resolve_inpath()`

inv_stdin(params)

  Create `Inventory` from contents of stdin.

  Due to stdin’s encoding and formatting assumptions, only text-based inventory formats can be sanely parsed.

  Thus, only plaintext and JSON inventory formats can be used as inputs here.

  Parameters:

    params – `dict` – Parameters/values mapping from the active subparser

  Returns:

    inv – `Inventory` – Object representation of the inventory provided at stdin

inv_url(params)

  Create `Inventory` from file downloaded from URL.

  Initially, treats `INFILE` as a download URL to be passed to the url initialization argument of `Inventory`.

  If an inventory is not found at that exact URL, progressively searches the directory tree of the URL for objects.inv.

  Injects the URL at which an inventory was found into params under the `FOUND_URL` key.

  Calls `sys.exit()` internally in error-exit situations.

  Parameters:

    params – `dict` – Parameters/values mapping from the active subparser

  Returns:

    - inv – `Inventory` – Object representation of the inventory at `INFILE`

    - ret_path – `str` – URL from `INFILE` used to construct inv. If URL is longer than 45 characters, the central portion is elided.