From 58ebd3bc0f00c532e97e9a5571471ffab87934ba Mon Sep 17 00:00:00 2001 From: AL-LCL Date: Fri, 19 May 2023 10:39:49 +0200 Subject: GOD-VIEW --- server/helper.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 server/helper.py (limited to 'server/helper.py') diff --git a/server/helper.py b/server/helper.py new file mode 100644 index 0000000..7f258d9 --- /dev/null +++ b/server/helper.py @@ -0,0 +1,57 @@ +''' + General purpose methods that are + commonly used throughout the program. + + Verified: 2021 February 7 + * Follows PEP8 + * Tested Platforms + * Windows 10 +''' + +from server.state import ServerStatic + +import time +import uuid + + +class SafeIP: + + def __init__(self, ip): + self.__safe = ip.replace(':', '_') + self.__pure = ip + + @property + def pure(self): + return self.__pure + + @property + def safe(self): + return self.__safe + + +class ServerHelper: + + @staticmethod + def split(value, seperator=ServerStatic.SEPERATOR, strict=False): + result = [el.strip() for el in value.split(seperator)] + + if strict: + return list(filter(None, result)) + else: + return result + + @staticmethod + def keys(dictionary, keys): + return (dictionary.get(key, False) for key in keys) + + @staticmethod + def filename(ext): + return time.strftime(f'%Y-%m-%d (%H-%M-%S).{ext}') + + @staticmethod + def repeat(times, symbol=' '): + return symbol * times + + @staticmethod + def uuid(): + return str(uuid.uuid4()) -- cgit v1.2.3