mooseconfig.py¶
- class MooseConfig(config=None)[source]¶
Bases:
object
Moose configuration class that handles 1) the path to the main moose build, 2) the path to the moose app, and 3) the name of the app to be used to construct the command string. These are stored as a dictionary keyed with ‘main_path’, ‘app_path’ and ‘app_name’. This class can also write and read json files containing the moose config.
- get_config()[source]¶
get_config: returns the config dictionary after checking it is valid.
- Returns:
dict[str
,Path | str]
– dictionary containing the moose config.
- convert_path_to_str(in_config)[source]¶
convert_path_to_str: converts all paths in the config dictionary to strings so that it can be saved to json.
- Parameters:
in_config (
dict[str
,Path | str] | None
) – Dictionary containing the moose config. Defaults to None.- Returns:
dict[str,str] | None
– as input with Paths converted to strings.
- convert_str_to_path(in_config=None)[source]¶
convert_str_to_path: helper function to convert string to Path for readin in json dictionary. Does not check if the paths exist.
- Parameters:
in_config (
dict[str
,Path | str] | None
) – Dictionary containing the moose config. Defaults to None.- Returns:
dict[str
,Path | str] | None
– as in_config but strings to main_path and app_path are converted to Path.
- save_config(config_path)[source]¶
save_config: saves the moose config dictionary as a json file in the specified path.
- Parameters:
config_path (
Path
) – path and file name with extension .json to save the moose config dictionary.- Raises:
MooseConfigError – Parent path to save config file does not exist.
- read_config(config_path)[source]¶
read_config: reads the moose json configuration file at the specified path. Checks if the configuration is valid and raises a MooseConfigError if it is not.
- Parameters:
config_path (
Path
) – path to the json config file containing the- Returns:
Self
– returns a MooseConfig object allowing the config to be initialised by directly loading a json config file.- Raises:
MooseConfigError – MOOSE config file does not exist.