module documentation

Main functions to be called by the UI Application classes, after CLI option parsing.

Function dump_huml_to_nestedtext Read HUML from stdin or input_files, and send NestedText to stdout.
Function dump_huml_to_schema Read HUML from stdin or input_files, and send a NestedText schema to stdout.
Function dump_json_to_nestedtext Read JSON from stdin or input_files, and send NestedText to stdout.
Function dump_json_to_schema Read JSON from stdin or input_files, and send a NestedText schema to stdout.
Function dump_nestedtext_to_huml Read NestedText from stdin or input_files, and send up-typed HUML to stdout.
Function dump_nestedtext_to_json Read NestedText from stdin or input_files, and send up-typed JSON to stdout.
Function dump_nestedtext_to_toml Read NestedText from stdin or input_files, and send up-typed TOML to stdout.
Function dump_nestedtext_to_yaml Read NestedText from stdin or input_files, and send up-typed YAML to stdout.
Function dump_toml_to_nestedtext Read TOML from stdin or input_files, and send NestedText to stdout.
Function dump_toml_to_schema Read TOML from stdin or input_files, and send a NestedText schema to stdout.
Function dump_yaml_to_nestedtext Read YAML from stdin or input_files, and send NestedText to stdout.
Function dump_yaml_to_schema Read YAML from stdin or input_files, and send a NestedText schema to stdout.
Function huml_dump Pretty-print the data as HUML, with color if interactive, to stdout.
Function jdump Pretty-print the data as JSON, with color if interactive, to stdout.
Function jloads Wrap json.loads so that on failure it tries parsing as JSON Lines.
Function ntdump Pretty-print the data as NestedText, with color if interactive, to stdout.
Function ntload Wrap nestedtext.load with convenient configuration for this module.
Function tdump Pretty-print the data as TOML, with color if interactive, to stdout.
Function ydump Pretty-print the data as YAML, with color if interactive, to stdout.
Constant RICH Undocumented
Constant YAML_EDITOR Undocumented
Variable HUML_SUPPORT Undocumented
Variable TOML_SUPPORT Undocumented
Function _ansi_ok Return True if it's acceptable to use ANSI escape sequences.
Function _dump_typed_data_to_schema Undocumented
Function _require_huml_support If HUML support is not installed, raise an exception.
Function _require_toml_support If TOML support is not installed, raise an exception.
Function _syntax_print Print a syntax-highlighted rendering of the content to terminal.
def dump_huml_to_nestedtext(*input_files: LocalPath, inline_width: int = 0): (source)

Read HUML from stdin or input_files, and send NestedText to stdout.

Parameters
*input_files:LocalPathLocalPaths with HUML content.
inline_width:intMaximum line length for inline dictionaries and lists.
def dump_huml_to_schema(*input_files: LocalPath): (source)

Read HUML from stdin or input_files, and send a NestedText schema to stdout.

Parameters
*input_files:LocalPathLocalPaths with HUML content.
def dump_json_to_nestedtext(*input_files: LocalPath, inline_width: int = 0): (source)

Read JSON from stdin or input_files, and send NestedText to stdout.

Parameters
*input_files:LocalPathLocalPaths with JSON content.
inline_width:intMaximum line length for inline dictionaries and lists.
def dump_json_to_schema(*input_files: LocalPath): (source)

Read JSON from stdin or input_files, and send a NestedText schema to stdout.

Parameters
*input_files:LocalPathLocalPaths with JSON content.
def dump_nestedtext_to_huml(*input_files: LocalPath, bool_paths: Sequence[str] = (), null_paths: Sequence[str] = (), num_paths: Sequence[str] = ()): (source)

Read NestedText from stdin or input_files, and send up-typed HUML to stdout.

Parameters
*input_files:LocalPathLocalPaths with NestedText content.
bool_paths:Sequence[str]YAMLPath queries whose matches will be casted to bool.
null_paths:Sequence[str]YAMLPath queries whose matches will be casted to None.
num_paths:Sequence[str]YAMLPath queries whose matches will be casted to int/float.
def dump_nestedtext_to_json(*input_files: LocalPath, bool_paths: Sequence[str] = (), null_paths: Sequence[str] = (), num_paths: Sequence[str] = ()): (source)

Read NestedText from stdin or input_files, and send up-typed JSON to stdout.

Parameters
*input_files:LocalPathLocalPaths with NestedText content.
bool_paths:Sequence[str]YAMLPath queries whose matches will be casted to bool.
null_paths:Sequence[str]YAMLPath queries whose matches will be casted to None.
num_paths:Sequence[str]YAMLPath queries whose matches will be casted to int/float.
def dump_nestedtext_to_toml(*input_files: LocalPath, bool_paths: Sequence[str] = (), num_paths: Sequence[str] = (), date_paths: Sequence[str] = ()): (source)

Read NestedText from stdin or input_files, and send up-typed TOML to stdout.

Parameters
*input_files:LocalPathLocalPaths with NestedText content.
bool_paths:Sequence[str]YAMLPath queries whose matches will be casted to bool.
num_paths:Sequence[str]YAMLPath queries whose matches will be casted to int/float.
date_paths:Sequence[str]YAMLPath queries whose matches will be casted to date/datetime/time.
def dump_nestedtext_to_yaml(*input_files: LocalPath, bool_paths: Sequence[str] = (), null_paths: Sequence[str] = (), num_paths: Sequence[str] = (), date_paths: Sequence[str] = ()): (source)

Read NestedText from stdin or input_files, and send up-typed YAML to stdout.

Parameters
*input_files:LocalPathLocalPaths with NestedText content.
bool_paths:Sequence[str]YAMLPath queries whose matches will be casted to bool.
null_paths:Sequence[str]YAMLPath queries whose matches will be casted to None.
num_paths:Sequence[str]YAMLPath queries whose matches will be casted to int/float.
date_paths:Sequence[str]YAMLPath queries whose matches will be casted to date/datetime.
def dump_toml_to_nestedtext(*input_files: LocalPath, inline_width: int = 0): (source)

Read TOML from stdin or input_files, and send NestedText to stdout.

Parameters
*input_files:LocalPathLocalPaths with TOML content.
inline_width:intMaximum line length for inline dictionaries and lists.
def dump_toml_to_schema(*input_files: LocalPath): (source)

Read TOML from stdin or input_files, and send a NestedText schema to stdout.

Parameters
*input_files:LocalPathLocalPaths with TOML content.
def dump_yaml_to_nestedtext(*input_files: LocalPath, inline_width: int = 0): (source)

Read YAML from stdin or input_files, and send NestedText to stdout.

Parameters
*input_files:LocalPathLocalPaths with YAML content.
inline_width:intMaximum line length for inline dictionaries and lists.
def dump_yaml_to_schema(*input_files: LocalPath): (source)

Read YAML from stdin or input_files, and send a NestedText schema to stdout.

Parameters
*input_files:LocalPathLocalPaths with YAML content.
def huml_dump(data: JSONData): (source)

Pretty-print the data as HUML, with color if interactive, to stdout.

Parameters
data:JSONDataA JSONData to dump as HUML.
def jdump(data: JSONData): (source)

Pretty-print the data as JSON, with color if interactive, to stdout.

Parameters
data:JSONDataA JSONData to dump as JSON.
def jloads(content: str) -> JSONData: (source)

Wrap json.loads so that on failure it tries parsing as JSON Lines.

# noqa: DAR401 # noqa: DAR402

Parameters
content:strJSON or JSON Lines content.
Returns
JSONDataParsed JSON data as a JSON-supported type, usually dict or list.
Raises
JSONDecodeErrorUnable to parse content as JSON or JSONLines.
def ntdump(data: JSONData | tuple | set | Schema, inline_width: int = 0): (source)

Pretty-print the data as NestedText, with color if interactive, to stdout.

Parameters
data:JSONData | tuple | set | SchemaAn object, usually dict or list, to dump as NestedText.
inline_width:intMaximum line length for inline dictionaries and lists.
def ntload(file: str | Path | TextIO) -> StringyData: (source)

Wrap nestedtext.load with convenient configuration for this module.

Set top-level type constraint to 'any', and assure the type checker the result is StringyData.

Parameters
file:str | Path | TextIONestedText file-like object, usually a LocalPath or sys.stdin.
Returns
StringyDataParsed NestedText data as StringyData.
def tdump(data: TOMLHashData): (source)

Pretty-print the data as TOML, with color if interactive, to stdout.

Parameters
data:TOMLHashDataA TOMLHashData to dump as TOML.
def ydump(data: YAMLData): (source)

Pretty-print the data as YAML, with color if interactive, to stdout.

Parameters
data:YAMLDataA YAMLData to dump as YAML.
Raises
ExceptionUnexpected problem dumping or highlighting data.

Undocumented

Value
RichConsole()
YAML_EDITOR = (source)

Undocumented

Value
mk_yaml_editor()
HUML_SUPPORT: bool = (source)

Undocumented

TOML_SUPPORT: bool = (source)

Undocumented

def _ansi_ok() -> bool: (source)

Return True if it's acceptable to use ANSI escape sequences.

Returns
boolTrue if stdout is a terminal OR FORCE_COLOR is set.
def _dump_typed_data_to_schema(typed_data: TypedData): (source)

Undocumented

def _require_huml_support(): (source)

If HUML support is not installed, raise an exception.

Raises
ImportErrorThe libraries for HUML support are absent.
def _require_toml_support(): (source)

If TOML support is not installed, raise an exception.

Raises
ImportErrorThe libraries for TOML support are absent.
def _syntax_print(content: str, syntax: str, console: RichConsole = RICH): (source)

Print a syntax-highlighted rendering of the content to terminal.

Parameters
content:strAny code to be syntax-highlighted.
syntax:strA syntax name recognized by pygments (via rich).
console:RichConsoleAn initialized Rich Console object used to print with.