Processor

Processor

class Processor[source]

Bases: Generic[configpile.processor._Config]

Configuration processor

Attributes

Note: attributes inherited from parent classes are not shown here, if any

config_type

Configuration to parse

argument_parser

Completed argument parser, used only for documentation purposes (CLI and Sphinx)

env_handlers

Environment variable handlers

ini_processor

INI file processor

cl_handler

Command line arguments handler

params_by_name

Dictionary of parameters by field name

validators

Methods

make

Creates the processor corresponding to a configuration

process

Processes command-line arguments (deprecated)

process_command_line

Processes command-line arguments, configuration files and environment variables

process_fields

Returns a sequence of the arguments present in a configuration, with updated data

process_ini_contents

Processes the configuration in INI format contained in a string

process_ini_file

Processes the configuration contained in an INI file

List of members of Processor

config_type: Type[configpile.processor._Config]

Configuration to parse

argument_parser: argparse.ArgumentParser

Completed argument parser, used only for documentation purposes (CLI and Sphinx)

env_handlers: Mapping[str, configpile.handlers.KVHandler]

Environment variable handlers

ini_processor: configpile.processor.IniProcessor

INI file processor

cl_handler: configpile.handlers.CLStdHandler

Command line arguments handler

params_by_name: Mapping[str, configpile.arg.Param[Any]]

Dictionary of parameters by field name

validators: Sequence[Callable[[configpile.processor._Config], Optional[configpile.userr.Err]]]
static process_fields(config_type)[source]

Returns a sequence of the arguments present in a configuration, with updated data

Parameters

config_type (Type[TypeVar(_Config, bound= Config)]) – Configuration to process

Return type

Sequence[Arg]

Returns

Sequence of arguments

static make(config_type)[source]

Creates the processor corresponding to a configuration

Return type

Processor[TypeVar(_Config, bound= Config)]

process_ini_contents(ini_contents)[source]

Processes the configuration in INI format contained in a string

Parameters

ini_contents (str) – Multiline string containing information in INI format

Return type

Union[TypeVar(_Config, bound= Config), Err]

Returns

The parsed configuration or an error

process_ini_file(ini_file_path)[source]

Processes the configuration contained in an INI file

Parameters

ini_file_path (Path) – Path to the file to parse

Return type

Union[TypeVar(_Config, bound= Config), Err]

Returns

The parsed configuration or an error

process(cwd, args, env)[source]

Processes command-line arguments (deprecated)

See also: process_command_line()

Return type

Union[TypeVar(_Config, bound= Config), SpecialAction, Err]

process_command_line(cwd, args, env)[source]

Processes command-line arguments, configuration files and environment variables

Parameters
  • cwd (Path) – Working directory, used as a base for configuration file relative paths

  • args (Sequence[str]) – Command line arguments to parse

  • env (Mapping[str, str]) – Environment variables

Return type

Union[TypeVar(_Config, bound= Config), SpecialAction, Err]

Returns

Either a parsed configuration, a special action to execute, or (a list of) errors

__init__(config_type, argument_parser, env_handlers, ini_processor, cl_handler, params_by_name, validators)
static __new__(cls, *args, **kwds)