| 1 | #!/usr/bin/python
|
| 2 | from __future__ import print_function
|
| 3 | """
|
| 4 | callgraph_demo.py
|
| 5 | """
|
| 6 |
|
| 7 | import sys
|
| 8 |
|
| 9 | from opy import callgraph
|
| 10 |
|
| 11 | _private = '_PRIVATE'
|
| 12 | private = 'PRIVATE'
|
| 13 |
|
| 14 |
|
| 15 | def f():
|
| 16 | sys.settrace(sys.settrace) # Try passing a type to a type.
|
| 17 |
|
| 18 |
|
| 19 | def 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 |
|
| 35 | def g(argv):
|
| 36 | print(dir(sys))
|
| 37 |
|
| 38 | g()
|
| 39 |
|
| 40 | print(private)
|
| 41 | print(_private)
|
| 42 |
|
| 43 |
|
| 44 | def main(argv):
|
| 45 | callgraph.Walk(g, sys.modules)
|
| 46 |
|
| 47 | h()
|
| 48 |
|
| 49 |
|
| 50 | if __name__ == '__main__':
|
| 51 | try:
|
| 52 | main(sys.argv)
|
| 53 | except RuntimeError as e:
|
| 54 | print >>sys.stderr, 'FATAL: %s' % e
|
| 55 | sys.exit(1)
|