From cbecb05cdb158b17b02df7acaf992439797d9e60 Mon Sep 17 00:00:00 2001 From: msinn Date: Fri, 26 Apr 2024 11:32:38 +0200 Subject: [PATCH] lib.utils: Removed logging info and changed parameter typing to be compatible with Python 3.9 and under --- dev/sample_plugin/__init__.py | 4 ++-- lib/utils.py | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dev/sample_plugin/__init__.py b/dev/sample_plugin/__init__.py index 1a79b76f4b..0edd07a838 100644 --- a/dev/sample_plugin/__init__.py +++ b/dev/sample_plugin/__init__.py @@ -7,8 +7,8 @@ # https://www.smarthomeNG.de # https://knx-user-forum.de/forum/supportforen/smarthome-py # -# Sample plugin for new plugins to run with SmartHomeNG version 1.8 and -# upwards. +# Sample plugin for new plugins to run with SmartHomeNG version 1.10 +# and up. # # SmartHomeNG is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/utils.py b/lib/utils.py index de31c528d6..07f08d1414 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -291,7 +291,8 @@ def is_timeframe(string: str) -> bool: return False @staticmethod - def to_timeframe(value: str | int) -> int: +# def to_timeframe(value: str | int) -> int: # works for Python 3.10 and above + def to_timeframe(value: str) -> int: # works for Python 3.9 and under """ Converts a timeframe value to milliseconds. See is_timeframe() method. The special value 'now' is supported for the current time. @@ -359,8 +360,10 @@ def is_float(string: str) -> bool: return False @staticmethod - def to_bool(value: str|int|float, default: bool='exception') -> bool: - """ +# def to_bool(value: str|int|float, default: bool='exception') -> bool: # works for Python 3.10 and above + def to_bool(value: str, default: bool = 'exception') -> bool: # works for Python 3.9 and under + + """ Converts a value to boolean. Raises exception if value is a string and can't be converted and if no default value is given