pytconf package

Submodules

pytconf.color_utils module

pytconf.color_utils.color_hi(text)[source]
pytconf.color_utils.color_ok(text)[source]
pytconf.color_utils.color_warn(text)[source]
pytconf.color_utils.identity(text)[source]
pytconf.color_utils.print_error(text)[source]
pytconf.color_utils.print_highlight(text)[source]
pytconf.color_utils.print_title(text)[source]
pytconf.color_utils.print_warn(text)[source]

pytconf.config module

class pytconf.config.Config[source]

Bases: object

class pytconf.config.ConfigFormat(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

JSON = 1
YAML = 2
class pytconf.config.ConfigType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

SYSTEM = 2
USER = 1
class pytconf.config.FunctionData(name: str, description: str, function: Callable, configs: List[pytconf.config.Config] = <factory>, suggest_configs: List[pytconf.config.Config] = <factory>, allow_free_args: bool = False, min_free_args: Optional[int] = None, max_free_args: Optional[int] = None, group: str = 'default')[source]

Bases: object

allow_free_args: bool = False
configs: List[Config]
description: str
function: Callable
group: str = 'default'
max_free_args: int | None = None
min_free_args: int | None = None
name: str
suggest_configs: List[Config]
class pytconf.config.FunctionGroupData(name: str, description: str, show_meta: bool = False, show: bool = False, names: Set[str] = <factory>, list_names: List[str] = <factory>)[source]

Bases: object

description: str
list_names: List[str]
name: str
names: Set[str]
show: bool = False
show_meta: bool = False
class pytconf.config.MetaConfig(name, bases, namespace)[source]

Bases: type

class pytconf.config.PytconfConf[source]

Bases: object

config_arg_parse_and_launch(args: List[str] | None = None, launch=True, do_exit=True) None[source]
static get_config(app_name: str, config_type: ConfigType, config_format: ConfigFormat)[source]
get_function_selected(args: List[str], errors) FunctionData | None[source]
get_html() str[source]
classmethod get_html_for_config(config, html_gen)[source]
get_html_for_function(name: str, html_gen)[source]
has_function(function_name: str) bool[source]
launch(launch: bool, select: FunctionData | None, errors)[source]
parse_args(args, errors, flags)[source]
classmethod print_errors(errors: ErrorsCollector) None[source]
process_flags(select: FunctionData, flags: Dict[str, str], errors: ErrorsCollector) None[source]
static read_flags_from_config(app_name: str, config_type: ConfigType, config_format: ConfigFormat, flags: Dict[str, str]) None[source]
register_defaults()[source]
register_function(data: FunctionData)[source]
register_function_group(data: FunctionGroupData)[source]
register_main(main_function: Callable, main_description: str, app_name: str, version: str)[source]
classmethod rm_config_file(app_name: str, config_type: ConfigType, config_format: ConfigFormat) None[source]
show_help() None[source]
classmethod show_help_for_config(config)[source]
show_help_for_function(name: str, show_help_full: bool = False, show_help_suggest: bool = False) None[source]
write_config(config_type: ConfigType, config_format: ConfigFormat) None[source]
classmethod write_config_file(filename: str, config_format: ConfigFormat) None[source]
pytconf.config.config_arg_parse_and_launch(args=None, launch=True, do_exit=True) None[source]
pytconf.config.get_free_args() List[str][source]
pytconf.config.get_pytconf()[source]
pytconf.config.register_endpoint(description: str, name: str | None = None, configs: List[Config] | None = None, suggest_configs: List[Config] | None = None, group: str = 'default', allow_free_args: bool = False, min_free_args: int | None = None, max_free_args: int | None = None) Callable[[Any], Any][source]
pytconf.config.register_function(name: str, description: str, function: Callable, configs: List[Config] | None = None, suggest_configs: List[Config] | None = None, allow_free_args: bool = False, min_free_args: int | None = None, max_free_args: int | None = None, group: str = 'default')[source]
pytconf.config.register_function_group(name: str, description: str, show_meta: bool, show: bool) None[source]
pytconf.config.register_main(main_description: str, app_name: str, version: str) Callable[[Any], Any][source]
pytconf.config.rm_config_file(app_name: str, config_type: ConfigType, config_format: ConfigFormat) None[source]
pytconf.config.write_config(config_type: ConfigType, config_format: ConfigFormat) None[source]
pytconf.config.write_config_file(filename: str, config_format: ConfigFormat) None[source]

pytconf.convert module

pytconf.convert.convert_bool_to_str(b: bool) str[source]
pytconf.convert.convert_int_or_none_to_str(v: int | None) str[source]
pytconf.convert.convert_int_to_str(i: int) str[source]
pytconf.convert.convert_list_int_to_str(li: List[int]) str[source]
pytconf.convert.convert_list_str_to_str(li: List[str]) str[source]
pytconf.convert.convert_str_or_none_to_str(v: str | None) str[source]
pytconf.convert.convert_str_to_bool(s: str) bool[source]
pytconf.convert.convert_str_to_int(s: str) int[source]
pytconf.convert.convert_str_to_int_default(i: int, s: str) int[source]
pytconf.convert.convert_str_to_int_or_none(s: str) int | None[source]
pytconf.convert.convert_str_to_list_int(s: str) List[int][source]
pytconf.convert.convert_str_to_list_str(s: str) List[str][source]
pytconf.convert.convert_str_to_str(e: str) str[source]
pytconf.convert.convert_str_to_str_or_none(s: str) str | None[source]

pytconf.data module

pytconf.enum_subset module

class pytconf.enum_subset.EnumSubset(enum_type: Enum, list_of_values: List[Enum])[source]

Bases: object

add(enum_value)[source]
delete(enum_value)[source]
classmethod from_enum_all(e)[source]
classmethod from_string(e, s)[source]
has_value(item)[source]
list_of_strings()[source]
to_string()[source]
values()[source]
yield_values()[source]
pytconf.enum_subset.enum_subset_to_str(e: EnumSubset) str[source]
pytconf.enum_subset.g_from_enum_all(e: ExtendedEnum) EnumSubset[source]
pytconf.enum_subset.g_from_string(e: Enum, s: str) EnumSubset[source]

pytconf.errors_collector module

class pytconf.errors_collector.ErrorsCollector[source]

Bases: object

This collector support two types of error. Regular errors and special errors Regular errors are the ones to be printed and carry the error_type = false.

add_error(msg: str) None[source]
get_do_help() bool[source]
get_show_errors()[source]
have_errors() bool[source]
set_do_help() None[source]
set_force_show_errors() None[source]
unset_show_errors() None[source]
yield_errors() Generator[str, None, None][source]

pytconf.extended_enum module

class pytconf.extended_enum.ExtendedEnum(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

classmethod from_string(s: str) Enum[source]
classmethod get_list_of_all_values()[source]
pytconf.extended_enum.enum_int_to_name(i: int, e: Enum) str[source]
pytconf.extended_enum.enum_type_to_list_str(e: Enum) List[str][source]
pytconf.extended_enum.enum_value_to_str(ev: Enum) str[source]
pytconf.extended_enum.str_to_enum_int(s: str, e: Enum) int[source]
pytconf.extended_enum.str_to_enum_value(s, e: Enum) Enum[source]

pytconf.param module

class pytconf.param.Param(help_string='No help for this configuration option', default: ~typing.Any = <pytconf.param.Unique object>, type_name: str | None = None)[source]

Bases: ABC

Parent class of all parameters of configuration

collect()[source]
get_type_name()[source]
more_help() str | None[source]
abstract s2t(s: str) object[source]
s2t_generate_from_default(s: str) object[source]
abstract t2s(t: object) str[source]
class pytconf.param.ParamChoice(help_string='No help for this configuration option', default: str | ~pytconf.param.Unique = <pytconf.param.Unique object>, choice_list: ~typing.List[str] | None = None)[source]

Bases: Param

more_help()[source]
s2t(s: str) Any[source]
t2s(t: Any) str[source]
class pytconf.param.ParamCreator[source]

Bases: object

Static namespace with all the param creation functions.

static create_bool(help_string: str = 'No help for this configuration option', default: bool | ~pytconf.param.Unique = <pytconf.param.Unique object>) bool[source]

Create a bool parameter :param help_string: :param default: :return:

static create_choice(choice_list: ~typing.List[str], help_string: str = 'No help for this configuration option', default: str | ~pytconf.param.Unique = <pytconf.param.Unique object>) str[source]

Create a choice config :param choice_list: :param help_string: :param default: :return:

static create_enum(enum_type: ~enum.Enum, help_string: str = 'No help for this configuration option', default: ~enum.Enum | ~pytconf.param.Unique = <pytconf.param.Unique object>) Enum[source]

Create an enum config :param enum_type: :param help_string: :param default: :return:

static create_enum_subset(enum_type: ~enum.Enum, help_string: str = 'No help for this configuration option', default: ~pytconf.enum_subset.EnumSubset | ~pytconf.param.Unique = <pytconf.param.Unique object>) EnumSubset[source]

Create an enum config :param enum_type: :param help_string: :param default: :return:

static create_existing_bucket(help_string: str = 'No help for this configuration option', default: str | ~pytconf.param.Unique = <pytconf.param.Unique object>) str[source]

Create a bucket name on gcp :param help_string: :param default: :return:

static create_existing_file(help_string: str = 'No help for this configuration option', default: str | ~pytconf.param.Unique = <pytconf.param.Unique object>, suffixes: ~typing.List[str] | None = None) str[source]

Create a new file parameter :param help_string: :param default: :param suffixes: :return:

static create_existing_folder(help_string: str = 'No help for this configuration option', default: str | ~pytconf.param.Unique = <pytconf.param.Unique object>, suffixes: ~typing.List[str] | None = None) str[source]

Create a new folder parameter :param help_string: :param default: :param suffixes: :return:

static create_int(help_string: str = 'No help for this configuration option', default: int | ~pytconf.param.Unique = <pytconf.param.Unique object>) int[source]

Create an int parameter :param help_string: :param default: :return:

static create_int_or_none(help_string: str = 'No help for this configuration option', default: int | None | ~pytconf.param.Unique = <pytconf.param.Unique object>) int | None[source]

Create an int parameter :param help_string: :param default: :return:

static create_list_int(help_string: str = 'No help for this configuration option', default: List[int] = []) List[int][source]

Create a List[int] parameter :param help_string: :param default: :return:

static create_list_str(help_string: str = 'No help for this configuration option', default: List[str] = []) List[str][source]

Create a List[str] parameter :param help_string: :param default: :return:

static create_new_file(help_string: str = 'No help for this configuration option', default: str | ~pytconf.param.Unique = <pytconf.param.Unique object>, suffixes: ~typing.List[str] | None = None) str[source]

Create a new file parameter :param help_string: :param default: :param suffixes: :return:

static create_str(help_string: str = 'No help for this configuration option', default: str | ~pytconf.param.Unique = <pytconf.param.Unique object>) str[source]

Create a string parameter :param help_string: :param default: :return:

static create_str_or_none(help_string: str = 'No help for this configuration option', default: str | None | ~pytconf.param.Unique = <pytconf.param.Unique object>) str | None[source]

Create a string parameter :param help_string: :param default: :return:

class pytconf.param.ParamEnum(enum_type: ~enum.Enum, help_string='No help for this configuration option', default: ~typing.Any = <pytconf.param.Unique object>)[source]

Bases: Param

get_type_name()[source]
more_help()[source]
s2t(s: str) Any[source]
t2s(t: Any) str[source]
class pytconf.param.ParamEnumSubset(help_string='No help for this configuration option', default: ~typing.Any = <pytconf.param.Unique object>, enum_type: ~enum.Enum | None = None)[source]

Bases: Param

get_type_name()[source]
more_help()[source]
s2t(s: str) EnumSubset[source]
s2t_generate_from_default(s: str) EnumSubset | None[source]
t2s(t: Any) str[source]
class pytconf.param.ParamFilename(help_string: str = 'No help for this configuration option', default: ~pytconf.param.Unique | str = <pytconf.param.Unique object>, type_name=None, suffixes: ~typing.List[str] | None = None)[source]

Bases: Param

more_help()[source]
s2t(s)[source]
t2s(t)[source]
class pytconf.param.ParamFunctions(function_s2t: Callable, function_s2t_generate_from_default: Callable, function_t2s: Callable, help_string='No help for this configuration option', default=None, type_name=None)[source]

Bases: Param

Parent class of all parameters of configuration

s2t(s: str) Any[source]
s2t_generate_from_default(s: str) Any[source]
t2s(t: Any) str[source]
class pytconf.param.Unique[source]

Bases: object

pytconf.param_collector module

class pytconf.param_collector.ParamCollector[source]

Bases: object

add_data(item)[source]
clear()[source]
get_item(i)[source]
yield_items()[source]

pytconf.pydoc module

pytconf.pydoc.get_first_line(o, default_val: str) str | None[source]

Get first line for a pydoc string :param o: object which is documented (class or function) :param default_val: value to return if there is no documentation :return: the first line which is not whitespace

pytconf.registry module

class pytconf.registry.Registry[source]

Bases: object

get_config_for_name(name)[source]
get_data_for_name(name)[source]
has_name(name)[source]
register(config, name, data)[source]
yield_configs()[source]
yield_name_data_for_config(config)[source]
yield_names_for_config(config)[source]

pytconf.static module

version which can be consumed from within the module

pytconf.utils module

class pytconf.utils.HtmlGen[source]

Bases: object

pytconf.utils.noun(name: str, num: int) str[source]

This function returns a noun in it’s right for a specific quantity :param name: :param num: :return:

Module contents