-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.py
36 lines (34 loc) · 1.18 KB
/
util.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
class LogColor():
Default = "\033[0m"
Error = "\033[31;1m"
Warning = "\033[33m"
Info = "\033[34m"
Bold = "\033[1m"
def fixiter(values, make_basic_value=True, skip_null=False):
from interpreter.basic_value import BasicValue
from interpreter.basic_object import BasicObject
result = []
for value in values:
if type(value) in [list, set, tuple]:
result.append(fixiter(value))
else:
if not isinstance(value, BasicValue) and make_basic_value:
result.append(BasicValue(value))
else:
if isinstance(value, BasicObject):
if make_basic_value:
result.append(BasicValue(value.value))
else:
result.append(value.value)
else:
result.append(value)
if not isinstance(result, BasicValue) and make_basic_value:
return BasicValue(result)
else:
if isinstance(value, BasicObject):
if make_basic_value:
return BasicValue(result.value)
else:
return result.value
else:
return result