-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetglobal.py
44 lines (35 loc) · 1.09 KB
/
setglobal.py
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
import sys
from console import console
class Global:
__instance = None
@staticmethod
def get_instance():
if Global.__instance == None:
Global()
return Global.__instance
def __init__(self):
if Global.__instance == None:
Global.__instance = self
self.variables = {}
def add_value(self, key, value):
self.variables[key] = value
def unset(self, key):
try:
if self.variables[key]:
self.add_value(key, None)
except Exception as e:
pass
def get_variables(self):
return self.variables
def show_variables(self):
console.print(" Options (Field = Value)", style="yellow")
print(" -----------------------")
flag = 0
for key, value in self.variables.items():
flag += 1
if flag > 1:
print(" |")
sys.stdout.write(" |_")
sys.stdout.write("%s" % key)
sys.stdout.write(" = %s \n" % (value))
print("")