blob: 7f258d9a7c2da6ceb14ab41bbebd0ff415ce84f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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())
|