wolfgpu.utils

Module Contents

class wolfgpu.utils.EveryNSeconds(n: float, trigger_start=True)[source]
has_shot()[source]
wolfgpu.utils.add_logging_level(levelName, levelNum, methodName=None)[source]

Adds a new logging level to the logging module and the currently configured logging class. levelName becomes an attribute of the logging module with the value levelNum. methodName becomes a convenience method for both logging itself and the class returned by logging.getLoggerClass() (usually just logging.Logger). If methodName is not specified, levelName.lower() is used.

To avoid accidental clobberings of existing attributes, this method will raise an AttributeError if the level name is already an attribute of the logging module or if the method name is already present .

Example

>>> add_logging_level('TRACE', logging.DEBUG - 5)
>>> logging.getLogger(__name__).setLevel("TRACE")
>>> logging.getLogger(__name__).trace('that worked')
>>> logging.trace('so did this')
>>> logging.TRACE
5
wolfgpu.utils.init_global_logging(lvl=logging.INFO)[source]
wolfgpu.utils.delete_dir_recursion(p)[source]

Delete folder, sub-folders and files.

Taken from: https://stackoverflow.com/questions/70246591/delete-directory-and-all-symlinks-recursively

Use this to remove the content of a directory without removing the directory itself.

wolfgpu.utils.nice_timestamp() str[source]

A nice timestamp which makes sure the day, month and year cannot be mismatched.

wolfgpu.utils.PARSE_DURATION_REGEX[source]
wolfgpu.utils.parse_duration(time_str) datetime.timedelta[source]

Parse a time string e.g. (2h13m) into a timedelta object.

Modified from virhilo’s answer at https://stackoverflow.com/a/4628148/851699

Parameters:

time_str – A string identifying a duration. (eg. 2h13m)

Return datetime.timedelta:

A datetime.timedelta object

Taken from https://stackoverflow.com/a/51916936/2030384

wolfgpu.utils.parse_duration_to_seconds(time_str) float[source]
wolfgpu.utils.seconds_to_duration_str(s: float)[source]
wolfgpu.utils.t[source]