:py:mod:`wolfgpu.utils` ======================= .. py:module:: wolfgpu.utils .. autoapi-nested-parse:: Author: HECE - University of Liege, Stéphane Champailler, Pierre Archambeau Date: 2024 Copyright (c) 2024 University of Liege. All rights reserved. This script and its content are protected by copyright law. Unauthorized copying or distribution of this file, via any medium, is strictly prohibited. Module Contents --------------- .. py:class:: EveryNSeconds(period: float, trigger_start=True, name: str = '') .. py:method:: has_shot() -> bool Calling this method will clear the has_shot flag. So if you call it twice one after the other, without waiting no more than the period, it will give True one time and False the next time. .. py:function:: add_logging_level(levelName, levelNum, methodName=None) 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 . .. rubric:: 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 .. py:function:: init_global_logging(lvl=logging.INFO) .. py:function:: delete_dir_recursion(p) 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. .. py:function:: nice_timestamp() -> str A nice timestamp which makes sure the day, month and year cannot be mismatched. .. py:data:: PARSE_DURATION_REGEX .. py:function:: parse_duration(time_str) -> datetime.timedelta Parse a time string e.g. (2h13m) into a timedelta object. Modified from virhilo's answer at https://stackoverflow.com/a/4628148/851699 :param time_str: A string identifying a duration. (eg. 2h13m) :return datetime.timedelta: A datetime.timedelta object Taken from https://stackoverflow.com/a/51916936/2030384 .. py:function:: parse_duration_to_seconds(time_str) -> float .. py:function:: seconds_to_duration_str(s: float) .. py:data:: t