| 1 |
import sys |
| 2 |
import types |
| 3 |
|
| 4 |
|
| 5 |
from kinds import KINDS |
| 6 |
|
| 7 |
|
| 8 |
def main(argv): |
| 9 |
if len(argv) == 2: |
| 10 |
[_, modname] = argv |
| 11 |
attr = None |
| 12 |
elif len(argv) == 3: |
| 13 |
[_, modname, attr] = argv |
| 14 |
else: |
| 15 |
sys.exit("Wrong number of args") |
| 16 |
__import__(modname) |
| 17 |
obj = sys.modules[modname] |
| 18 |
|
| 19 |
if attr is not None: |
| 20 |
obj = getattr(obj, attr) |
| 21 |
|
| 22 |
for name in dir(obj): |
| 23 |
if attr is None and name.startswith("_"): |
| 24 |
continue |
| 25 |
subobj = getattr(obj, name) |
| 26 |
if subobj is None: |
| 27 |
continue |
| 28 |
if isinstance(subobj, types.FunctionType): |
| 29 |
try: |
| 30 |
subobj() |
| 31 |
except NotImplementedError: |
| 32 |
continue |
| 33 |
except: |
| 34 |
pass |
| 35 |
if isinstance(subobj, types.TypeType): |
| 36 |
kind = KINDS["TYPE"] |
| 37 |
else: |
| 38 |
kind = KINDS["UNKNOWN"] |
| 39 |
print kind, ":", name |
| 40 |
|
| 41 |
if __name__ == "__main__": |
| 42 |
main(sys.argv) |