cornflakes.builder package

Module contents

cornflakes config generation.

generate_config_group_module(source_module)

Module with function to generate automatically config group module.

generate_config_module(title, sources, ...)

Generate a Python module with a single Config class from the provided sources.

generate_enum_module(title, sources, ...[, ...])

Generate Schema Types Enum from datahub module.

cornflakes.builder.generate_config_group_module(source_module, source_config=None, target_module_file=None, class_name=None, loader=Loader.FILE, module_description='Automatically generated Default Config.', class_description='Main config class of the module.', *args, **kwargs)

Module with function to generate automatically config group module.

Parameter:
  • source_module (module | str) –

  • source_config (Dict[str, str | List[str]] | List[str] | str | None) –

  • target_module_file (str | None) –

  • class_name (str | None) –

  • loader (Loader) –

  • module_description (str) –

  • class_description (str) –

cornflakes.builder.generate_config_module(title, sources, target_module_file, cls=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, kw_only=False, slots=False, match_args=True, dict_factory=None, tuple_factory=None, value_factory=None, alias_generator=None, eval_env=False, validate=False, updatable=False, ignore_none=False, files=None, sections=None, use_regex=False, is_list=False, default_loader=None, allow_empty=False, chain_configs=False, init_default_config=True, module_description=None, class_description=None, inherit_from=None, comments=None, to_upper=False, *args, **kwargs)

Generate a Python module with a single Config class from the provided sources.

param title:

The name of the config class to be generated.

type title:

Optional[str]

param sources:

The source data from which to generate the config. Can be a list, dict, module, or the name of a module as a string.

type sources:

Union[str, List[str], Dict[str, Any], ModuleType]

param target_module_file:

The path to the file where the generated module will be written.

type target_module_file:

str

param module_description:

Description of the module to be included at the top of the generated file.

type module_description:

Optional[str]

param class_description:

Description of the config class to be included in the generated file.

type class_description:

Optional[str]

param comments:

Optional comments to be included next to each config member. Can be a list (in which case comments are matched with members by index) or a dict (in which case comments are matched with members by key).

type comments:

Optional[Union[Dict[str, str], List[str]]]

param inherit_from:

Optional list of classes to inherit from.

type inherit_from:

Optional[List[Type[Any]]]

param to_upper:

If True, convert all config members to uppercase.

type to_upper:

bool

param args:

Additional arguments to be passed to the @config decorator.

type args:

Any

param kwargs:

Additional keyword arguments to be passed to the @config decorator.

type kwargs:

Any

raises ValueError:

If the type of the ‚sources‘ parameter is not supported.

Parameter:
  • title (str) –

  • sources (str | List[str] | Dict[str, Any] | module) –

  • target_module_file (str) –

  • cls (Type[_T] | None) –

  • init (bool) –

  • repr (bool) –

  • eq (bool) –

  • order (bool) –

  • unsafe_hash (bool) –

  • frozen (bool) –

  • kw_only (bool) –

  • slots (bool) –

  • match_args (bool) –

  • dict_factory (Callable | None) –

  • tuple_factory (Callable | None) –

  • value_factory (Callable | None) –

  • alias_generator (Callable[[str], str] | None) –

  • eval_env (bool) –

  • validate (bool) –

  • updatable (bool) –

  • ignore_none (bool) –

  • files (List[str] | str | None) –

  • sections (List[str] | str | None) –

  • use_regex (bool | None) –

  • is_list (bool | int | None) –

  • default_loader (Loader | None) –

  • allow_empty (bool | None) –

  • chain_configs (bool | None) –

  • init_default_config (bool | None) –

  • module_description (str | None) –

  • class_description (str | None) –

  • inherit_from (List[Type[Any]] | None) –

  • comments (Dict[str, str] | List[str] | None) –

  • to_upper (bool) –

  • kwargs (Any) –

cornflakes.builder.generate_enum_module(title, sources, target_module_file, module_description=None, class_description=None, comments=None)

Generate Schema Types Enum from datahub module.

Parameter:
  • title (str | None) –

  • sources (str | List[str] | Dict[str, Any] | module) –

  • target_module_file (str) –

  • module_description (str | None) –

  • class_description (str | None) –

  • comments (Dict[str, str] | List[str] | None) –