sphobjinv.fileops

File I/O helpers for sphobjinv.

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

Author

Brian Skinn (brian.skinn@gmail.com)

File Created

5 Nov 2017

Copyright

(c) Brian Skinn 2016-2022

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

readbytes(path)

Read file contents and return as bytes.

Changed in version 2.1: path can now be Path or str. Previously, it had to be str.

Parameters

pathstr or Path – Path to file to be opened.

Returns

bbytes – Contents of the indicated file.

readjson(path)

Create dict from JSON file.

No data or schema validation is performed.

Changed in version 2.1: path can now be Path or str. Previously, it had to be str.

Parameters

pathstr or Path – Path to JSON file to be read.

Returns

ddict – Deserialized JSON.

urlwalk(url)

Generate a series of candidate objects.inv URLs.

URLs are based on the seed url passed in. Ensure that the path separator in url is the standard forward slash (’/’).

Parameters

urlstr – Seed URL defining directory structure to walk through.

Yields

inv_urlstr – Candidate URL for objects.inv location.

writebytes(path, contents)

Write indicated file contents.

Any existing file at path will be overwritten.

Changed in version 2.1: path can now be Path or str. Previously, it had to be str.

Parameters
  • pathstr or Path – Path to file to be written.

  • contentsbytes – Content to be written to file.

writejson(path, d)

Create JSON file from dict.

No data or schema validation is performed. Any existing file at path will be overwritten.

Changed in version 2.1: path can now be Path or str. Previously, it had to be str.

Parameters
  • pathstr or Path – Path to output JSON file.

  • ddict – Data structure to serialize.