[Python-checkins] CVS: python/dist/src/Lib pydoc.py,1.11,1.12

Ka-Ping Yee ping@users.sourceforge.net
Thu, 01 Mar 2001 18:45:10 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv16004

Modified Files:
	pydoc.py 
Log Message:
Clean up the handling of getsourcefile/getabsfile.
Remove __main__ from the index of built-in modules.
Miscellaneous compatibility fixes.


Index: pydoc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** pydoc.py	2001/03/02 01:19:14	1.11
--- pydoc.py	2001/03/02 02:45:08	1.12
***************
*** 63,67 ****
                  line = file.readline()
                  if not line: break
!             result = split(line, '"""')[0]
          else: result = None
          file.close()
--- 63,67 ----
                  line = file.readline()
                  if not line: break
!             result = strip(split(line, '"""')[0])
          else: result = None
          file.close()
***************
*** 87,91 ****
          try: result = inspect.getcomments(object)
          except: pass
!     return result and rstrip(result) or ''
  
  def classname(object, modname):
--- 87,91 ----
          try: result = inspect.getcomments(object)
          except: pass
!     return result and re.sub('^ *\n', '', rstrip(result)) or ''
  
  def classname(object, modname):
***************
*** 394,400 ****
          head = '<big><big><strong>%s</strong></big></big>' % linkedname
          try:
!             path = os.path.abspath(inspect.getfile(object))
!             sourcepath = os.path.abspath(inspect.getsourcefile(object))
!             if os.path.isfile(sourcepath): path = sourcepath
              filelink = '<a href="file:%s">%s</a>' % (path, path)
          except TypeError:
--- 394,398 ----
          head = '<big><big><strong>%s</strong></big></big>' % linkedname
          try:
!             path = inspect.getabsfile(object)
              filelink = '<a href="file:%s">%s</a>' % (path, path)
          except TypeError:
***************
*** 676,682 ****
              lines = lines[2:]
          result = result + self.section('NAME', name)
!         try: file = inspect.getfile(object) # XXX or getsourcefile?
!         except TypeError: file = None
!         result = result + self.section('FILE', file or '(built-in)')
          if lines:
              result = result + self.section('DESCRIPTION', join(lines, '\n'))
--- 674,680 ----
              lines = lines[2:]
          result = result + self.section('NAME', name)
!         try: file = inspect.getabsfile(object)
!         except TypeError: file = '(built-in)'
!         result = result + self.section('FILE', file)
          if lines:
              result = result + self.section('DESCRIPTION', join(lines, '\n'))
***************
*** 1050,1057 ****
  
          for modname in sys.builtin_module_names:
!             seen[modname] = 1
!             desc = split(__import__(modname).__doc__ or '', '\n')[0]
!             if find(lower(modname + ' - ' + desc), lower(key)) >= 0:
!                 callback(None, modname, desc)
  
          while not self.quit:
--- 1048,1056 ----
  
          for modname in sys.builtin_module_names:
!             if modname != '__main__':
!                 seen[modname] = 1
!                 desc = split(__import__(modname).__doc__ or '', '\n')[0]
!                 if find(lower(modname + ' - ' + desc), lower(key)) >= 0:
!                     callback(None, modname, desc)
  
          while not self.quit:
***************
*** 1125,1132 ****
  '<big><big><strong>Python: Index of Modules</strong></big></big>',
  '#ffffff', '#7799ee')
!                 builtins = []
!                 for name in sys.builtin_module_names:
!                     builtins.append('<a href="%s.html">%s</a>' % (name, name))
!                 indices = ['<p>Built-in modules: ' + join(builtins, ', ')]
                  seen = {}
                  for dir in pathdirs():
--- 1124,1134 ----
  '<big><big><strong>Python: Index of Modules</strong></big></big>',
  '#ffffff', '#7799ee')
!                 def bltinlink(name):
!                     return '<a href="%s.html">%s</a>' % (name, name)
!                 names = filter(lambda x: x != '__main__', sys.builtin_module_names)
!                 contents = html.multicolumn(names, bltinlink)
!                 indices = ['<p>' + html.bigsection(
!                     'Built-in Modules', '#ffffff', '#ee77aa', contents)]
! 
                  seen = {}
                  for dir in pathdirs():
***************
*** 1207,1212 ****
              self.search_ent.focus_set()
  
!             self.result_lst = Tkinter.Listbox(window, 
!                 font=('helvetica', 8), height=6)
              self.result_lst.bind('<Button-1>', self.select)
              self.result_lst.bind('<Double-Button-1>', self.goto)
--- 1209,1214 ----
              self.search_ent.focus_set()
  
!             font = ('helvetica', sys.platform in ['win32', 'win', 'nt'] and 8 or 10)
!             self.result_lst = Tkinter.Listbox(window, font=font, height=6)
              self.result_lst.bind('<Button-1>', self.select)
              self.result_lst.bind('<Double-Button-1>', self.goto)
***************
*** 1245,1251 ****
              self.quit_btn.config(state='normal')
  
!         def open(self, event=None):
!             import webbrowser
!             webbrowser.open(self.server.url)
  
          def quit(self, event=None):
--- 1247,1266 ----
              self.quit_btn.config(state='normal')
  
!         def open(self, event=None, url=None):
!             url = url or self.server.url
!             try:
!                 import webbrowser
!                 webbrowser.open(url)
!             except ImportError: # pre-webbrowser.py compatibility
!                 if sys.platform in ['win', 'win32', 'nt']:
!                     os.system('start "%s"' % url)
!                 elif sys.platform == 'mac':
!                     try:
!                         import ic
!                         ic.launchurl(url)
!                     except ImportError: pass
!                 else:
!                     rc = os.system('netscape -remote "openURL(%s)" &' % url)
!                     if rc: os.system('netscape "%s" &' % url)
  
          def quit(self, event=None):
***************
*** 1297,1303 ****
              selection = self.result_lst.curselection()
              if selection:
-                 import webbrowser
                  modname = split(self.result_lst.get(selection[0]))[0]
!                 webbrowser.open(self.server.url + modname + '.html')
  
          def collapse(self):
--- 1312,1317 ----
              selection = self.result_lst.curselection()
              if selection:
                  modname = split(self.result_lst.get(selection[0]))[0]
!                 self.open(url=self.server.url + modname + '.html')
  
          def collapse(self):