cornflakes.decorator package
Subpackages
- cornflakes.decorator.click package
- cornflakes.decorator.dataclasses package
- Subpackages
- Module contents
AnyUrlAnyUrl.check_kwargs()AnyUrl.fragmentAnyUrl.hostnameAnyUrl.keys()AnyUrl.netlocAnyUrl.paramsAnyUrl.passwordAnyUrl.pathAnyUrl.portAnyUrl.queryAnyUrl.query_argsAnyUrl.schemeAnyUrl.tldAnyUrl.to_dict()AnyUrl.to_tuple()AnyUrl.tokenAnyUrl.urlAnyUrl.usernameAnyUrl.validAnyUrl.validate_kwargs()
FieldField.aliasesField.allow_inf_nanField.allow_mutationField.cliField.compareField.constField.decimal_placesField.defaultField.default_factoryField.descriptionField.discriminatorField.excludeField.extraField.geField.gtField.hashField.ignoreField.includeField.initField.kw_onlyField.leField.ltField.max_digitsField.max_itemsField.max_lengthField.metadataField.min_itemsField.min_lengthField.multiple_ofField.nameField.regexField.reprField.titleField.typeField.unique_itemsField.validate()Field.validator
add_slots()check_dataclass_kwargs()config()config_files()config_group()dataclass()dataclass_fields()dc_field_without_default()default()field()fields()is_config()is_group()normalized_class_name()to_dict()to_ini()to_tuple()to_yaml()validate_dataclass_kwargs()
- cornflakes.decorator.datalite package
- Submodules
- cornflakes.decorator.datalite.commons module
- cornflakes.decorator.datalite.constraints module
- cornflakes.decorator.datalite.datalite_decorator module
- cornflakes.decorator.datalite.fetch module
- cornflakes.decorator.datalite.mass_actions module
- cornflakes.decorator.datalite.migrations module
- cornflakes.decorator.datalite.type_mapping module
- Module contents
Submodules
cornflakes.decorator.string_builder module
Module contents
cornflakes decorator module.
|
Function that creates generic click CLI Object. |
|
Config decorator to parse INI files and implement config loader methods to config-classes. |
|
Config decorator with a Subset of configs to parse Ini Files. |
|
Wrapper around built-in dataclasses dataclass. |
|
This function is used instead of exposing Field creation directly. |
|
Config decorator to parse INI files and implement config loader methods to config-classes. |
|
Config decorator with a Subset of configs to parse Ini Files. |
|
Indexer Class. |
|
Prepend a functionality. |
|
Function Decorator that can update all passed arguments (that can be a variable) of function. |
|
- class cornflakes.decorator.Index(start=None, *args, **kwds)
Bases:
intIndexer Class.
- classmethod get_index(name, start=0)[Quellcode]
Get an Index instance with the given name.
- Parameter:
name (str) –
start (int) –
- classmethod group_indexing()[Quellcode]
Set group indexing.
- indices: Dict[str, IndexCounter] = {}
- is_group_indexing: bool = False
- classmethod reset()[Quellcode]
Reset all indices to their initial values.
- cornflakes.decorator.click_cli(STYLE_OPTION='bold cyan', STYLE_ARGUMENT='bold cyan', STYLE_SWITCH='bold green', STYLE_METAVAR='bold yellow', STYLE_METAVAR_APPEND='dim yellow', STYLE_METAVAR_SEPARATOR='dim', STYLE_HEADER_TEXT='', STYLE_FOOTER_TEXT='', STYLE_USAGE='yellow', STYLE_USAGE_COMMAND='bold', STYLE_DEPRECATED='red', STYLE_HELPTEXT_FIRST_LINE='', STYLE_HELPTEXT='dim', STYLE_OPTION_HELP='', STYLE_OPTION_DEFAULT='dim', STYLE_OPTION_ENVVAR='dim yellow', STYLE_REQUIRED_SHORT='red', STYLE_REQUIRED_LONG='dim red', STYLE_OPTIONS_PANEL_BORDER='dim', ALIGN_OPTIONS_PANEL='left', STYLE_OPTIONS_TABLE_SHOW_LINES=False, STYLE_OPTIONS_TABLE_LEADING=0, STYLE_OPTIONS_TABLE_PAD_EDGE=False, STYLE_OPTIONS_TABLE_PADDING=(0, 1), STYLE_OPTIONS_TABLE_SHOW_EDGE=True, STYLE_OPTIONS_TABLE_BOX='', STYLE_OPTIONS_TABLE_ROW_STYLES=None, STYLE_OPTIONS_TABLE_HEADER_STYLE='table.header', STYLE_OPTIONS_TABLE_BORDER_STYLE=None, STYLE_COMMANDS_PANEL_BORDER='dim', ALIGN_COMMANDS_PANEL='left', STYLE_COMMANDS_TABLE_SHOW_LINES=False, STYLE_COMMANDS_TABLE_LEADING=0, STYLE_COMMANDS_TABLE_PAD_EDGE=False, STYLE_COMMANDS_TABLE_PADDING=(0, 1), STYLE_COMMANDS_TABLE_BOX='', STYLE_COMMANDS_TABLE_ROW_STYLES=None, STYLE_COMMANDS_TABLE_BORDER_STYLE=None, STYLE_ERRORS_PANEL_BORDER='red', ALIGN_ERRORS_PANEL='left', STYLE_ERRORS_SUGGESTION='dim', STYLE_ABORTED='red', MAX_WIDTH=None, COLOR_SYSTEM='auto', FORCE_TERMINAL=None, HEADER_TEXT=None, HEADER_LOGO=None, FOOTER_TEXT=None, DEPRECATED_STRING='(Deprecated) ', DEFAULT_STRING='[default: {}]', ENVVAR_STRING='[env var: {}]', REQUIRED_SHORT_STRING='*', REQUIRED_LONG_STRING='[required]', RANGE_STRING=' [{}]', APPEND_METAVARS_HELP_STRING='({})', ARGUMENTS_PANEL_TITLE='Arguments', OPTIONS_PANEL_TITLE='Options', COMMANDS_PANEL_TITLE='Commands', ERRORS_PANEL_TITLE='Error', ERRORS_SUGGESTION=None, ERRORS_EPILOGUE=None, ABORTED_TEXT='Aborted.', SHOW_ARGUMENTS=True, SHOW_METAVARS_COLUMN=True, APPEND_METAVARS_HELP=False, APPEND_METAVARS_REQUIRED=False, GROUP_ARGUMENTS_OPTIONS=False, OPTION_ENVVAR_FIRST=False, USE_RST=False, SHOW_RST_ERRORS=False, USE_MARKDOWN=False, USE_MARKDOWN_EMOJI=True, USE_RICH_MARKUP=False, CODE_THEME='monokai', USE_CLICK_SHORT_HELP=False, VERSION_INFO=False, VERBOSE_OPTION=False, BG_PROCESS_OPTION=False, files=None, sections=None, eval_env=None, allow_empty=False, init_from_default_cache=False, callback=None, config=None, loader=<Loader.DICT: 'from_dict'>, default_log_level=20, as_command=False, *args, **kwargs)
Function that creates generic click CLI Object.
- Parameter:
STYLE_OPTION (str) –
STYLE_ARGUMENT (str) –
STYLE_SWITCH (str) –
STYLE_METAVAR (str) –
STYLE_METAVAR_APPEND (str) –
STYLE_METAVAR_SEPARATOR (str) –
STYLE_HEADER_TEXT (str) –
STYLE_FOOTER_TEXT (str) –
STYLE_USAGE (str) –
STYLE_USAGE_COMMAND (str) –
STYLE_DEPRECATED (str) –
STYLE_HELPTEXT_FIRST_LINE (str) –
STYLE_HELPTEXT (str) –
STYLE_OPTION_HELP (str) –
STYLE_OPTION_DEFAULT (str) –
STYLE_OPTION_ENVVAR (str) –
STYLE_REQUIRED_SHORT (str) –
STYLE_REQUIRED_LONG (str) –
STYLE_OPTIONS_PANEL_BORDER (str) –
ALIGN_OPTIONS_PANEL (str) –
STYLE_OPTIONS_TABLE_SHOW_LINES (bool) –
STYLE_OPTIONS_TABLE_LEADING (int) –
STYLE_OPTIONS_TABLE_PAD_EDGE (bool) –
STYLE_OPTIONS_TABLE_PADDING (Tuple[int, int]) –
STYLE_OPTIONS_TABLE_SHOW_EDGE (bool) –
STYLE_OPTIONS_TABLE_BOX (str) –
STYLE_OPTIONS_TABLE_ROW_STYLES (List[str] | None) –
STYLE_OPTIONS_TABLE_HEADER_STYLE (str) –
STYLE_OPTIONS_TABLE_BORDER_STYLE (str | None) –
STYLE_COMMANDS_PANEL_BORDER (str) –
ALIGN_COMMANDS_PANEL (str) –
STYLE_COMMANDS_TABLE_SHOW_LINES (bool) –
STYLE_COMMANDS_TABLE_LEADING (int) –
STYLE_COMMANDS_TABLE_PAD_EDGE (bool) –
STYLE_COMMANDS_TABLE_PADDING (Tuple[int, int]) –
STYLE_COMMANDS_TABLE_BOX (str) –
STYLE_COMMANDS_TABLE_ROW_STYLES (List[str] | None) –
STYLE_COMMANDS_TABLE_BORDER_STYLE (List[str] | None) –
STYLE_ERRORS_PANEL_BORDER (str) –
ALIGN_ERRORS_PANEL (str) –
STYLE_ERRORS_SUGGESTION (str) –
STYLE_ABORTED (str) –
MAX_WIDTH (int | None) –
COLOR_SYSTEM (Literal['auto', 'standard', '256', 'truecolor', 'windows'] | None) –
FORCE_TERMINAL (bool | None) –
HEADER_TEXT (str | None) –
HEADER_LOGO (str | None) –
FOOTER_TEXT (str | None) –
DEPRECATED_STRING (str) –
DEFAULT_STRING (str) –
ENVVAR_STRING (str) –
REQUIRED_SHORT_STRING (str) –
REQUIRED_LONG_STRING (str) –
RANGE_STRING (str) –
APPEND_METAVARS_HELP_STRING (str) –
ARGUMENTS_PANEL_TITLE (str) –
OPTIONS_PANEL_TITLE (str) –
COMMANDS_PANEL_TITLE (str) –
ERRORS_PANEL_TITLE (str) –
ERRORS_SUGGESTION (str | None) –
ERRORS_EPILOGUE (str | None) –
ABORTED_TEXT (str) –
SHOW_ARGUMENTS (bool) –
SHOW_METAVARS_COLUMN (bool) –
APPEND_METAVARS_HELP (bool) –
APPEND_METAVARS_REQUIRED (bool) –
GROUP_ARGUMENTS_OPTIONS (bool) –
OPTION_ENVVAR_FIRST (bool) –
USE_RST (bool) –
SHOW_RST_ERRORS (bool) –
USE_MARKDOWN (bool) –
USE_MARKDOWN_EMOJI (bool) –
USE_RICH_MARKUP (bool) –
CODE_THEME (str) –
USE_CLICK_SHORT_HELP (bool) –
VERSION_INFO (bool) –
VERBOSE_OPTION (bool) –
BG_PROCESS_OPTION (bool) –
files (List[str] | str | None) –
sections (List[str] | str | None) –
eval_env (bool | None) –
allow_empty (bool | None) –
init_from_default_cache (bool) –
callback (Any | None) –
config (RichConfig | None) –
loader (Loader) –
default_log_level (int) –
as_command (bool) –
- cornflakes.decorator.config(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, **kwargs)
Config decorator to parse INI files and implement config loader methods to config-classes.
- Parameter:
alias_generator (Callable[[str], str] | None) –
ignore_none (bool) –
value_factory (Callable | None) –
init_default_config (bool, optional) –
match_args (bool) –
slots (bool) –
kw_only (bool) –
cls (class) – The class type to create the config dataclass from.
init (bool, optional) – Whether to automatically add an __init__ method to the class. Default is True.
repr (bool, optional) – Whether to automatically add a __repr__ method to the class. Default is True.
eq (bool, optional) – Whether to automatically add an __eq__ method to the class. Default is True.
order (bool, optional) – Whether to automatically add comparison methods (__lt__, __le__, __gt__, __ge__) to the class. Default is False.
unsafe_hash (bool, optional) – Whether to add a __hash__ method to the class. Default is False.
frozen (bool, optional) – Whether to make the generated class immutable. Default is False.
dict_factory (Callable, optional) – A function that returns a dict-like object which will be used as the base of the dataclass object. Default is None.
tuple_factory (Callable, optional) – A function that returns a tuple-like object which will be used as the base of the dataclass object. Default is None.
eval_env (bool, optional) – If set to True, will evaluate environment variables in the config file. Default is False.
validate (bool, optional) – If set to True, will validate the config file upon loading. Default is False.
updatable (bool, optional) – If set to True, the config object can be updated after it’s created. Default is False.
files (Union[List[str], str], optional) – A list or a single string of file path(s) to the default config files.
sections (Union[List[str], str], optional) – A list or a single string of section name(s) in the config file(s).
use_regex (bool, optional) – If set to True, will evaluate all sections in the config file(s) by regex. Default is False.
is_list (Union[bool, int], optional) – If set to True or a positive integer, will load the Config as a list of config class objects. Default is False.
default_loader (Loader, optional) – The default config parser method.
allow_empty (bool, optional) – If set to True, an empty config result will be allowed. Default is False.
chain_configs (bool, optional) – If set to True, multiple config files will be chained into a single config. Default is False.
init_default_config – If set to True, will initialize the default config file(s) upon loading. Default is True.
kwargs (Any) –
- Rückgabe:
If a class is given as config_cls, a new decorated class is returned. If no class is given, the decorator itself is returned with the custom default arguments.
- Rückgabetyp:
Union[Type[Config], Type[ConfigGroup], Type[_T]], Callable[…, Union[Type[Config], Type[ConfigGroup], Type[_T]]]
- cornflakes.decorator.config_group(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, allow_empty=None, chain_configs=False, **kwargs)
Config decorator with a Subset of configs to parse Ini Files.
- Parameter:
ignore_none (bool) –
alias_generator (Callable[[str], str] | None) –
value_factory (Callable | None) –
updatable (bool) –
validate (bool) –
eval_env (bool) –
tuple_factory (Callable | None) –
dict_factory (Callable | None) –
match_args (bool) –
slots (bool) –
kw_only (bool) –
frozen (bool) –
unsafe_hash (bool) –
order (bool) –
eq (bool) –
repr (bool) –
init (bool) –
cls (Type[_T] | None) – Config class
files (List[str] | str | None) – Default config files
allow_empty (bool | None) – Flag that allows empty config result
chain_configs (bool | None) – flag indicating whether to chain files in to single config.
kwargs – Additional args for custom dataclass. (dict_factory, eval_env. …).
- Rückgabe:
wrapped class or the wrapper itself with the custom default arguments if the config class is not
- Rückgabetyp:
Callable[[Type[_T]], Type[ConfigGroup] | Type[CornflakesDataclass] | MappingWrapper[_T]] | Type[ConfigGroup] | Type[CornflakesDataclass] | MappingWrapper[_T]
- cornflakes.decorator.dataclass(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, eval_env=False, validate=False, updatable=False, ignore_none=False, **kwargs)
Wrapper around built-in dataclasses dataclass.
- Parameter:
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) –
eval_env (bool) –
validate (bool) –
updatable (bool) –
ignore_none (bool) –
kwargs (Any) –
- Rückgabetyp:
Callable[[Type[_T]], Type[CornflakesDataclass] | MappingWrapper[_T]] | Type[CornflakesDataclass] | MappingWrapper[_T]
- cornflakes.decorator.field(attr=None, /, *, default=<cornflakes.types._MISSING_TYPE object>, default_factory=<cornflakes.types._MISSING_TYPE object>, init=True, repr=True, hash=None, compare=True, metadata=None, kw_only=<cornflakes.types._MISSING_TYPE object>, validator=<cornflakes.types._MISSING_TYPE object>, aliases=None, ignore=False, cli=True, title=None, description=None, exclude=None, include=None, const=None, gt=None, ge=None, lt=None, le=None, multiple_of=None, allow_inf_nan=True, max_digits=None, decimal_places=None, min_items=None, max_items=None, unique_items=None, min_length=None, max_length=None, allow_mutation=True, regex=None, discriminator=None, no_default=False, **extra)
This function is used instead of exposing Field creation directly.
So that a type checker can be told (via overloads) that this is a function whose type depends on its parameters. This function is used instead of exposing Field creation directly, so that a type checker can be told (via overloads) that this is a function whose type depends on its parameters.
- Parameter:
attr (Field | Any | None) – Attribute name on the class to be used to store the field.
default (_MISSING_TYPE | Any) – Default value for field.
default_factory (_MISSING_TYPE | _WithoutDefault | Callable) – Default factory for field.
init (bool | None) – Field will be included in __init__ method.
repr (bool | None) – Field will be included in __repr__ method.
hash (bool | _MISSING_TYPE | None) – Field will be included in __hash__ method.
compare (bool | None) – Field will be included in __eq__ method.
metadata (Any | None) – Field will be included in metadata.
kw_only (_MISSING_TYPE | bool) – Field will be included in __init__ method as keyword only.
validator (Callable[[str], Any] | _MISSING_TYPE | None) – Validator for field.
aliases (List[str] | str | None) – Aliases for config data (will be used to read from config files).
ignore (bool | None) – Field will be ignored when writing to_ini etc.
cli (bool | None) – Field will be included in cli on option_config.
title (str | None) – Can be any string, used in the schema.
description (str | None) – can be any string, used in the schema.
exclude (List[str] | str | None) – exclude this field while dumping. Takes same values as the
includeandexcludearguments on the.dictmethod.include (List[str] | str | None) – include this field while dumping. Takes same values as the
includeandexcludearguments on the.dictmethod.const (bool | None) – this field is required and must take it’s default value
gt (int | float | None) – only applies to numbers, requires the field to be „greater than“. The schema will have an
exclusiveMinimumvalidation keywordge (int | float | None) – only applies to numbers, requires the field to be „greater than or equal to“. The schema will have a
minimumvalidation keywordlt (int | float | None) – only applies to numbers, requires the field to be „less than“. The schema will have an
exclusiveMaximumvalidation keywordle (int | float | None) – only applies to numbers, requires the field to be „less than or equal to“. The schema will have a
maximumvalidation keywordmultiple_of (int | float | None) – only applies to numbers, requires the field to be „a multiple of“. The schema will have a
multipleOfvalidation keywordallow_inf_nan (bool | None) – only applies to numbers, allows the field to be NaN or infinity (+inf or -inf), which is a valid Python float. Default True, set to False for compatibility with JSON.
max_digits (int | None) – only applies to Decimals, requires the field to have a maximum number of digits within the decimal. It does not include a zero before the decimal point or trailing decimal zeroes.
decimal_places (int | None) – only applies to Decimals, requires the field to have at most a number of decimal places allowed. It does not include trailing decimal zeroes.
min_items (int | None) – only applies to lists, requires the field to have a minimum number of elements. The schema will have a
minItemsvalidation keywordmax_items (int | None) – only applies to lists, requires the field to have a maximum number of elements. The schema will have a
maxItemsvalidation keywordunique_items (bool | None) – only applies to lists, requires the field not to have duplicated elements. The schema will have a
uniqueItemsvalidation keywordmin_length (int | None) – only applies to strings, requires the field to have a minimum length. The schema will have a
minLengthvalidation keywordmax_length (int | None) – only applies to strings, requires the field to have a maximum length. The schema will have a
maxLengthvalidation keywordallow_mutation (bool | None) – a boolean which defaults to True. When False, the field raises a TypeError if the field is assigned on an instance. The BaseModel Config must set validate_assignment to True
regex (str | None) – only applies to strings, requires the field match against a regular expression pattern string. The schema will have a
patternvalidation keyworddiscriminator (str | None) – only useful with a (discriminated a.k.a. tagged) Union of sub models with a common field. The discriminator is the name of this common field to shorten validation and improve generated schema
repr – show this field in the representation
no_default (bool) – if True, the field will not have a default value, even if a default value is specified
extra (Any) – any additional keyword arguments will be added as is to the schema
- Rückgabe:
A dataclass field.
- Verursacht:
ValueError – if both default and default_factory are specified.
- cornflakes.decorator.funcat(func, *f_args, where=FuncatTypes.AFTER, **f_kwargs)
Prepend a functionality.
- Parameter:
where (FuncatTypes) –
- cornflakes.decorator.string_builder(callback=None, *args, **kwargs)
- cornflakes.decorator.wrap_kwargs(wrapped, exclude=None, **overwrites)
Function Decorator that can update all passed arguments (that can be a variable) of function.
- Parameter:
wrapped (Callable) – The original function to be wrapped.
exclude (List[str], optional) – A list of keys to exclude from wrapping.
**overwrites – Keyword arguments that specify default values to overwrite.
- Rückgabe:
A function that wraps the original function.
- Rückgabetyp:
Callable
>>> @wrap_kwargs(wrapped=sum) ... def new_sum(**kwargs): ... return kwargs >>> new_sum([1, 2, 3]) # Output would be 16 because 'start' is overwritten to 10 {'iterable': [1, 2, 3]}