asyncutils.tools#
Utilities related to the command-line interface and getting metadata for package configuration.
Functions#
|
Parse the shell-escaped string representing the command-line arguments for this module and writes it into a .json path. |
|
|
|
Essentially the output of |
|
|
|
Get the URL of the |
|
|
|
Return the command line help as a string containing ANSI colour escape sequences. |
|
Load the file at |
|
Open the URL to the documentation of the specified symbol defined in |
|
Print the format, as gotten by |
|
Print the help, as returned by |
Module Contents#
- asyncutils.tools.argstr_to_cfg(
- argstr: str,
- path: _typeshed.FileDescriptorOrPath,
- /,
- *,
- dump: asyncutils._internal.prots.DumpType = ...,
- split: collections.abc.Callable[[str], collections.abc.Sequence[str]] = ...,
Parse the shell-escaped string representing the command-line arguments for this module and writes it into a .json path.
- asyncutils.tools.argv_to_cfg(
- argv: collections.abc.Sequence[str],
- path: _typeshed.FileDescriptorOrPath,
- /,
- *,
- dump: asyncutils._internal.prots.DumpType = ...,
- Writes the sequence of strings, parsed as command-line arguments for this module, into
path, in JSON format by default, or the format chosen by thedumpparameter if passed.Since this function is environment-agnostic, it may behave unexpectedly if the arguments passed rely on current configuration, which is not captured.
- asyncutils.tools.cfg_to_argstr(path: _typeshed.FileDescriptorOrPath, /, *, join: collections.abc.Callable[[list[str]], str] = ...) str[source]#
Essentially the output of
cfg_to_argv(), but joined into a shell-escaped string withjoin.
- asyncutils.tools.cfg_to_argv(path: _typeshed.FileDescriptorOrPath, /) list[str][source]#
- Return a list of strings representing the command-line arguments for this module from
pathto the corresponding file, with as little items as possible.When an integer is passed topath, it is assumed to be a file descriptor for a JSON file. An alternate file extension cannot be specified.The module should have aloads()function that takes a string of the file contents and returns adictdeserialized from it.Perfect round-trip conversion withargv_to_cfg()is guaranteed only with no other configuration file active.
- asyncutils.tools.find_help_url(obj: object = ..., /, *, ver: Literal['latest', 'stable'] = ...) str[source]#
Get the URL of the
asyncutilsdocumentation page forobj. See the supported calling patterns here.Caution
The URL returned is not guaranteed to work with strings representing non-existent, undocumented or internal symbols.
- asyncutils.tools.get_cfg_json_format() str[source]#
- Get the format of .json configs this module takes as a string.
print_cfg_json_format()is perhaps more useful.If you would like a format schema for other languages, a programmatic approach would likely be unnecessary; you can just use an online tool implementing a browser-based converter.
- asyncutils.tools.get_cmd_help() str#
Return the command line help as a string containing ANSI colour escape sequences.
Implementation detail
This is actually a bound method of the library’s argument parser at runtime.
- asyncutils.tools.loadf(path: _typeshed.FileDescriptorOrPath, ext: str = ..., /) dict[str, Any][source]#
Load the file at
path, with the specified file extension if undeducible from the file name, into a dictionary using the correct library.
- asyncutils.tools.open_help(obj: object = ..., /, *, ver: Literal['latest', 'stable'] = ...) bool[source]#
Open the URL to the documentation of the specified symbol defined in
asyncutilsvia the default browser, returning success.
- asyncutils.tools.print_cfg_json_format(file: asyncutils._internal.prots.CanWriteAndFlush[str] = ..., *, flush: bool = ...) None[source]#
Print the format, as gotten by
get_cfg_json_format(), into the specified file and flush it (defaultstdout).
- asyncutils.tools.print_cmd_help(file: asyncutils._internal.prots.CanWriteAndFlush[str] = ..., *, flush: bool = ...) None[source]#
Print the help, as returned by
get_cmd_help(), into the specified file (defaultstdout) and flush it.