Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # find_core_modules.py
- _builtins = []
- _other_modules = []
- _other_modules_attr = []
- def oText(modules):
- sss = '\n' + ' '*10
- spc = '\n' + ' '*16
- def output(s,zzz):
- print s
- for z in zzz:
- print
- print ' ',z
- print
- for module in modules:
- zzz = sub = ''
- try:
- mod = __import__(module)
- sub = dir(mod)
- sub = spc.join(sub)
- doc = mod.__doc__.splitlines()
- doc = sss.join(['']+doc) + '\n'
- tab = ' '*(30-len(module))
- zzz = '{}{}{}{}{}'.format(module, tab, doc, spc, sub)
- except:
- 0
- if module in sys.builtin_module_names:
- zzz = '{}{}{}'.format(module, spc, sub)
- if zzz not in _builtins:
- _builtins.append(zzz)
- else:
- if module not in _other_modules:
- _other_modules.append(module)
- if zzz:
- _other_modules_attr.append(zzz)
- _builtins.sort()
- _other_modules.sort()
- _other_modules_attr.sort()
- output('Built-In Modules:', _builtins)
- output('3rd-Party Modules:', _other_modules)
- output('...', _other_modules_attr)
- import sys, os
- import __builtin__
- print str(len(dir(__builtin__))) + ' built-in functions and variables\n'
- print 'Filepaths Of Modules:'
- modules_in_each_path = []
- for f in sys.path:
- print ' ', f
- if '\\lib\\' in f and '\\Python' in f:
- for root, _, dir_files in os.walk(f):
- for df in dir_files:
- if '.py' in df:
- df,z = df.rsplit('.',1)
- try:
- __import__(df)
- if df not in modules_in_each_path:
- modules_in_each_path.append(df)
- except:
- 0
- print
- search = (sys.builtin_module_names, sys.modules.keys(), dir(__builtin__), modules_in_each_path)
- search = [val for sublist in search for val in sublist]
- oText(search)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement