module documentation

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

Function dump_format Pretty-print the data as fmt, with color if interactive, to stdout.
Function dump_from_nestedtext Read NestedText from stdin or input_files, and send an up-typed data format to stdout.
Function dump_to_nestedtext Read typed data from stdin or input_files, and send NestedText to stdout.
Function dump_to_schema Read typed data from stdin or input_files, and send a NestedText schema to stdout.
Constant RICH Undocumented
Function _ansi_ok Return True if it's acceptable to use ANSI escape sequences.
Function _dump_to_nestedtext Pretty-print the data as NestedText, with color if interactive, to stdout.
Function _dump_typed_data_to_schema Undocumented
Function _syntax_print Print a syntax-highlighted rendering of the content to terminal.
def dump_format(*, data: TypedData, fmt: str, dump_stdout: Callable[[TypedData], None], dump_str: Callable[[TypedData], str], **kwargs: Any): (source)

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

Parameters
data:TypedDataTypedData to dump as the format.
fmt:strThe format to dump as (e.g. 'json').
dump_stdout:Callable[[TypedData], None]A function to dump the data to stdout, plainly.
dump_str:Callable[[TypedData], str]A function to dump the data to a string, also plain, for potential colorizing.
**kwargs:AnyKeyword arguments to pass to the format's dump_str or dump_stdout.
def dump_from_nestedtext(*, input_files: LocalPath, dump_stdout: Callable[[TypedData], None], dump_str: Callable[[TypedData], str], fmt: str, converter: Converter, fix_data: Callable[[TypedData], TypedData] | None = None, 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 an up-typed data format to stdout.

Parameters
input_files:LocalPathLocalPaths with NestedText content.
dump_stdout:Callable[[TypedData], None]A function to dump the data to stdout, plainly.
dump_str:Callable[[TypedData], str]A function to dump the data to a string, also plain, for potential colorizing.
fmt:strThe format to use for dumping (e.g., 'toml').
converter:ConverterA Converter used to unstructure the result to match specific type support.
fix_data:Callable[[TypedData], TypedData] | NoneA function to fix the data, post-uptyping, if necessary.
bool_paths:Sequence[str]YAMLPath queries whose matches will be up-typed to bool.
null_paths:Sequence[str]YAMLPath queries whose matches will be up-typed to None.
num_paths:Sequence[str]YAMLPath queries whose matches will be up-typed to int/float.
date_paths:Sequence[str]YAMLPath queries whose matches will be up-typed to date/datetime/time.
def dump_to_nestedtext(*, load_stdin: Callable[[], TypedData], load_file: Callable[[LocalPath], TypedData], input_files: Sequence[LocalPath], inline_width: int = 0): (source)

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

Colorize if stdout is a terminal.

Parameters
load_stdin:Callable[[], TypedData]A function to load typed data from stdin.
load_file:Callable[[LocalPath], TypedData]A function to load typed data from a LocalPath.
input_files:Sequence[LocalPath]LocalPaths with typed data content.
inline_width:intMaximum line length for inline dictionaries and lists.
def dump_to_schema(*, load_stdin: Callable[[], TypedData], load_file: Callable[[LocalPath], TypedData], input_files: Sequence[LocalPath]): (source)

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

Parameters
load_stdin:Callable[[], TypedData]A function to load typed data from stdin.
load_file:Callable[[LocalPath], TypedData]A function to load typed data from a LocalPath.
input_files:Sequence[LocalPath]LocalPaths with typed data content.

Undocumented

Value
RichConsole()
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_to_nestedtext(data: TypedData, *, inline_width: int = 0): (source)

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

Parameters
data:TypedDataAn object, usually dict or list, to dump as NestedText.
inline_width:intMaximum line length for inline dictionaries and lists.
def _dump_typed_data_to_schema(typed_data: TypedData): (source)

Undocumented

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.