-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpydis.py
More file actions
executable file
·39 lines (26 loc) · 747 Bytes
/
pydis.py
File metadata and controls
executable file
·39 lines (26 loc) · 747 Bytes
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
#!/usr/bin/env python2
# Author: ChengYi
# Mail: chengyi818@foxmail.cn
# created time: Fri 15 Jun 2018 05:10:24 PM CST
import dis
import sys
def is_code_object(code_object):
if type(code_object).__name__ == 'code':
return True
return False
def show_code_object(code_object):
if not is_code_object(code_object):
return
for tmp in code_object.co_consts:
if is_code_object(tmp):
show_code_object(tmp)
print(code_object.co_name)
dis.dis(code_object)
print("---------------------------")
def main():
file_name = sys.argv[len(sys.argv)-1]
s = open(file_name).read()
co = compile(s, file_name, 'exec')
show_code_object(co)
if __name__ == "__main__":
main()