[Python-checkins] CVS: python/nondist/sandbox/help htmldoc.py,1.4,1.5 pydoc.py,1.2,1.3

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


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

Modified Files:
	htmldoc.py pydoc.py 
Log Message:
Grey out modules and packages that are shadowed by things earlier in sys.path.


Index: htmldoc.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/help/htmldoc.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** htmldoc.py	2001/01/14 21:48:24	1.4
--- htmldoc.py	2001/01/14 22:18:44	1.5
***************
*** 107,111 ****
      return name
  
! def modpkglink((name, ispackage, path)):
      if path:
          url = '%s.%s.html' % (path, name)
--- 107,113 ----
      return name
  
! def modpkglink((name, path, ispackage, shadowed)):
!     if shadowed:
!         return '<font color="#808080">%s</font>' % name
      if path:
          url = '%s.%s.html' % (path, name)
***************
*** 233,240 ****
                  path = os.path.join(object.__path__[0], file)
                  if file[-3:] == '.py' and file[:-3] not in modnames:
!                     modpkgs.append((file[:-3], 0, name))
                      modnames.append(file[:-3])
                  elif file[-4:] == '.pyc' and file[:-4] not in modnames:
!                     modpkgs.append((file[:-4], 0, name))
                      modnames.append(file[:-4])
                  elif os.path.isdir(path):
--- 235,242 ----
                  path = os.path.join(object.__path__[0], file)
                  if file[-3:] == '.py' and file[:-3] not in modnames:
!                     modpkgs.append((file[:-3], 0, name, 0))
                      modnames.append(file[:-3])
                  elif file[-4:] == '.pyc' and file[:-4] not in modnames:
!                     modpkgs.append((file[:-4], 0, name, 0))
                      modnames.append(file[:-4])
                  elif os.path.isdir(path):
***************
*** 242,246 ****
                      initc = os.path.join(path, '__init__.pyc')
                      if os.path.isfile(init) or os.path.isfile(initc):
!                         modpkgs.append((file, 1, name))
          modpkgs.sort()
          contents = multicolumn(modpkgs, modpkglink)
--- 244,248 ----
                      initc = os.path.join(path, '__init__.pyc')
                      if os.path.isfile(init) or os.path.isfile(initc):
!                         modpkgs.append((file, 1, name, 0))
          modpkgs.sort()
          contents = multicolumn(modpkgs, modpkglink)
***************
*** 351,376 ****
      return serialize(results)
  
! def index(dir):
      modpkgs = []
!     modnames = []
!     for file in os.listdir(dir):
!         if file[:1] != '_':
!             path = os.path.join(dir, file)
!             if os.path.isfile(path): 
!                 if file[-3:] == '.py' and file[:-3] not in modnames:
!                     modpkgs.append((file[:-3], 0, ''))
!                     modnames.append(file[:-3])
!                 elif file[-4:] == '.pyc' and file[:-4] not in modnames:
!                     modpkgs.append((file[:-4], 0, ''))
!                     modnames.append(file[:-4])
!                 elif file[-11:] == 'module.so':
!                     modpkgs.append((file[:-11], 0, ''))
!                 elif file[-13:] == 'module.so.1':
!                     modpkgs.append((file[:-13], 0, ''))
!             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, 1, ''))
  
      modpkgs.sort()
--- 353,387 ----
      return serialize(results)
  
! def index(dir, shadowed=None):
      modpkgs = []
!     if shadowed is None: shadowed = {}
!     seen = {}
!     files = os.listdir(dir)
! 
!     def found(name, ispackage, modpkgs=modpkgs, shadowed=shadowed, seen=seen):
!         if not seen.has_key(name):
!             modpkgs.append((name, '', ispackage, shadowed.has_key(name)))
!             seen[name] = 1
!             shadowed[name] = 1
! 
!     # Package spam/__init__.py takes precedence over module spam.py.
!     for file in files:
!         path = os.path.join(dir, file)
!         if 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):
!                 found(file, 1)
!     for file in files:
!         path = os.path.join(dir, file)
!         if file[:1] != '_' and os.path.isfile(path): 
!             if file[-3:] == '.py':
!                 found(file[:-3], 0)
!             elif file[-4:] == '.pyc':
!                 found(file[:-4], 0)
!             elif file[-11:] == 'module.so':
!                 found(file[:-11], 0)
!             elif file[-13:] == 'module.so.1':
!                 found(file[:-13], 0)
  
      modpkgs.sort()

Index: pydoc.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/help/pydoc.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** pydoc.py	2001/01/14 21:48:12	1.2
--- pydoc.py	2001/01/14 22:18:44	1.3
***************
*** 295,299 ****
                  contents.append('<p>Built-in modules: ')
                  contents.append(string.join(builtins, ', '))
!                 contents.extend(map(htmldoc.index, sys.path))
                  contents = htmldoc.serialize(contents)
                  self.send_document('Index of Modules', contents)
--- 295,301 ----
                  contents.append('<p>Built-in modules: ')
                  contents.append(string.join(builtins, ', '))
!                 seen = {}
!                 for dir in sys.path:
!                     contents.append(htmldoc.index(dir, seen))
                  contents = htmldoc.serialize(contents)
                  self.send_document('Index of Modules', contents)