[Python-checkins] CVS: python/nondist/sandbox/help textdoc.py,1.2,1.3

Ka-Ping Yee python-dev@python.org
Sun, 14 Jan 2001 13:55:24 -0800


Update of /cvsroot/python/python/nondist/sandbox/help
In directory usw-pr-cvs1:/tmp/cvs-serv18159

Modified Files:
	textdoc.py 
Log Message:
Show package contents.


Index: textdoc.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/help/textdoc.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** textdoc.py	2001/01/14 11:49:50	1.2
--- textdoc.py	2001/01/14 21:55:22	1.3
***************
*** 3,7 ****
  __version__ = 'Ka-Ping Yee <ping@lfw.org>, 10 Jan 2001'
  
! import sys, types, inspect
  from string import join, split, strip, rstrip
  
--- 3,7 ----
  __version__ = 'Ka-Ping Yee <ping@lfw.org>, 10 Jan 2001'
  
! import sys, os, string, types, inspect
  from string import join, split, strip, rstrip
  
***************
*** 101,104 ****
--- 101,121 ----
          if key[:1] != '_':
              constants.append((key, value))
+ 
+     if hasattr(object, '__path__'):
+         modpkgs = []
+         for file in os.listdir(object.__path__[0]):
+             if file[:1] != '_':
+                 path = os.path.join(object.__path__[0], file)
+                 if file[-3:] == '.py' and file[:-3] not in modpkgs:
+                     modpkgs.append(file[:-3])
+                 elif file[-4:] == '.pyc' and file[:-4] not in modpkgs:
+                     modpkgs.append(file[:-4])
+                 elif os.path.isdir(path):
+                     init = os.path.join(path, '__init__.py')
+                     initc = os.path.join(path, '__init__.pyc')
+                     if os.path.isfile(init) or os.path.isfile(initc):
+                         modpkgs.append(file + ' (package)')
+         modpkgs.sort()
+         results.append(section('PACKAGE CONTENTS', string.join(modpkgs, '\n')))
  
      if classes: