OILS / opy / _regtest / src / opy / callgraph_demo.py View on Github | oilshell.org

55 lines, 31 significant
1#!/usr/bin/python
2from __future__ import print_function
3"""
4callgraph_demo.py
5"""
6
7import sys
8
9from opy import callgraph
10
11_private = '_PRIVATE'
12private = 'PRIVATE'
13
14
15def f():
16 sys.settrace(sys.settrace) # Try passing a type to a type.
17
18
19def h():
20 import dis
21 dis.dis(f)
22
23 from core import util
24 out = []
25 seen = set()
26 #_Walk(util.log, util, out)
27 callgraph._Walk(util.ShowAppVersion, util, seen, out)
28
29 #_Walk(util.log, sys.modules['core.util'], out)
30 print('---')
31 for o in out:
32 print(o)
33
34
35def g(argv):
36 print(dir(sys))
37
38 g()
39
40 print(private)
41 print(_private)
42
43
44def main(argv):
45 callgraph.Walk(g, sys.modules)
46
47 h()
48
49
50if __name__ == '__main__':
51 try:
52 main(sys.argv)
53 except RuntimeError as e:
54 print >>sys.stderr, 'FATAL: %s' % e
55 sys.exit(1)