pyfrag_plotter.config package#
Submodules#
pyfrag_plotter.config.config_handler module#
Module that contains the functions for initializing the config file and reading the config file. This module should be imported by any module that needs to read the config file.
- class pyfrag_plotter.config.config_handler.Config(config_parser)[source]#
Bases:
objectAn interface for the config file.
This class overloads the get method of the ConfigParser class to ensure that the correct type is returned.
- config_parser#
The ConfigParser instance that contains the configuration data.
- Type:
ConfigParser
- property content: Dict[str, Dict[str, Any]]#
Gets a dictionary containing the content of the config file.
- Returns:
A dictionary containing the content of the config file.
- Return type:
Dict[str, Dict[str, Any]]
- get(section: str, option: str) Any[source]#
Gets the value of the specified option in the specified section.
This method returns the value with the correct type.
- Parameters:
section (str) – The name of the section that contains the option.
option (str) – The name of the option to get.
- Returns:
The value of the specified option in the specified section.
- Return type:
ret_variable (Any)
- Raises:
ValueError – If the specified option is not a valid option.
ValueError – If the specified section is not a valid section.
- overwrite_config(config_parser: ConfigParser)[source]#
Overwrites the current config parser with a new config parser. This is used to overwrite the default config parser with a user-specified config parser with the
pyfrag_plotter.initialize_pyfrag_plotter()function.
- property sections: List[str]#
Gets a list of the sections in the config file.
- Returns:
A list of the sections in the config file.
- Return type:
List[str]
- validate_config()[source]#
- Validates all available config keys. It checks whether:
the user specified keys are valid keys (valid keys are specified in the config_key_to_function_mapping dictionary)
the user specified keys have the correct values
- Raises:
PyFragConfigValidationError (PyFragConfigValidationError) – If the config key is invalid.
Note: it uses the
pyfrag_plotter.config_handler.validate_config()function from the validate module.
pyfrag_plotter.config.validate module#
Module for validating the inputs of the config file
- pyfrag_plotter.config.validate.validate_config_key(key: str, value: Any, validation_keys: Sequence[str]) None[source]#
Validates a configuration key-value pair against a list of valid keys.
- Parameters:
key (str) – The key to validate.
value (Any) – The value to validate.
validation_keys (Sequence[str]) – A list of valid keys.
- Returns:
None