typeddfs.utils.cli_help

Utils for getting nice CLI help on DataFrame inputs.

Attention

The exact text used in this module are subject to change.

Note

Two consecutive newlines (\n\n) are used to separate sections. This is consistent with a number of formats, including Markdown, reStructuredText, and Typer.

Module Contents

class typeddfs.utils.cli_help.DfCliHelp
classmethod help(cls, clazz: Type[typeddfs.abs_dfs.AbsDf]) DfHelp

Returns info suitable for CLI help.

Display this info as the help description for an argument that’s a path to a table file that will be read with typeddfs.abs_dfs.AbsDf.read_file() for clazz.

Parameters

clazz – The typeddfs.typed_dfs.AbsDf subclass

classmethod list_formats(cls, *, flexwf_sep: str = _FLEXWF_SEP, hdf_key: str = _HDF_KEY, toml_aot: str = _TOML_AOT) DfFormatsHelp

Lists all file formats with descriptions.

For example, typeddfs.file_formats.FileFormat.ods is β€œOpenDocument Spreadsheet”.

class typeddfs.utils.cli_help.DfFormatHelp

Help text on a specific file format.

desc :str
fmt :typeddfs.file_formats.FileFormat
property all_suffixes(self) Sequence[str]

Returns all suffixes, naturally sorted.

property bare_suffixes(self) Sequence[str]

Returns all suffixes, excluding compressed variants (etc. .gz), naturally sorted.

get_text(self) str

Returns a 1-line string of the suffixes and format description.

class typeddfs.utils.cli_help.DfFormatsHelp

Help on file formats only.

Initialize self. See help(type(self)) for accurate signature.

get_long_text(self, *, recommended_only: bool = False, nl: str = '\n', bullet: str = '- ', indent: str = '  ') str

Returns a multi-line text listing of allowed file formats.

Parameters
  • recommended_only – Skip non-recommended file formats

  • nl – Newline characters; use β€œn”, β€œ\n”, or ” β€œ

  • bullet – Prepended to each item

  • indent – Spaces for nested indent

Returns

Something like::

[[ Supported formats ]]:

.csv[.bz2/.gz/.xz/.zip]: comma-delimited

.parquet/.snappy: Parquet

.h5/.hdf/.hdf5: HDF5 (key β€˜df’) [discouraged]

.pickle/.pkl: Python Pickle [discouraged]

get_short_text(self, *, recommended_only: bool = False) str

Returns a single-line text listing of allowed file formats.

Parameters

recommended_only – Skip non-recommended file formats

Returns

Something like::

.csv, .tsv/.tab, or .flexwf [.gz,/.xz,/.zip/.bz2]; .feather, .pickle, or .snappy …

class typeddfs.utils.cli_help.DfHelp

Info on a TypedDf suitable for CLI help.

clazz :Type[typeddfs.abs_dfs.AbsDf]
formats :DfFormatsHelp
get_header_text(self, *, use_doc: bool = True, nl: str = '\n') str

Returns a multi-line header of the DataFrame name and docstring.

Parameters
  • use_doc – Include the docstring, as long as it is not None

  • nl – Newline characters; use β€œn”, β€œnn”, or ” β€œ

Returns

Something like::

Path to a Big Table file.

This is a big table for big things.

get_long_text(self, *, use_doc: bool = True, recommended_only: bool = False, nl: str = '\n', bullet: str = '- ', indent: str = '  ') str

Returns a multi-line text description of the DataFrame. Includes its required and optional columns, and supported file formats.

Parameters
  • use_doc – Include the docstring of the DataFrame type

  • recommended_only – Only include recommended formats

  • nl – Newline characters; use β€œn”, β€œnn”, or ” β€œ

  • bullet – Prepended to each item

  • indent – Spaces for nested indent

abstract get_long_typing_text(self) str

Returns multi-line text on only the required columns / structure.

get_short_text(self, *, use_doc: bool = True, recommended_only: bool = False, nl: str = '\n') str

Returns a multi-line description with compressed text.

Parameters
  • use_doc – Include the docstring of the DataFrame type

  • recommended_only – Only include recommended formats

  • nl – Newline characters; use β€œn”, β€œ\n”, or ” β€œ

abstract get_short_typing_text(self) str

Returns 1-line text on only the required columns / structure.

property typing(self) typeddfs.df_typing.DfTyping