cowbird.config
Attributes
Exceptions
Generic error during configuration loading. |
|
Config error specific to invalid SINGLE_TOKEN or MULTI_TOKEN tokens. |
|
Config error for invalid service keys. |
|
Config error for invalid resource keys. |
Functions
|
Loads a file path or dictionary as YAML/JSON configuration. |
Loads all configuration files specified by the path (if a directory), a single configuration (if a file) or directly |
|
|
Applies environment variable expansion recursively to all applicable fields of a configuration definition. |
|
Validates the schema of the handlers section found in the config. |
|
Validates the schema of the sync_permissions section found in the config. |
Validates a resource_key and its related info from the config and returns some resource info relevant to the config |
|
|
Validates if both resources of a bidirectional mapping respect validation rules. |
|
Validates if both source and target resource of a unidirectional mapping respect validation rules. |
|
Obtain the different info found in a mapping string from the config. |
|
Returns a tuple of all permissions found in a string. |
|
Validates if mappings in the config have valid resource keys and use tokens properly. |
|
|
|
Validates if all services used in the sync config are actual available services. |
Module Contents
- exception cowbird.config.ConfigError[source]
Bases:
RuntimeError
Generic error during configuration loading.
Initialize self. See help(type(self)) for accurate signature.
- exception cowbird.config.ConfigErrorInvalidTokens[source]
Bases:
ConfigError
Config error specific to invalid SINGLE_TOKEN or MULTI_TOKEN tokens.
Initialize self. See help(type(self)) for accurate signature.
- exception cowbird.config.ConfigErrorInvalidServiceKey[source]
Bases:
ConfigError
Config error for invalid service keys.
Initialize self. See help(type(self)) for accurate signature.
- exception cowbird.config.ConfigErrorInvalidResourceKey[source]
Bases:
ConfigError
Config error for invalid resource keys.
Initialize self. See help(type(self)) for accurate signature.
- cowbird.config._load_config(path_or_dict: str | cowbird.typedefs.ConfigDict, section: str, allow_missing: bool = False) cowbird.typedefs.ConfigDict [source]
Loads a file path or dictionary as YAML/JSON configuration.
- cowbird.config.get_all_configs(path_or_dict: str | cowbird.typedefs.ConfigDict, section: Literal['handlers'], allow_missing: bool = False) List[Dict[str, cowbird.typedefs.HandlerConfig]] [source]
- cowbird.config.get_all_configs(path_or_dict: str | cowbird.typedefs.ConfigDict, section: Literal['sync_permissions'], allow_missing: bool = False) List[cowbird.typedefs.SyncPointConfig]
Loads all configuration files specified by the path (if a directory), a single configuration (if a file) or directly returns the specified dictionary section (if a configuration dictionary).
- Returns:
list of configurations loaded if input was a directory path
list of single configuration if input was a file path
list of single configuration if input was a JSON dict
empty list if none of the other cases where matched
Note
Order of file loading will be resolved by alphabetically sorted filename if specifying a directory path.
- cowbird.config._expand_all(config: cowbird.typedefs.ConfigDict) cowbird.typedefs.ConfigDict [source]
Applies environment variable expansion recursively to all applicable fields of a configuration definition.
- cowbird.config.validate_handlers_config_schema(handlers_cfg: Dict[str, cowbird.typedefs.HandlerConfig]) None [source]
Validates the schema of the handlers section found in the config.
- cowbird.config.validate_sync_perm_config_schema(sync_cfg: cowbird.typedefs.SyncPointConfig) None [source]
Validates the schema of the sync_permissions section found in the config.
- cowbird.config.validate_and_get_resource_info(res_key: str, segments: List[cowbird.typedefs.ConfigSegment]) cowbird.typedefs.ConfigResTokenInfo [source]
Validates a resource_key and its related info from the config and returns some resource info relevant to the config mapping validation.
Returned info contains the following: - if the resource uses a MULTI_TOKEN in its resource_path - the list of named tokens found in the resource_path
- cowbird.config.validate_bidirectional_mapping(mapping: str, res_info: Dict[str, cowbird.typedefs.ConfigResTokenInfo], res_key1: str, res_key2: str) None [source]
Validates if both resources of a bidirectional mapping respect validation rules.
Both should either use MULTI_TOKEN or not use it and both should use exactly the same named tokens.
- cowbird.config.validate_unidirectional_mapping(mapping: str, src_info: cowbird.typedefs.ConfigResTokenInfo, tgt_info: cowbird.typedefs.ConfigResTokenInfo) None [source]
Validates if both source and target resource of a unidirectional mapping respect validation rules.
Source resource should use MULTI_TOKEN if target uses it, and source resource should include all named tokens found in the target resource.
- cowbird.config.get_mapping_info(mapping: str) Tuple[str | Any, Ellipsis] [source]
Obtain the different info found in a mapping string from the config.
Returns the following matching groups : (res_key1, permission1, direction, res_key2, permission2)
- cowbird.config.get_permissions_from_str(permissions: str) List[str] [source]
Returns a tuple of all permissions found in a string.
Used for permission strings found in the config, which can either be a single permission or a list of permissions.