Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # pys60_find_core_modules.py
- def z_savedata(data=''): ###ZZZ
- dir_x = u'E:\\'
- folder = u'Python\\'
- filename = 'pys60_core_modules.txt'
- try: os.mkdir(dir_x+folder)
- except: pass
- fullpath = dir_x + folder + filename
- print fullpath
- f=open(fullpath,'w')
- f.write(data)
- f.close
- _builtins = []
- _other_modules = []
- _other_modules_attr = []
- _printout = []
- def oText(modules):
- sss = '\n' + ' '*10
- spc = '\n' + ' '*16
- def output(s,zzz):
- _printout.append( s )
- for z in zzz:
- _printout.append( '\n '+z )
- _printout.append( '' )
- 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 = '%s'*5 % (module, tab, doc, spc, sub)
- except:
- 0
- if module in sys.builtin_module_names:
- zzz = '%s'*3 % (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__
- _printout.append( str(len(dir(__builtin__))) + ' built-in functions and variables\n' )
- _printout.append( 'Filepaths Of Modules:' )
- modules_in_each_path = []
- for f in sys.path:
- _printout.append( ' '+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
- _printout.append( '' )
- 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)
- data = '\n'.join(_printout)
- z_savedata(data)
- print '# pys60_find_core_modules'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement