From 68b75a1479f54e421efe277a841b0173e286ebf3 Mon Sep 17 00:00:00 2001 From: David Trattnig <david.trattnig@o94.at> Date: Wed, 1 Apr 2020 21:28:16 +0200 Subject: [PATCH] Green method, fix for timestamp, info formatting. --- modules/base/utils.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/base/utils.py b/modules/base/utils.py index 14d65b31..448f9397 100644 --- a/modules/base/utils.py +++ b/modules/base/utils.py @@ -102,8 +102,8 @@ class EngineUtil: ██╔══██║██║ ██║██╔══██╗██╔══██║ ██╔══╝ ██║╚██╗██║██║ ██║██║██║╚██╗██║██╔══╝ ██║ ██║╚██████╔╝██║ ██║██║ ██║ ███████╗██║ ╚████║╚██████╔╝██║██║ ╚████║███████╗ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝╚══════╝ - v%s | %s - Ready to play! - \n""" % (version, component) + %s v%s - Ready to play! + \n""" % (component, version) @@ -128,7 +128,7 @@ class SimpleUtil: @staticmethod - def timestamp(date_and_time=datetime.datetime.now()): + def timestamp(date_and_time=None): """ Transforms the given `datetime` into a UNIX epoch timestamp. If no parameter is passed, the current timestamp is returned. @@ -139,6 +139,8 @@ class SimpleUtil: Returns: (Integer): timestamp in seconds. """ + if not date_and_time: + date_and_time = datetime.datetime.now() return time.mktime(date_and_time.timetuple()) @@ -164,7 +166,7 @@ class SimpleUtil: """ Creates a red version of the given text. """ - return TerminalColors.Red + text + TerminalColors.ENDC + return TerminalColors.RED.value + text + TerminalColors.ENDC.value @staticmethod @@ -175,6 +177,15 @@ class SimpleUtil: return TerminalColors.PINK.value + text + TerminalColors.ENDC.value + @staticmethod + def green(text): + """ + Creates a red version of the given text. + """ + return TerminalColors.GREEN.value + text + TerminalColors.ENDC.value + + + class TerminalColors(Enum): """ -- GitLab