baroque.utils package¶
Submodules¶
baroque.utils.configreader module¶
Utility functions for handling with Baroque config datastructure
-
baroque.utils.configreader.read_config_or_default(path_to_file)¶ Loads configuration data from the supplied file or returns the default Baroque configuration.
Parameters: path_to_file (str, optional) – Path to the configuration file.
Returns: The configuration dictionary
Return type: dict
Raises: - (
baroque.exceptions.configuration.ConfigurationNotFoundError - when the supplied filepath is not a regular file
- (
baroque.exceptions.configuration.ConfigurationParseError - when the supplied file cannot be parsed
- (
-
baroque.utils.configreader.readconfig(path_to_file)¶ Loads configuration data from the supplied file.
Parameters: path_to_file (str, optional) – Path to the configuration file.
Returns: The configuration dictionary
Return type: dict
Raises: - (
baroque.exceptions.configuration.ConfigurationNotFoundError - when the supplied filepath is not a regular file
- (
baroque.exceptions.configuration.ConfigurationParseError - when the supplied file cannot be parsed
- (
baroque.utils.importer module¶
Utility functions for handling imports
-
baroque.utils.importer.class_from_dotted_path(dotted_path)¶ Loads a Python class from the supplied Python dot-separated class path. The class must be visible according to the PYTHONPATH variable contents.
Example
"package.subpackage.module.MyClass" --> MyClassParameters: dotted_path (str) – the dot-separated path of the class Returns: a typeobject
baroque.utils.timestamp module¶
-
baroque.utils.timestamp.TIME_FORMAT= '%Y-%m-%dT%H:%M:%SZ'¶ str – ISO-8601 time format used for timestamp printing
-
baroque.utils.timestamp.stringify(timestamp)¶ Turns a timestamp into its ISO-8601 string representation.
Note
refer to the TIME_FORMAT template string
Parameters: timestamp ( datetime.datetime) – the timestamp to be stringifiedReturns: The ISO-8601 time formatted string Return type: str
-
baroque.utils.timestamp.utc_now()¶ Gives the current UTC time-aware timestamp.
Returns: The UTC timestamp Return type: datetime.datetime