gws.config.parser¶
Configuration parser: read configuration files and validate them against the specs.
Source code: gws.config.parser
Module Contents¶
- gws.config.parser.CONFIG_PATH_PATTERN = '\\.(py|json|yaml|yml|cx)$'¶
- gws.config.parser.parse_app_dict(dct: dict | gws.Data, path: str, ctx: gws.ConfigContext) gws.Config | None¶
Validate an application configuration dict.
Works like
parse_app_from_path.- Parameters:
dct – Application configuration dict or
gws.Dataobject.path – Path to the configuration file, for error reporting.
ctx – Configuration context. Errors are added to it.
- Returns:
The parsed application configuration, or
Noneif it could not be parsed.
- gws.config.parser.parse_app_from_path(path: str, ctx: gws.ConfigContext) gws.Config | None¶
Read and validate the application configuration file.
Sets the server time zone, then parses the application config and all projects (inline
projects,projectPathsand files inprojectDirs).- Parameters:
path – Path to the application configuration file.
ctx – Configuration context. Errors are added to it.
- Returns:
The parsed application configuration, or
Noneif it could not be parsed.
- gws.config.parser.parse_dict(dct: dict | gws.Data, path: str, as_type: str, ctx: gws.ConfigContext) gws.Config | None¶
Validate a configuration dict as a given type.
- Parameters:
dct – Configuration dict or
gws.Dataobject.path – Path to the configuration file, for error reporting.
as_type – Type of the configuration, e.g.
gws.ext.config.layer.ctx – Configuration context. Errors are added to it.
- Returns:
The parsed configuration, or
Noneif there were errors.
- gws.config.parser.parse_from_path(path: str, as_type: str, ctx: gws.ConfigContext) gws.Config | None¶
Read a configuration file and validate it as a given type.
- Parameters:
path – Path to the configuration file.
as_type – Type of the configuration, e.g.
gws.base.application.core.Config.ctx – Configuration context. Errors are added to it.
- Returns:
The parsed configuration, or
Noneif there were errors.
- gws.config.parser.read_from_path(path: str, ctx: gws.ConfigContext) dict | None¶
Read a configuration file into a dict, without validating it.
The format is determined by the file extension.
- Parameters:
path – Path to the configuration file.
ctx – Configuration context. Errors are added to it.
- Returns:
The configuration dict, or
Noneif the file could not be read or does not contain a dict.