Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # modules_plus.py
- import os, sys, imp, inspect
- print '\nSeaching for modules, this might take a short while...\n\n'
- try:
- import distutils.sysconfig
- std_lib = distutils.sysconfig.get_python_lib(standard_lib=True)
- except: std_lib=0
- t = []
- if std_lib:
- for top, dirs, files in os.walk(std_lib):
- for fn in files:
- x='.'.join(fn.split('.')[:-1])
- try:
- if x not in t and not x[0].isdigit():
- t.append(x)
- except: pass
- def SaveText(txt, filename = 'demo', target = 'tmp\\', folder = 'python\\', dir = u'E:\\'):
- try:
- os.mkdir(dir+folder+target)
- print "\n\nNew Folder Has Been Added..."
- except: pass
- saveas = dir+folder+target+filename+'.txt'
- f = open(saveas,"w")
- f.write(txt)
- f.close()
- print '\n\nSaved As...\n', saveas
- #
- def B(zzz):
- for z in zzz:
- if z not in t:
- t.append(z)
- B(dir('keyword'))
- B(dir('import'))
- B(dir('modules package'))
- B(dir(__builtins__))
- B(sys.builtin_module_names)
- B(sys.modules)
- B(sys.modules.keys())
- try: B(dir(__package__))
- except: pass
- m = []
- v = []
- from pkgutil import iter_modules
- for z in iter_modules():
- z=str(z)
- if not v: v = z.split()[3]
- try:
- if v not in z:
- x = z.split()[-2][1:-2]
- if x not in t+m: m.append(x)
- except: pass
- m.sort()
- t.sort()
- ttt = []
- skip = ['antigravity','test','idle']
- print
- for z in t:
- try:
- imp.find_module(z)
- ttt.append(z)
- if z not in skip:
- mods = dir(__import__(z))
- if '_main_' in z:
- mods = ['*** Current Attributes ***']
- for mod in mods:
- ttt.append((' +++ '+mod))
- try:
- x = inspect.getmoduleinfo(mod)
- if x: ttt.append(' --- '+x)
- except: pass
- else:
- print
- except: pass
- txt = '\n'.join(ttt+m)
- print
- print
- print txt
- print
- print len(ttt+m)
- try:
- SaveText(txt,'sys_modules')
- except: print "\n\nWas Unable To Save That Data"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement