-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_namespace_.py
63 lines (43 loc) · 1.45 KB
/
_namespace_.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
57
58
59
60
61
62
63
# Copyright (c) 2024.
# Creative Commons 4 for original code
# GPL3 for rewrite
import sys
import pprint
from oewn_core import wordnet as core
from oewn_xml import wordnet_xml as xml
def debug_module_namespace(name):
m = __import__(name)
print(f"\n=== {m} module attributes ===")
pprint.pprint(dir(m))
def debug_core_module_namespace():
print("\n=== core module attributes ===")
pprint.pprint(dir(core))
def debug_xml_module_namespace():
print("\n=== xml module attributes ===")
pprint.pprint(dir(xml))
def debug_current_module_namespace():
print("=== Local namespace ===")
pprint.pprint(locals())
print("\n=== Global namespace ===")
pprint.pprint(globals())
def debug_current_module_search_path():
print("\n=== Python module search path ===")
pprint.pprint(sys.path)
def debug_loaded_modules():
print("\n=== Currently loaded modules ===")
pprint.pprint(sys.modules)
def debug_namespace():
# 1. Print current module's namespace
debug_current_module_namespace()
# 2. Check module search path
debug_current_module_search_path()
# 3. List loaded modules
debug_loaded_modules()
# 4. Inspect specific module attributes
debug_core_module_namespace()
debug_xml_module_namespace()
# 4b. Inspect specific module attributes
debug_module_namespace("oewn_core.wordnet")
debug_module_namespace("oewn_xml.wordnet_xml")
if __name__ == "__main__":
debug_namespace()