SHARE
TWEET

# pys60_find_core_modules.py

here2share Apr 11th, 2018 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # pys60_find_core_modules.py
  2.  
  3. def z_savedata(data=''): ###ZZZ
  4.     dir_x = u'E:\\'
  5.     folder = u'Python\\'
  6.     filename = 'pys60_core_modules.txt'
  7.     try: os.mkdir(dir_x+folder)
  8.     except: pass
  9.     fullpath = dir_x + folder + filename
  10.  
  11.     print fullpath
  12.    
  13.     f=open(fullpath,'w')
  14.     f.write(data)
  15.     f.close
  16.  
  17. _builtins = []
  18. _other_modules = []
  19. _other_modules_attr = []
  20. _printout = []
  21.  
  22. def oText(modules):
  23.     sss = '\n' + ' '*10
  24.     spc = '\n' + ' '*16
  25.    
  26.     def output(s,zzz):
  27.         _printout.append( s )
  28.         for z in zzz:
  29.             _printout.append( '\n   '+z )
  30.         _printout.append( '' )
  31.    
  32.     for module in modules:
  33.         zzz = sub = ''
  34.         try:
  35.             mod = __import__(module)
  36.             sub = dir(mod)
  37.             sub = spc.join(sub)
  38.             doc = mod.__doc__.splitlines()
  39.             doc = sss.join(['']+doc) + '\n'
  40.             tab = ' '*(30-len(module))
  41.             zzz = '%s'*5 % (module, tab, doc, spc, sub)
  42.         except:
  43.             0
  44.         if module in sys.builtin_module_names:
  45.             zzz = '%s'*3 % (module, spc, sub)
  46.             if zzz not in _builtins:
  47.                 _builtins.append(zzz)
  48.         else:
  49.             if module not in _other_modules:
  50.                 _other_modules.append(module)
  51.                 if zzz:
  52.                     _other_modules_attr.append(zzz)
  53.                
  54.     _builtins.sort()
  55.     _other_modules.sort()
  56.     _other_modules_attr.sort()
  57.    
  58.     output('Built-In Modules:', _builtins)
  59.     output('3rd-Party Modules:', _other_modules)
  60.     output('...', _other_modules_attr)
  61.  
  62. import sys, os
  63. import __builtin__
  64.  
  65. _printout.append( str(len(dir(__builtin__))) + ' built-in functions and variables\n' )
  66.  
  67. _printout.append( 'Filepaths Of Modules:' )
  68. modules_in_each_path = []
  69. for f in sys.path:
  70.     _printout.append(  '   '+f )
  71.     if '\\lib\\' in f and '\\Python' in f:
  72.         for root, _, dir_files in os.walk(f):
  73.             for df in dir_files:
  74.                 if '.py' in df:
  75.                     df,z = df.rsplit('.',1)
  76.                     try:
  77.                         __import__(df)
  78.                         if df not in modules_in_each_path:
  79.                             modules_in_each_path.append(df)
  80.                     except:
  81.                         0
  82. _printout.append( '' )
  83.  
  84. search = (sys.builtin_module_names, sys.modules.keys(), dir(__builtin__), modules_in_each_path)
  85. search = [val for sublist in search for val in sublist]
  86.  
  87. oText(search)
  88.  
  89. data = '\n'.join(_printout)
  90.  
  91. z_savedata(data)
  92.  
  93. print '# pys60_find_core_modules'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top