sphobjinv.cli.ui

sphobjinv CLI UI functions.

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-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

err_format(exc)

Pretty-format an exception.

Parameters

excException – Exception instance to pretty-format

Returns

pretty_excstr – Exception type and message formatted as ‘{type}: {message}’

print_stderr(thing, params, *, end='\n')

Print thing to stderr if not in quiet mode.

Quiet mode is indicated by the value at the QUIET key within params.

Quiet mode is not implemented for the “suggest” CLI mode.

Parameters
  • thingany – Object to be printed

  • paramsdict – Parameters/values mapping from the active subparser

  • endstr – String to append to printed content (default: \n)

yesno_prompt(prompt)

Query user at stdin for yes/no confirmation.

Uses input(), so will hang if used programmatically unless stdin is suitably mocked.

The value returned from input() must satisfy either resp.lower() == ‘n’ or resp.lower() == ‘y’, or else the query will be repeated ad infinitum. This function does NOT augment prompt to indicate the constraints on the accepted values.

Parameters

promptstr – Prompt to display to user that requests a ‘Y’ or ‘N’ response

Returns

respstr – User response