-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoggingUtil.py
56 lines (40 loc) · 1.2 KB
/
LoggingUtil.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
45
46
47
48
49
50
51
52
53
54
55
56
import inspect
current_indent = 0
INDENT_SIZE = 2
def reset():
global current_indent
current_indent = 0
def indent():
global current_indent
current_indent += 1
def undent():
global current_indent
current_indent -= 1
def log(*data):
print(f"{current_indent * INDENT_SIZE * ' '}{' '.join([str(x) for x in data])}")
def header(data):
log(f"> {data}")
indent()
def debug_members(obj):
for x, _ in inspect.getmembers(obj):
log(x)
def debug_object_properties(obj):
log(obj)
for prop in obj.properties():
log(f"{prop} = {getattr(obj, prop)}")
def debug_widget(obj):
if obj is None: return
header(f"{obj.get_name()} [{obj.get_class()}]")
props = obj.properties()
# for prop in props:
# print(f"{prop} = {getattr(obj, prop)}")
if "WidgetTree" in props and obj.WidgetTree is not None:
debug_widget(obj.WidgetTree)
if "RootWidget" in props and obj.RootWidget is not None:
debug_widget(obj.RootWidget)
if "Content" in props and obj.Content is not None:
debug_widget(obj.Content)
if "Slots" in props and obj.Slots is not None:
for s in obj.Slots:
debug_widget(s)
undent()