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

Ka-Ping Yee python-dev@python.org
Sun, 14 Jan 2001 03:40:40 -0800


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

Modified Files:
	htmldoc.py 
Log Message:
Display module constants 


Index: htmldoc.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/help/htmldoc.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** htmldoc.py	2001/01/14 02:27:10	1.1
--- htmldoc.py	2001/01/14 11:40:38	1.2
***************
*** 4,8 ****
  __version__ = 'Ka-Ping Yee <ping@lfw.org>, 29 May 2000'
  
! import sys, os, re, inspect
  from string import join, replace, expandtabs, rstrip
  
--- 4,8 ----
  __version__ = 'Ka-Ping Yee <ping@lfw.org>, 29 May 2000'
  
! import sys, os, re, types, inspect
  from string import join, replace, expandtabs, rstrip
  
***************
*** 179,182 ****
--- 179,190 ----
      modules = map(cadr, inspect.getmembers(object, inspect.ismodule))
  
+     constants = []
+     for key, value in inspect.getmembers(object):
+         if key[:1] != '_' and type(value) in [types.FloatType,
+             types.IntType, types.ListType, types.LongType,
+             types.StringType, types.TupleType, types.TypeType,
+             types.UnicodeType]:
+             constants.append((key, value))
+ 
      classes, cdict = [], {}
      for key, value in inspect.getmembers(object, inspect.isclass):
***************
*** 222,225 ****
--- 230,242 ----
          results.append(section('<big><strong>Functions</strong></big>',
                                 '#ffffff', '#eeaa77', contents))
+ 
+     if constants:
+         contents = []
+         for key, value in constants:
+             contents.append('<br><strong>%s</strong> = %s' %
+                             (key, htmlrepr(value)))
+         results.append(section('<big><strong>Constants</strong></big>',
+                                '#ffffff', '#55aa55', contents))
+ 
      return results