# sphobjinv.cli.write

Module for `sphobjinv` CLI `Inventory` writing.

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

Author

  Brian Skinn (brian.skinn@gmail.com)

File Created

  19 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

write_file(inv, in_path, params)

  Write the inventory contents to a file on disk.

  Parameters:

    - inv – `Inventory` – Objects inventory to be written to stdout

    - in_path – `str` – For a local input file, its absolute path. For a URL, the (possibly truncated) URL text.

    - params – dict – argparse parameters

  Raises:

    ValueError – If both params[“expand”] and params[“contract”] are `True`

write_json(inv, path, params)

  Write an `Inventory` to JSON.

  Writes output via `fileops.writejson()`.

  Calling with both expand and contract as `True` is invalid.

  Parameters:

    - inv – `Inventory` – Objects inventory to be written zlib-compressed

    - path – `str` – Path to output file

    - params – dict – argparse parameters

  Raises:

    ValueError – If both params[“expand”] and params[“contract”] are `True`

write_plaintext(inv, path, *, expand=False, contract=False)

  Write an `Inventory` to plaintext.

  Newlines are inserted in an OS-aware manner, based on the value of `os.linesep`.

  Calling with both expand and contract as `True` is invalid.

  Parameters:

    - inv – `Inventory` – Objects inventory to be written as plaintext

    - path – `str` – Path to output file

    - expand – `bool` (optional) – Generate output with any `uri` or `dispname` abbreviations expanded

    - contract – `bool` (optional) – Generate output with abbreviated `uri` and `dispname` values

  Raises:

    ValueError – If both expand and contract are `True`

write_stdout(inv, params)

  Write the inventory contents to stdout.

  Parameters:

    - inv – `Inventory` – Objects inventory to be written to stdout

    - params – dict – argparse parameters

  Raises:

    ValueError – If both params[“expand”] and params[“contract”] are `True`

write_zlib(inv, path, *, expand=False, contract=False)

  Write an `Inventory` to zlib-compressed format.

  > Calling with both expand and contract as `True` is invalid.

  Parameters:

    - inv – `Inventory` – Objects inventory to be written zlib-compressed

    - path – `str` – Path to output file

    - expand – `bool` (optional) – Generate output with any `uri` or `dispname` abbreviations expanded

    - contract – `bool` (optional) – Generate output with abbreviated `uri` and `dispname` values

  Raises:

    ValueError – If both expand and contract are `True`