- class pecans.utilities.config.BetterConfig(*args, **kwargs)[source]¶
Extension of
configparser.RawConfigParsercustomized for use with PECANSThis class adds a
section_as_dict()method that allows you to quickly return a section of the parser as a dictionary. It also overrides theconfigparser.RawConfigParser.read()method to parse input values from strings into Python types using the function set as the attribute valuexform.
- exception pecans.utilities.config.ConfigurationError[source]¶
An error that represents something wrong in the PECANS configuration.
This should be raised specifically if there is something wrong with what the user has given in the config file.
- pecans.utilities.config.get_domain_size_from_config(config, all_dims=False)[source]¶
Helper function that reads the domain size (as a tuple) from a configuration object.
- Parameters:
config (
BetterConfig) – the configuration object to read the domain size from.all_dims (bool) – whether to include just non-zero dimensions (False, default) or all dimensions (True)
- Returns:
the shape of the domain, as a tuple with 1, 2, or 3 elements depending if the domain is 1-, 2-, or 3- D.
- Return type:
tuple of int
- pecans.utilities.config.load_config_file(config_file)[source]¶
Reads a configuration file and returns a BetterConfig instance representing it
This function automatically instantiates a
BetterConfiginstance, sets it to parse values into Python literals (including tuples or dicts) :param config_file: the file to read. :type config_file: str or list :return: theBetterConfigobject