[Python-checkins] CVS: python/dist/src/Lib urllib.py,1.89,1.90

Guido van Rossum guido@cnri.reston.va.us
Tue, 1 Feb 2000 18:36:58 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Lib
In directory eric:/projects/python/develop/guido/src/Lib

Modified Files:
	urllib.py 
Log Message:
Sjoerd Mullender writes:

Fixed a TypeError: not enough arguments; expected 4, got 3.
When authentication is needed, the default http_error_401 method calls 
retry_http_basic_auth.  The default version of that method expected a
data argument which wasn't provided, so now we provide the argument if 
it was given and we also made the data argument optional.

Also changed other calls where data was optional to not pass data if
it was not passed to the calling method (in line with other similar
occurances).


Index: urllib.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/urllib.py,v
retrieving revision 1.89
retrieving revision 1.90
diff -C2 -r1.89 -r1.90
*** urllib.py	1999/12/07 21:37:17	1.89
--- urllib.py	2000/02/01 23:36:55	1.90
***************
*** 500,504 ****
          # In case the server sent a relative URL, join with original:
          newurl = basejoin("http:" + url, newurl)
!         return self.open(newurl, data)
  
      # Error 301 -- also relocated (permanently)
--- 500,507 ----
          # In case the server sent a relative URL, join with original:
          newurl = basejoin("http:" + url, newurl)
!         if data is None:
!             return self.open(newurl)
!         else:
!             return self.open(newurl, data)
  
      # Error 301 -- also relocated (permanently)
***************
*** 518,524 ****
                  if string.lower(scheme) == 'basic':
                     name = 'retry_' + self.type + '_basic_auth'
!                    return getattr(self,name)(url, realm)
  
!     def retry_http_basic_auth(self, url, realm, data):
          host, selector = splithost(url)
          i = string.find(host, '@') + 1
--- 521,530 ----
                  if string.lower(scheme) == 'basic':
                     name = 'retry_' + self.type + '_basic_auth'
!                    if data is None:
!                        return getattr(self,name)(url, realm)
!                    else:
!                        return getattr(self,name)(url, realm, data)
  
!     def retry_http_basic_auth(self, url, realm, data=None):
          host, selector = splithost(url)
          i = string.find(host, '@') + 1
***************
*** 528,534 ****
          host = user + ':' + passwd + '@' + host
          newurl = 'http://' + host + selector
!         return self.open(newurl, data)
     
!     def retry_https_basic_auth(self, url, realm):
              host, selector = splithost(url)
              i = string.find(host, '@') + 1
--- 534,543 ----
          host = user + ':' + passwd + '@' + host
          newurl = 'http://' + host + selector
!         if data is None:
!             return self.open(newurl)
!         else:
!             return self.open(newurl, data)
     
!     def retry_https_basic_auth(self, url, realm, data=None):
              host, selector = splithost(url)
              i = string.find(host, '@') + 1



Return-Path: <guido@kaluha.cnri.reston.va.us>
Delivered-To: python-checkins@dinsdale.python.org
Received: from python.org (parrot.python.org [132.151.1.90])
	by dinsdale.python.org (Postfix) with ESMTP id 891DA1CD42
	for <python-checkins@dinsdale.python.org>; Wed,  2 Feb 2000 10:08:59 -0500 (EST)
Received: from cnri.reston.va.us (ns.CNRI.Reston.VA.US [132.151.1.1] (may be forged))
	by python.org (8.9.1a/8.9.1) with ESMTP id KAA28495
	for <python-checkins@python.org>; Wed, 2 Feb 2000 10:08:57 -0500 (EST)
Received: from kaluha.cnri.reston.va.us (kaluha.cnri.reston.va.us [132.151.7.31])
	by cnri.reston.va.us (8.9.1a/8.9.1) with ESMTP id KAA12031
	for <python-checkins@python.org>; Wed, 2 Feb 2000 10:08:58 -0500 (EST)
Received: from eric.cnri.reston.va.us (eric.cnri.reston.va.us [10.27.10.23])
	by kaluha.cnri.reston.va.us (8.9.1b+Sun/8.9.1) with ESMTP id KAA05279
	for <python-checkins@python.org>; Wed, 2 Feb 2000 10:10:22 -0500 (EST)
Received: (from guido@localhost)
	by eric.cnri.reston.va.us (8.9.3+Sun/8.9.1) id KAA22017
	for python-checkins@python.org; Wed, 2 Feb 2000 10:10:20 -0500 (EST)
Date: Wed, 2 Feb 2000 10:10:20 -0500 (EST)
From: Guido van Rossum <guido@cnri.reston.va.us>
Message-Id: <200002021510.KAA22017@eric.cnri.reston.va.us>
To: python-checkins@python.org
Subject: [Python-checkins] CVS: python/dist/src/Lib fpformat.py,1.5,1.6 copy_reg.py,1.2,1.3 bisect.py,1.3,1.4 audiodev.py,1.7,1.8 UserList.py,1.7,1.8 UserDict.py,1.6,1.7 StringIO.py,1.7,1.8 Queue.py,1.9,1.10 dircmp.py,1.7,1.8 dircache.py,1.4,1.5 cmpcache.py,1.7,1.8 cmp.py,1.7,1.8 cmd.py,1.16,1.17 calendar.py,1.14,1.15 binhex.py,1.10,1.11 bdb.py,1.26,1.27 base64.py,1.8,1.9 aifc.py,1.34,1.35
Sender: python-checkins-admin@python.org
Errors-To: python-checkins-admin@python.org
X-BeenThere: python-checkins@python.org
X-Mailman-Version: 1.2 (experimental)
Precedence: bulk
List-Id: Check-in messages from the Python maintainers <python-checkins.python.org>

Update of /projects/cvsroot/python/dist/src/Lib
In directory eric:/projects/python/develop/guido/src/Lib

Modified Files:
	fpformat.py copy_reg.py bisect.py audiodev.py UserList.py 
	UserDict.py StringIO.py Queue.py dircmp.py dircache.py 
	cmpcache.py cmp.py cmd.py calendar.py binhex.py bdb.py 
	base64.py aifc.py 
Log Message:
Mass patch by Ka-Ping Yee:

    1. Comments at the beginning of the module, before
       functions, and before classes have been turned
       into docstrings.

    2. Tabs are normalized to four spaces.

Also, removed the "remove" function from dircmp.py, which reimplements
list.remove() (it must have been very old).



Index: fpformat.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/fpformat.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** fpformat.py	1999/09/10 14:34:48	1.5
--- fpformat.py	2000/02/02 15:10:13	1.6
***************
*** 1,14 ****
! # General floating point formatting functions.
  
! # Functions:
! # fix(x, digits_behind)
! # sci(x, digits_behind)
  
! # Each takes a number or a string and a number of digits as arguments.
  
! # Parameters:
! # x:             number to be formatted; or a string resembling a number
! # digits_behind: number of digits behind the decimal point
! 
  
  import re
--- 1,14 ----
! """General floating point formatting functions.
  
! Functions:
! fix(x, digits_behind)
! sci(x, digits_behind)
  
! Each takes a number or a string and a number of digits as arguments.
  
! Parameters:
! x:             number to be formatted; or a string resembling a number
! digits_behind: number of digits behind the decimal point
! """
  
  import re

Index: copy_reg.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/copy_reg.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** copy_reg.py	1997/05/20 18:03:22	1.2
--- copy_reg.py	2000/02/02 15:10:13	1.3
***************
*** 1,3 ****
! # Helper to provide extensibility for pickle/cPickle.
  
  dispatch_table = {}
--- 1,3 ----
! """Helper to provide extensibility for pickle/cPickle."""
  
  dispatch_table = {}

Index: bisect.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/bisect.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** bisect.py	1998/03/26 20:35:09	1.3
--- bisect.py	2000/02/02 15:10:14	1.4
***************
*** 1,25 ****
! # Bisection algorithms
  
  
- # Insert item x in list a, and keep it sorted assuming a is sorted
- 
  def insort(a, x, lo=0, hi=None):
! 	if hi is None:
! 		hi = len(a)
! 	while lo < hi:
! 		mid = (lo+hi)/2
! 		if x < a[mid]: hi = mid
! 		else: lo = mid+1
! 	a.insert(lo, x)
! 
  
- # Find the index where to insert item x in list a, assuming a is sorted
  
  def bisect(a, x, lo=0, hi=None):
! 	if hi is None:
! 		hi = len(a)
! 	while lo < hi:
! 		mid = (lo+hi)/2
! 		if x < a[mid]: hi = mid
! 		else: lo = mid+1
! 	return lo
--- 1,23 ----
! """Bisection algorithms."""
  
  
  def insort(a, x, lo=0, hi=None):
!     """Insert item x in list a, and keep it sorted assuming a is sorted."""
!     if hi is None:
!         hi = len(a)
!     while lo < hi:
!         mid = (lo+hi)/2
!         if x < a[mid]: hi = mid
!         else: lo = mid+1
!     a.insert(lo, x)
  
  
  def bisect(a, x, lo=0, hi=None):
!     """Find the index where to insert item x in list a, assuming a is sorted."""
!     if hi is None:
!         hi = len(a)
!     while lo < hi:
!         mid = (lo+hi)/2
!         if x < a[mid]: hi = mid
!         else: lo = mid+1
!     return lo

Index: audiodev.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/audiodev.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** audiodev.py	1999/05/03 18:04:07	1.7
--- audiodev.py	2000/02/02 15:10:14	1.8
***************
*** 1,2 ****
--- 1,4 ----
+ """Classes for manipulating audio devices (currently only for Sun and SGI)"""
+ 
  error = 'audiodev.error'
  

Index: UserList.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/UserList.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** UserList.py	1999/03/26 16:20:18	1.7
--- UserList.py	2000/02/02 15:10:14	1.8
***************
*** 1,3 ****
! # A more or less complete user-defined wrapper around list objects
  
  class UserList:
--- 1,3 ----
! """A more or less complete user-defined wrapper around list objects."""
  
  class UserList:

Index: UserDict.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/UserDict.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** UserDict.py	1999/03/26 15:31:12	1.6
--- UserDict.py	2000/02/02 15:10:14	1.7
***************
*** 1,3 ****
! # A more or less complete user-defined wrapper around dictionary objects
  
  class UserDict:
--- 1,3 ----
! """A more or less complete user-defined wrapper around dictionary objects."""
  
  class UserDict:

Index: StringIO.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/StringIO.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** StringIO.py	1998/08/18 17:43:08	1.7
--- StringIO.py	2000/02/02 15:10:14	1.8
***************
*** 1,29 ****
! # class StringIO implements  file-like objects that read/write a
! # string buffer (a.k.a. "memory files").
! #
! # This implements (nearly) all stdio methods.
! #
! # f = StringIO()      # ready for writing
! # f = StringIO(buf)   # ready for reading
! # f.close()           # explicitly release resources held
! # flag = f.isatty()   # always false
! # pos = f.tell()      # get current position
! # f.seek(pos)         # set current position
! # f.seek(pos, mode)   # mode 0: absolute; 1: relative; 2: relative to EOF
! # buf = f.read()      # read until EOF
! # buf = f.read(n)     # read up to n bytes
! # buf = f.readline()  # read until end of line ('\n') or EOF
! # list = f.readlines()# list of f.readline() results until EOF
! # f.write(buf)        # write at current position
! # f.writelines(list)  # for line in list: f.write(line)
! # f.getvalue()        # return whole file's contents as a string
! #
! # Notes:
! # - Using a real file is often faster (but less convenient).
! # - fileno() is left unimplemented so that code which uses it triggers
! #   an exception early.
! # - Seeking far beyond EOF and then writing will insert real null
! #   bytes that occupy space in the buffer.
! # - There's a simple test set (see end of this file).
  
  import string
--- 1,29 ----
! """File-like objects that read from or write to a string buffer.
! 
! This implements (nearly) all stdio methods.
! 
! f = StringIO()      # ready for writing
! f = StringIO(buf)   # ready for reading
! f.close()           # explicitly release resources held
! flag = f.isatty()   # always false
! pos = f.tell()      # get current position
! f.seek(pos)         # set current position
! f.seek(pos, mode)   # mode 0: absolute; 1: relative; 2: relative to EOF
! buf = f.read()      # read until EOF
! buf = f.read(n)     # read up to n bytes
! buf = f.readline()  # read until end of line ('\n') or EOF
! list = f.readlines()# list of f.readline() results until EOF
! f.write(buf)        # write at current position
! f.writelines(list)  # for line in list: f.write(line)
! f.getvalue()        # return whole file's contents as a string
! 
! Notes:
! - Using a real file is often faster (but less convenient).
! - fileno() is left unimplemented so that code which uses it triggers
!   an exception early.
! - Seeking far beyond EOF and then writing will insert real null
!   bytes that occupy space in the buffer.
! - There's a simple test set (see end of this file).
! """
  
  import string

Index: Queue.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/Queue.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** Queue.py	1999/09/09 14:54:28	1.9
--- Queue.py	2000/02/02 15:10:14	1.10
***************
*** 1,3 ****
! # A multi-producer, multi-consumer queue.
  
  # define this exception to be compatible with Python 1.5's class
--- 1,3 ----
! """A multi-producer, multi-consumer queue."""
  
  # define this exception to be compatible with Python 1.5's class

Index: dircmp.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/dircmp.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** dircmp.py	1992/12/14 12:57:38	1.7
--- dircmp.py	2000/02/02 15:10:14	1.8
***************
*** 1,5 ****
! # Module 'dirmp'
! #
! # Defines a class to build directory diff tools on.
  
  import os
--- 1,3 ----
! """A class to build directory diff tools on."""
  
  import os
***************
*** 10,203 ****
  from stat import *
  
- # Directory comparison class.
- #
  class dircmp:
! 	#
! 	def new(self, a, b): # Initialize
! 		self.a = a
! 		self.b = b
! 		# Properties that caller may change before calling self.run():
! 		self.hide = [os.curdir, os.pardir] # Names never to be shown
! 		self.ignore = ['RCS', 'tags'] # Names ignored in comparison
! 		#
! 		return self
! 	#
! 	def run(self): # Compare everything except common subdirectories
! 		self.a_list = filter(dircache.listdir(self.a), self.hide)
! 		self.b_list = filter(dircache.listdir(self.b), self.hide)
! 		self.a_list.sort()
! 		self.b_list.sort()
! 		self.phase1()
! 		self.phase2()
! 		self.phase3()
! 	#
! 	def phase1(self): # Compute common names
! 		self.a_only = []
! 		self.common = []
! 		for x in self.a_list:
! 			if x in self.b_list:
! 				self.common.append(x)
! 			else:
! 				self.a_only.append(x)
! 		#
! 		self.b_only = []
! 		for x in self.b_list:
! 			if x not in self.common:
! 				self.b_only.append(x)
! 	#
! 	def phase2(self): # Distinguish files, directories, funnies
! 		self.common_dirs = []
! 		self.common_files = []
! 		self.common_funny = []
! 		#
! 		for x in self.common:
! 			a_path = os.path.join(self.a, x)
! 			b_path = os.path.join(self.b, x)
! 			#
! 			ok = 1
! 			try:
! 				a_stat = statcache.stat(a_path)
! 			except os.error, why:
! 				# print 'Can\'t stat', a_path, ':', why[1]
! 				ok = 0
! 			try:
! 				b_stat = statcache.stat(b_path)
! 			except os.error, why:
! 				# print 'Can\'t stat', b_path, ':', why[1]
! 				ok = 0
! 			#
! 			if ok:
! 				a_type = S_IFMT(a_stat[ST_MODE])
! 				b_type = S_IFMT(b_stat[ST_MODE])
! 				if a_type <> b_type:
! 					self.common_funny.append(x)
! 				elif S_ISDIR(a_type):
! 					self.common_dirs.append(x)
! 				elif S_ISREG(a_type):
! 					self.common_files.append(x)
! 				else:
! 					self.common_funny.append(x)
! 			else:
! 				self.common_funny.append(x)
! 	#
! 	def phase3(self): # Find out differences between common files
! 		xx = cmpfiles(self.a, self.b, self.common_files)
! 		self.same_files, self.diff_files, self.funny_files = xx
! 	#
! 	def phase4(self): # Find out differences between common subdirectories
! 		# A new dircmp object is created for each common subdirectory,
! 		# these are stored in a dictionary indexed by filename.
! 		# The hide and ignore properties are inherited from the parent
! 		self.subdirs = {}
! 		for x in self.common_dirs:
! 			a_x = os.path.join(self.a, x)
! 			b_x = os.path.join(self.b, x)
! 			self.subdirs[x] = newdd = dircmp().new(a_x, b_x)
! 			newdd.hide = self.hide
! 			newdd.ignore = self.ignore
! 			newdd.run()
! 	#
! 	def phase4_closure(self): # Recursively call phase4() on subdirectories
! 		self.phase4()
! 		for x in self.subdirs.keys():
! 			self.subdirs[x].phase4_closure()
! 	#
! 	def report(self): # Print a report on the differences between a and b
! 		# Assume that phases 1 to 3 have been executed
! 		# Output format is purposely lousy
! 		print 'diff', self.a, self.b
! 		if self.a_only:
! 			print 'Only in', self.a, ':', self.a_only
! 		if self.b_only:
! 			print 'Only in', self.b, ':', self.b_only
! 		if self.same_files:
! 			print 'Identical files :', self.same_files
! 		if self.diff_files:
! 			print 'Differing files :', self.diff_files
! 		if self.funny_files:
! 			print 'Trouble with common files :', self.funny_files
! 		if self.common_dirs:
! 			print 'Common subdirectories :', self.common_dirs
! 		if self.common_funny:
! 			print 'Common funny cases :', self.common_funny
! 	#
! 	def report_closure(self): # Print reports on self and on subdirs
! 		# If phase 4 hasn't been done, no subdir reports are printed
! 		self.report()
! 		try:
! 			x = self.subdirs
! 		except AttributeError:
! 			return # No subdirectories computed
! 		for x in self.subdirs.keys():
! 			print
! 			self.subdirs[x].report_closure()
! 	#
! 	def report_phase4_closure(self): # Report and do phase 4 recursively
! 		self.report()
! 		self.phase4()
! 		for x in self.subdirs.keys():
! 			print
! 			self.subdirs[x].report_phase4_closure()
! 
! 
! # Compare common files in two directories.
! # Return:
! #	- files that compare equal
! #	- files that compare different
! #	- funny cases (can't stat etc.)
! #
  def cmpfiles(a, b, common):
! 	res = ([], [], [])
! 	for x in common:
! 		res[cmp(os.path.join(a, x), os.path.join(b, x))].append(x)
! 	return res
  
  
- # Compare two files.
- # Return:
- #	0 for equal
- #	1 for different
- #	2 for funny cases (can't stat, etc.)
- #
  def cmp(a, b):
! 	try:
! 		if cmpcache.cmp(a, b): return 0
! 		return 1
! 	except os.error:
! 		return 2
! 
! 
! # Remove a list item.
! # NB: This modifies the list argument.
! #
! def remove(list, item):
! 	for i in range(len(list)):
! 		if list[i] == item:
! 			del list[i]
! 			break
  
  
- # Return a copy with items that occur in skip removed.
- #
  def filter(list, skip):
! 	result = []
! 	for item in list:
! 		if item not in skip: result.append(item)
! 	return result
  
  
! # Demonstration and testing.
! #
  def demo():
! 	import sys
! 	import getopt
! 	options, args = getopt.getopt(sys.argv[1:], 'r')
! 	if len(args) <> 2: raise getopt.error, 'need exactly two args'
! 	dd = dircmp().new(args[0], args[1])
! 	dd.run()
! 	if ('-r', '') in options:
! 		dd.report_phase4_closure()
! 	else:
! 		dd.report()
  
! # demo()
--- 8,201 ----
  from stat import *
  
  class dircmp:
!     """Directory comparison class."""
! 
!     def new(self, a, b):
!         """Initialize."""
!         self.a = a
!         self.b = b
!         # Properties that caller may change before calling self.run():
!         self.hide = [os.curdir, os.pardir] # Names never to be shown
!         self.ignore = ['RCS', 'tags'] # Names ignored in comparison
! 
!         return self
! 
!     def run(self):
!         """Compare everything except common subdirectories."""
!         self.a_list = filter(dircache.listdir(self.a), self.hide)
!         self.b_list = filter(dircache.listdir(self.b), self.hide)
!         self.a_list.sort()
!         self.b_list.sort()
!         self.phase1()
!         self.phase2()
!         self.phase3()
! 
!     def phase1(self):
!         """Compute common names."""
!         self.a_only = []
!         self.common = []
!         for x in self.a_list:
!             if x in self.b_list:
!                 self.common.append(x)
!             else:
!                 self.a_only.append(x)
! 
!         self.b_only = []
!         for x in self.b_list:
!             if x not in self.common:
!                 self.b_only.append(x)
! 
!     def phase2(self):
!         """Distinguish files, directories, funnies."""
!         self.common_dirs = []
!         self.common_files = []
!         self.common_funny = []
! 
!         for x in self.common:
!             a_path = os.path.join(self.a, x)
!             b_path = os.path.join(self.b, x)
! 
!             ok = 1
!             try:
!                 a_stat = statcache.stat(a_path)
!             except os.error, why:
!                 # print 'Can\'t stat', a_path, ':', why[1]
!                 ok = 0
!             try:
!                 b_stat = statcache.stat(b_path)
!             except os.error, why:
!                 # print 'Can\'t stat', b_path, ':', why[1]
!                 ok = 0
! 
!             if ok:
!                 a_type = S_IFMT(a_stat[ST_MODE])
!                 b_type = S_IFMT(b_stat[ST_MODE])
!                 if a_type <> b_type:
!                     self.common_funny.append(x)
!                 elif S_ISDIR(a_type):
!                     self.common_dirs.append(x)
!                 elif S_ISREG(a_type):
!                     self.common_files.append(x)
!                 else:
!                     self.common_funny.append(x)
!             else:
!                 self.common_funny.append(x)
! 
!     def phase3(self):
!         """Find out differences between common files."""
!         xx = cmpfiles(self.a, self.b, self.common_files)
!         self.same_files, self.diff_files, self.funny_files = xx
! 
!     def phase4(self):
!         """Find out differences between common subdirectories.
!         A new dircmp object is created for each common subdirectory,
!         these are stored in a dictionary indexed by filename.
!         The hide and ignore properties are inherited from the parent."""
!         self.subdirs = {}
!         for x in self.common_dirs:
!             a_x = os.path.join(self.a, x)
!             b_x = os.path.join(self.b, x)
!             self.subdirs[x] = newdd = dircmp().new(a_x, b_x)
!             newdd.hide = self.hide
!             newdd.ignore = self.ignore
!             newdd.run()
! 
!     def phase4_closure(self):
!         """Recursively call phase4() on subdirectories."""
!         self.phase4()
!         for x in self.subdirs.keys():
!             self.subdirs[x].phase4_closure()
! 
!     def report(self):
!         """Print a report on the differences between a and b."""
!         # Assume that phases 1 to 3 have been executed
!         # Output format is purposely lousy
!         print 'diff', self.a, self.b
!         if self.a_only:
!             print 'Only in', self.a, ':', self.a_only
!         if self.b_only:
!             print 'Only in', self.b, ':', self.b_only
!         if self.same_files:
!             print 'Identical files :', self.same_files
!         if self.diff_files:
!             print 'Differing files :', self.diff_files
!         if self.funny_files:
!             print 'Trouble with common files :', self.funny_files
!         if self.common_dirs:
!             print 'Common subdirectories :', self.common_dirs
!         if self.common_funny:
!             print 'Common funny cases :', self.common_funny
! 
!     def report_closure(self):
!         """Print reports on self and on subdirs.
!         If phase 4 hasn't been done, no subdir reports are printed."""
!         self.report()
!         try:
!             x = self.subdirs
!         except AttributeError:
!             return # No subdirectories computed
!         for x in self.subdirs.keys():
!             print
!             self.subdirs[x].report_closure()
! 
!     def report_phase4_closure(self):
!         """Report and do phase 4 recursively."""
!         self.report()
!         self.phase4()
!         for x in self.subdirs.keys():
!             print
!             self.subdirs[x].report_phase4_closure()
! 
! 
  def cmpfiles(a, b, common):
!     """Compare common files in two directories.
!     Return:
!         - files that compare equal
!         - files that compare different
!         - funny cases (can't stat etc.)"""
! 
!     res = ([], [], [])
!     for x in common:
!         res[cmp(os.path.join(a, x), os.path.join(b, x))].append(x)
!     return res
  
  
  def cmp(a, b):
!     """Compare two files.
!     Return:
!         0 for equal
!         1 for different
!         2 for funny cases (can't stat, etc.)"""
! 
!     try:
!         if cmpcache.cmp(a, b): return 0
!         return 1
!     except os.error:
!         return 2
  
  
  def filter(list, skip):
!     """Return a copy with items that occur in skip removed."""
  
+     result = []
+     for item in list:
+         if item not in skip: result.append(item)
+     return result
  
! 
  def demo():
!     """Demonstration and testing."""
! 
!     import sys
!     import getopt
!     options, args = getopt.getopt(sys.argv[1:], 'r')
!     if len(args) <> 2: raise getopt.error, 'need exactly two args'
!     dd = dircmp().new(args[0], args[1])
!     dd.run()
!     if ('-r', '') in options:
!         dd.report_phase4_closure()
!     else:
!         dd.report()
  
! if __name__ == "__main__":
!     demo()

Index: dircache.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/dircache.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** dircache.py	1992/03/31 18:55:14	1.4
--- dircache.py	2000/02/02 15:10:14	1.5
***************
*** 1,7 ****
! # Module 'dircache'
! #
! # Return a sorted list of the files in a directory, using a cache
! # to avoid reading the directory more often than necessary.
! # Also contains a subroutine to append slashes to directories.
  
  import os
--- 1,5 ----
! """Return a sorted list of the files in a directory, using a cache
! to avoid reading the directory more often than necessary.
! Also contains a subroutine to append slashes to directories."""
  
  import os
***************
*** 9,35 ****
  cache = {}
  
! def listdir(path): # List directory contents, using cache
! 	try:
! 		cached_mtime, list = cache[path]
! 		del cache[path]
! 	except KeyError:
! 		cached_mtime, list = -1, []
! 	try:
! 		mtime = os.stat(path)[8]
! 	except os.error:
! 		return []
! 	if mtime <> cached_mtime:
! 		try:
! 			list = os.listdir(path)
! 		except os.error:
! 			return []
! 		list.sort()
! 	cache[path] = mtime, list
! 	return list
  
  opendir = listdir # XXX backward compatibility
  
! def annotate(head, list): # Add '/' suffixes to directories
! 	for i in range(len(list)):
! 		if os.path.isdir(os.path.join(head, list[i])):
! 			list[i] = list[i] + '/'
--- 7,35 ----
  cache = {}
  
! def listdir(path):
!     """List directory contents, using cache."""
!     try:
!         cached_mtime, list = cache[path]
!         del cache[path]
!     except KeyError:
!         cached_mtime, list = -1, []
!     try:
!         mtime = os.stat(path)[8]
!     except os.error:
!         return []
!     if mtime <> cached_mtime:
!         try:
!             list = os.listdir(path)
!         except os.error:
!             return []
!         list.sort()
!     cache[path] = mtime, list
!     return list
  
  opendir = listdir # XXX backward compatibility
  
! def annotate(head, list):
!     """Add '/' suffixes to directories."""
!     for i in range(len(list)):
!         if os.path.isdir(os.path.join(head, list[i])):
!             list[i] = list[i] + '/'

Index: cmpcache.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/cmpcache.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** cmpcache.py	1999/06/25 14:21:44	1.7
--- cmpcache.py	2000/02/02 15:10:14	1.8
***************
*** 1,12 ****
! # Module 'cmpcache'
! #
! # Efficiently compare files, boolean outcome only (equal / not equal).
! #
! # Tricks (used in this order):
! #	- Use the statcache module to avoid statting files more than once
! #	- Files with identical type, size & mtime are assumed to be clones
! #	- Files with different type or size cannot be identical
! #	- We keep a cache of outcomes of earlier comparisons
! #	- We don't fork a process to run 'cmp' but read the files ourselves
  
  import os
--- 1,11 ----
! """Efficiently compare files, boolean outcome only (equal / not equal).
! 
! Tricks (used in this order):
!     - Use the statcache module to avoid statting files more than once
!     - Files with identical type, size & mtime are assumed to be clones
!     - Files with different type or size cannot be identical
!     - We keep a cache of outcomes of earlier comparisons
!     - We don't fork a process to run 'cmp' but read the files ourselves
! """
  
  import os
***************
*** 20,68 ****
  
  
- # Compare two files, use the cache if possible.
- # May raise os.error if a stat or open of either fails.
- #
  def cmp(f1, f2, shallow=1):
! 	# Return 1 for identical files, 0 for different.
! 	# Raise exceptions if either file could not be statted, read, etc.
! 	s1, s2 = sig(statcache.stat(f1)), sig(statcache.stat(f2))
! 	if not S_ISREG(s1[0]) or not S_ISREG(s2[0]):
! 		# Either is a not a plain file -- always report as different
! 		return 0
! 	if shallow and s1 == s2:
! 		# type, size & mtime match -- report same
! 		return 1
! 	if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
! 		# types or sizes differ -- report different
! 		return 0
! 	# same type and size -- look in the cache
! 	key = f1 + ' ' + f2
! 	if cache.has_key(key):
! 		cs1, cs2, outcome = cache[key]
! 		# cache hit
! 		if s1 == cs1 and s2 == cs2:
! 			# cached signatures match
! 			return outcome
! 		# stale cached signature(s)
! 	# really compare
! 	outcome = do_cmp(f1, f2)
! 	cache[key] = s1, s2, outcome
! 	return outcome
  
- # Return signature (i.e., type, size, mtime) from raw stat data.
- #
  def sig(st):
! 	return S_IFMT(st[ST_MODE]), st[ST_SIZE], st[ST_MTIME]
  
- # Compare two files, really.
- #
  def do_cmp(f1, f2):
! 	#print '    cmp', f1, f2 # XXX remove when debugged
! 	bufsize = 8*1024 # Could be tuned
! 	fp1 = open(f1, 'rb')
! 	fp2 = open(f2, 'rb')
! 	while 1:
! 		b1 = fp1.read(bufsize)
! 		b2 = fp2.read(bufsize)
! 		if b1 <> b2: return 0
! 		if not b1: return 1
--- 19,64 ----
  
  
  def cmp(f1, f2, shallow=1):
!     """Compare two files, use the cache if possible.
!     May raise os.error if a stat or open of either fails.
!     Return 1 for identical files, 0 for different.
!     Raise exceptions if either file could not be statted, read, etc."""
!     s1, s2 = sig(statcache.stat(f1)), sig(statcache.stat(f2))
!     if not S_ISREG(s1[0]) or not S_ISREG(s2[0]):
!         # Either is a not a plain file -- always report as different
!         return 0
!     if shallow and s1 == s2:
!         # type, size & mtime match -- report same
!         return 1
!     if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
!         # types or sizes differ -- report different
!         return 0
!     # same type and size -- look in the cache
!     key = f1 + ' ' + f2
!     if cache.has_key(key):
!         cs1, cs2, outcome = cache[key]
!         # cache hit
!         if s1 == cs1 and s2 == cs2:
!             # cached signatures match
!             return outcome
!         # stale cached signature(s)
!     # really compare
!     outcome = do_cmp(f1, f2)
!     cache[key] = s1, s2, outcome
!     return outcome
  
  def sig(st):
!     """Return signature (i.e., type, size, mtime) from raw stat data."""
!     return S_IFMT(st[ST_MODE]), st[ST_SIZE], st[ST_MTIME]
  
  def do_cmp(f1, f2):
!     """Compare two files, really."""
!     #print '    cmp', f1, f2 # XXX remove when debugged
!     bufsize = 8*1024 # Could be tuned
!     fp1 = open(f1, 'rb')
!     fp2 = open(f2, 'rb')
!     while 1:
!         b1 = fp1.read(bufsize)
!         b2 = fp2.read(bufsize)
!         if b1 <> b2: return 0
!         if not b1: return 1

Index: cmp.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/cmp.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** cmp.py	1999/06/25 14:12:50	1.7
--- cmp.py	2000/02/02 15:10:14	1.8
***************
*** 1,61 ****
! # Module 'cmp'
  
! # Efficiently compare files, boolean outcome only (equal / not equal).
  
- # Tricks (used in this order):
- #	- Files with identical type, size & mtime are assumed to be clones
- #	- Files with different type or size cannot be identical
- #	- We keep a cache of outcomes of earlier comparisons
- #	- We don't fork a process to run 'cmp' but read the files ourselves
- 
  import os
  
  cache = {}
  
! def cmp(f1, f2, shallow=1): # Compare two files, use the cache if possible.
! 	# Return 1 for identical files, 0 for different.
! 	# Raise exceptions if either file could not be statted, read, etc.
! 	s1, s2 = sig(os.stat(f1)), sig(os.stat(f2))
! 	if s1[0] <> 8 or s2[0] <> 8:
! 		# Either is a not a plain file -- always report as different
! 		return 0
! 	if shallow and s1 == s2:
! 		# type, size & mtime match -- report same
! 		return 1
! 	if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
! 		# types or sizes differ -- report different
! 		return 0
! 	# same type and size -- look in the cache
! 	key = (f1, f2)
! 	try:
! 		cs1, cs2, outcome = cache[key]
! 		# cache hit
! 		if s1 == cs1 and s2 == cs2:
! 			# cached signatures match
! 			return outcome
! 		# stale cached signature(s)
! 	except KeyError:
! 		# cache miss
! 		pass
! 	# really compare
! 	outcome = do_cmp(f1, f2)
! 	cache[key] = s1, s2, outcome
! 	return outcome
! 
! def sig(st): # Return signature (i.e., type, size, mtime) from raw stat data
! 	# 0-5: st_mode, st_ino, st_dev, st_nlink, st_uid, st_gid
! 	# 6-9: st_size, st_atime, st_mtime, st_ctime
! 	type = st[0] / 4096
! 	size = st[6]
! 	mtime = st[8]
! 	return type, size, mtime
! 
! def do_cmp(f1, f2): # Compare two files, really
! 	bufsize = 8*1024 # Could be tuned
! 	fp1 = open(f1, 'rb')
! 	fp2 = open(f2, 'rb')
! 	while 1:
! 		b1 = fp1.read(bufsize)
! 		b2 = fp2.read(bufsize)
! 		if b1 <> b2: return 0
! 		if not b1: return 1
--- 1,63 ----
! """Efficiently compare files, boolean outcome only (equal / not equal).
  
! Tricks (used in this order):
!     - Files with identical type, size & mtime are assumed to be clones
!     - Files with different type or size cannot be identical
!     - We keep a cache of outcomes of earlier comparisons
!     - We don't fork a process to run 'cmp' but read the files ourselves
! """
  
  import os
  
  cache = {}
  
! def cmp(f1, f2, shallow=1):
!     """Compare two files, use the cache if possible.
!     Return 1 for identical files, 0 for different.
!     Raise exceptions if either file could not be statted, read, etc."""
!     s1, s2 = sig(os.stat(f1)), sig(os.stat(f2))
!     if s1[0] <> 8 or s2[0] <> 8:
!         # Either is a not a plain file -- always report as different
!         return 0
!     if shallow and s1 == s2:
!         # type, size & mtime match -- report same
!         return 1
!     if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
!         # types or sizes differ -- report different
!         return 0
!     # same type and size -- look in the cache
!     key = (f1, f2)
!     try:
!         cs1, cs2, outcome = cache[key]
!         # cache hit
!         if s1 == cs1 and s2 == cs2:
!             # cached signatures match
!             return outcome
!         # stale cached signature(s)
!     except KeyError:
!         # cache miss
!         pass
!     # really compare
!     outcome = do_cmp(f1, f2)
!     cache[key] = s1, s2, outcome
!     return outcome
! 
! def sig(st):
!     """Return signature (i.e., type, size, mtime) from raw stat data
!     0-5: st_mode, st_ino, st_dev, st_nlink, st_uid, st_gid
!     6-9: st_size, st_atime, st_mtime, st_ctime"""
!     type = st[0] / 4096
!     size = st[6]
!     mtime = st[8]
!     return type, size, mtime
! 
! def do_cmp(f1, f2):
!     """Compare two files, really."""
!     bufsize = 8*1024 # Could be tuned
!     fp1 = open(f1, 'rb')
!     fp2 = open(f2, 'rb')
!     while 1:
!         b1 = fp1.read(bufsize)
!         b2 = fp2.read(bufsize)
!         if b1 <> b2: return 0
!         if not b1: return 1

Index: cmd.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/cmd.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** cmd.py	1999/05/03 18:08:16	1.16
--- cmd.py	2000/02/02 15:10:14	1.17
***************
*** 1,39 ****
! # A generic class to build line-oriented command interpreters
! #
! # Interpreters constructed with this class obey the following conventions:
! #
! # 1. End of file on input is processed as the command 'EOF'.
! # 2. A command is parsed out of each line by collecting the prefix composed
! #    of characters in the identchars member.
! # 3. A command `foo' is dispatched to a method 'do_foo()'; the do_ method
! #    is passed a single argument consisting of the remainder of the line.
! # 4. Typing an empty line repeats the last command.  (Actually, it calls the
! #    method `emptyline', which may be overridden in a subclass.)
! # 5. There is a predefined `help' method.  Given an argument `topic', it
! #    calls the command `help_topic'.  With no arguments, it lists all topics
! #    with defined help_ functions, broken into up to three topics; documented
! #    commands, miscellaneous help topics, and undocumented commands.
! # 6. The command '?' is a synonym for `help'.  The command '!' is a synonym
! #    for `shell', if a do_shell method exists.
! #
! # The `default' method may be overridden to intercept commands for which there
! # is no do_ method.
! #
! # The data member `self.ruler' sets the character used to draw separator lines
! # in the help messages.  If empty, no ruler line is drawn.  It defaults to "=".
! #
! # If the value of `self.intro' is nonempty when the cmdloop method is called,
! # it is printed out on interpreter startup.  This value may be overridden
! # via an optional argument to the cmdloop() method.
! #
! # The data members `self.doc_header', `self.misc_header', and
! # `self.undoc_header' set the headers used for the help function's
! # listings of documented functions, miscellaneous topics, and undocumented
! # functions respectively.
! #
! # These interpreters use raw_input; thus, if the readline module is loaded,
! # they automatically support Emacs-like command history and editing features.
! #
  
  import string
  
--- 1,39 ----
! """A generic class to build line-oriented command interpreters.
  
+ Interpreters constructed with this class obey the following conventions:
+ 
+ 1. End of file on input is processed as the command 'EOF'.
+ 2. A command is parsed out of each line by collecting the prefix composed
+    of characters in the identchars member.
+ 3. A command `foo' is dispatched to a method 'do_foo()'; the do_ method
+    is passed a single argument consisting of the remainder of the line.
+ 4. Typing an empty line repeats the last command.  (Actually, it calls the
+    method `emptyline', which may be overridden in a subclass.)
+ 5. There is a predefined `help' method.  Given an argument `topic', it
+    calls the command `help_topic'.  With no arguments, it lists all topics
+    with defined help_ functions, broken into up to three topics; documented
+    commands, miscellaneous help topics, and undocumented commands.
+ 6. The command '?' is a synonym for `help'.  The command '!' is a synonym
+    for `shell', if a do_shell method exists.
+ 
+ The `default' method may be overridden to intercept commands for which there
+ is no do_ method.
+ 
+ The data member `self.ruler' sets the character used to draw separator lines
+ in the help messages.  If empty, no ruler line is drawn.  It defaults to "=".
+ 
+ If the value of `self.intro' is nonempty when the cmdloop method is called,
+ it is printed out on interpreter startup.  This value may be overridden
+ via an optional argument to the cmdloop() method.
+ 
+ The data members `self.doc_header', `self.misc_header', and
+ `self.undoc_header' set the headers used for the help function's
+ listings of documented functions, miscellaneous topics, and undocumented
+ functions respectively.
+ 
+ These interpreters use raw_input; thus, if the readline module is loaded,
+ they automatically support Emacs-like command history and editing features.
+ """
+ 
  import string
  
***************
*** 42,187 ****
  
  class Cmd:
! 	prompt = PROMPT
! 	identchars = IDENTCHARS
! 	ruler = '='
! 	lastcmd = ''
! 	cmdqueue = []
! 	intro = None
! 	doc_leader = ""
! 	doc_header = "Documented commands (type help <topic>):"
! 	misc_header = "Miscellaneous help topics:"
! 	undoc_header = "Undocumented commands:"
! 	nohelp = "*** No help on %s"
! 
! 	def __init__(self): pass
! 
! 	def cmdloop(self, intro=None):
! 		self.preloop()
! 		if intro != None:
! 			self.intro = intro
! 		if self.intro:
! 			print self.intro
! 		stop = None
! 		while not stop:
! 			if self.cmdqueue:
! 				line = self.cmdqueue[0]
! 				del self.cmdqueue[0]
! 			else:
! 				try:
! 					line = raw_input(self.prompt)
! 				except EOFError:
! 					line = 'EOF'
! 			line = self.precmd(line)
! 			stop = self.onecmd(line)
! 			stop = self.postcmd(stop, line)
! 		self.postloop()
! 
! 	def precmd(self, line):
! 		return line
! 
! 	def postcmd(self, stop, line):
! 		return stop
! 
! 	def preloop(self):
! 		pass
! 
! 	def postloop(self):
! 		pass
! 
! 	def onecmd(self, line):
! 		line = string.strip(line)
! 		if line == '?':
! 			line = 'help'
! 		elif line == '!':
! 			if hasattr(self, 'do_shell'):
! 				line = 'shell'
! 			else:
! 				return self.default(line)
! 		elif not line:
! 			return self.emptyline()
! 		self.lastcmd = line
! 		i, n = 0, len(line)
! 		while i < n and line[i] in self.identchars: i = i+1
! 		cmd, arg = line[:i], string.strip(line[i:])
! 		if cmd == '':
! 			return self.default(line)
! 		else:
! 			try:
! 				func = getattr(self, 'do_' + cmd)
! 			except AttributeError:
! 				return self.default(line)
! 			return func(arg)
! 
! 	def emptyline(self):
! 		if self.lastcmd:
! 			return self.onecmd(self.lastcmd)
! 
! 	def default(self, line):
! 		print '*** Unknown syntax:', line
! 
! 	def do_help(self, arg):
! 		if arg:
! 			# XXX check arg syntax
! 			try:
! 				func = getattr(self, 'help_' + arg)
! 			except:
! 				try:
! 					doc=getattr(self, 'do_' + arg).__doc__
! 					if doc:
! 						print doc
! 						return
! 				except:
! 					pass
! 				print self.nohelp % (arg,)
! 				return
! 			func()
! 		else:
! 			# Inheritance says we have to look in class and
! 			# base classes; order is not important.
! 			names = []
! 			classes = [self.__class__]
! 			while classes:
! 				aclass = classes[0]
! 				if aclass.__bases__:
! 				    classes = classes + list(aclass.__bases__)
! 				names = names + dir(aclass)
! 				del classes[0]
! 			cmds_doc = []
! 			cmds_undoc = []
! 			help = {}
! 			for name in names:
! 				if name[:5] == 'help_':
! 					help[name[5:]]=1
! 			names.sort()
! 			# There can be duplicates if routines overridden
! 			prevname = ''
! 			for name in names:
! 				if name[:3] == 'do_':
! 					if name == prevname:
! 						continue
! 					prevname = name
! 					cmd=name[3:]
! 					if help.has_key(cmd):
! 						cmds_doc.append(cmd)
! 						del help[cmd]
! 					elif getattr(self, name).__doc__:
! 						cmds_doc.append(cmd)
! 					else:
! 						cmds_undoc.append(cmd)
! 			print self.doc_leader
! 			self.print_topics(self.doc_header,   cmds_doc,   15,80)
! 			self.print_topics(self.misc_header,  help.keys(),15,80)
! 			self.print_topics(self.undoc_header, cmds_undoc, 15,80)
! 
! 	def print_topics(self, header, cmds, cmdlen, maxcol):
! 		if cmds:
! 			print header;
! 			if self.ruler:
! 			    print self.ruler * len(header)
! 			(cmds_per_line,junk)=divmod(maxcol,cmdlen)
! 			col=cmds_per_line
! 			for cmd in cmds:
! 				if col==0: print
! 				print (("%-"+`cmdlen`+"s") % cmd),
! 				col = (col+1) % cmds_per_line
! 			print "\n"
--- 42,187 ----
  
  class Cmd:
!     prompt = PROMPT
!     identchars = IDENTCHARS
!     ruler = '='
!     lastcmd = ''
!     cmdqueue = []
!     intro = None
!     doc_leader = ""
!     doc_header = "Documented commands (type help <topic>):"
!     misc_header = "Miscellaneous help topics:"
!     undoc_header = "Undocumented commands:"
!     nohelp = "*** No help on %s"
! 
!     def __init__(self): pass
! 
!     def cmdloop(self, intro=None):
!         self.preloop()
!         if intro != None:
!             self.intro = intro
!         if self.intro:
!             print self.intro
!         stop = None
!         while not stop:
!             if self.cmdqueue:
!                 line = self.cmdqueue[0]
!                 del self.cmdqueue[0]
!             else:
!                 try:
!                     line = raw_input(self.prompt)
!                 except EOFError:
!                     line = 'EOF'
!             line = self.precmd(line)
!             stop = self.onecmd(line)
!             stop = self.postcmd(stop, line)
!         self.postloop()
! 
!     def precmd(self, line):
!         return line
! 
!     def postcmd(self, stop, line):
!         return stop
! 
!     def preloop(self):
!         pass
! 
!     def postloop(self):
!         pass
! 
!     def onecmd(self, line):
!         line = string.strip(line)
!         if line == '?':
!             line = 'help'
!         elif line == '!':
!             if hasattr(self, 'do_shell'):
!                 line = 'shell'
!             else:
!                 return self.default(line)
!         elif not line:
!             return self.emptyline()
!         self.lastcmd = line
!         i, n = 0, len(line)
!         while i < n and line[i] in self.identchars: i = i+1
!         cmd, arg = line[:i], string.strip(line[i:])
!         if cmd == '':
!             return self.default(line)
!         else:
!             try:
!                 func = getattr(self, 'do_' + cmd)
!             except AttributeError:
!                 return self.default(line)
!             return func(arg)
! 
!     def emptyline(self):
!         if self.lastcmd:
!             return self.onecmd(self.lastcmd)
! 
!     def default(self, line):
!         print '*** Unknown syntax:', line
! 
!     def do_help(self, arg):
!         if arg:
!             # XXX check arg syntax
!             try:
!                 func = getattr(self, 'help_' + arg)
!             except:
!                 try:
!                     doc=getattr(self, 'do_' + arg).__doc__
!                     if doc:
!                         print doc
!                         return
!                 except:
!                     pass
!                 print self.nohelp % (arg,)
!                 return
!             func()
!         else:
!             # Inheritance says we have to look in class and
!             # base classes; order is not important.
!             names = []
!             classes = [self.__class__]
!             while classes:
!                 aclass = classes[0]
!                 if aclass.__bases__:
!                     classes = classes + list(aclass.__bases__)
!                 names = names + dir(aclass)
!                 del classes[0]
!             cmds_doc = []
!             cmds_undoc = []
!             help = {}
!             for name in names:
!                 if name[:5] == 'help_':
!                     help[name[5:]]=1
!             names.sort()
!             # There can be duplicates if routines overridden
!             prevname = ''
!             for name in names:
!                 if name[:3] == 'do_':
!                     if name == prevname:
!                         continue
!                     prevname = name
!                     cmd=name[3:]
!                     if help.has_key(cmd):
!                         cmds_doc.append(cmd)
!                         del help[cmd]
!                     elif getattr(self, name).__doc__:
!                         cmds_doc.append(cmd)
!                     else:
!                         cmds_undoc.append(cmd)
!             print self.doc_leader
!             self.print_topics(self.doc_header,   cmds_doc,   15,80)
!             self.print_topics(self.misc_header,  help.keys(),15,80)
!             self.print_topics(self.undoc_header, cmds_undoc, 15,80)
! 
!     def print_topics(self, header, cmds, cmdlen, maxcol):
!         if cmds:
!             print header;
!             if self.ruler:
!                 print self.ruler * len(header)
!             (cmds_per_line,junk)=divmod(maxcol,cmdlen)
!             col=cmds_per_line
!             for cmd in cmds:
!                 if col==0: print
!                 print (("%-"+`cmdlen`+"s") % cmd),
!                 col = (col+1) % cmds_per_line
!             print "\n"

Index: calendar.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/calendar.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** calendar.py	1999/06/09 15:07:38	1.14
--- calendar.py	2000/02/02 15:10:14	1.15
***************
*** 1,5 ****
! ###############################
! # Calendar printing functions #
! ###############################
  
  # Revision 2: uses funtions from built-in time module
--- 1,3 ----
! """Calendar printing functions"""
  
  # Revision 2: uses funtions from built-in time module
***************
*** 23,170 ****
  
  # Full and abbreviated names of weekdays
! day_name = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', \
! 	    'Friday', 'Saturday', 'Sunday']
  day_abbr = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  
  # Full and abbreviated names of months (1-based arrays!!!)
! month_name =          ['', 'January',   'February', 'March',    'April', \
! 		           'May',       'June',     'July',     'August', \
! 			   'September', 'October',  'November', 'December']
! month_abbr =       ['   ', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', \
! 		           'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
  
- # Return 1 for leap years, 0 for non-leap years
  def isleap(year):
! 	return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0)
  
- # Return number of leap years in range [y1, y2)
- # Assume y1 <= y2 and no funny (non-leap century) years
  def leapdays(y1, y2):
! 	return (y2+3)/4 - (y1+3)/4
  
- # Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), day (1-31)
  def weekday(year, month, day):
! 	secs = mktime((year, month, day, 0, 0, 0, 0, 0, 0))
! 	tuple = localtime(secs)
! 	return tuple[6]
  
- # Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month
  def monthrange(year, month):
! 	if not 1 <= month <= 12: raise ValueError, 'bad month number'
! 	day1 = weekday(year, month, 1)
! 	ndays = mdays[month] + (month == February and isleap(year))
! 	return day1, ndays
  
- # Return a matrix representing a month's calendar
- # Each row represents a week; days outside this month are zero
  def _monthcalendar(year, month):
! 	day1, ndays = monthrange(year, month)
! 	rows = []
! 	r7 = range(7)
! 	day = 1 - day1
! 	while day <= ndays:
! 		row = [0, 0, 0, 0, 0, 0, 0]
! 		for i in r7:
! 			if 1 <= day <= ndays: row[i] = day
! 			day = day + 1
! 		rows.append(row)
! 	return rows
  
- # Caching interface to _monthcalendar
  _mc_cache = {}
  def monthcalendar(year, month):
! 	key = (year, month)
! 	if _mc_cache.has_key(key):
! 		return _mc_cache[key]
! 	else:
! 		_mc_cache[key] = ret = _monthcalendar(year, month)
! 		return ret
  
- # Center a string in a field
  def _center(str, width):
! 	n = width - len(str)
! 	if n <= 0: return str
! 	return ' '*((n+1)/2) + str + ' '*((n)/2)
  
  # XXX The following code knows that print separates items with space!
  
- # Print a single week (no newline)
  def prweek(week, width):
! 	for day in week:
! 		if day == 0: s = ''
! 		else: s = `day`
! 		print _center(s, width),
  
- # Return a header for a week
  def weekheader(width):
! 	str = ''
! 	if width >= 9: names = day_name
! 	else: names = day_abbr
! 	for i in range(7):
! 		if str: str = str + ' '
! 		str = str + _center(names[i%7][:width], width)
! 	return str
  
- # Print a month's calendar
  def prmonth(year, month, w = 0, l = 0):
! 	w = max(2, w)
! 	l = max(1, l)
! 	print _center(month_name[month] + ' ' + `year`, 7*(w+1) - 1),
! 	print '\n'*l,
! 	print weekheader(w),
! 	print '\n'*l,
! 	for week in monthcalendar(year, month):
! 		prweek(week, w)
! 		print '\n'*l,
  
  # Spacing of month columns
! _colwidth = 7*3 - 1			# Amount printed by prweek()
! _spacing = ' '*4			# Spaces between columns
  
- # 3-column formatting for year calendars
  def format3c(a, b, c):
! 	print _center(a, _colwidth),
! 	print _spacing,
! 	print _center(b, _colwidth),
! 	print _spacing,
! 	print _center(c, _colwidth)
  
- # Print a year's calendar
  def prcal(year):
! 	header = weekheader(2)
! 	format3c('', `year`, '')
! 	for q in range(January, January+12, 3):
! 		print
! 		format3c(month_name[q], month_name[q+1], month_name[q+2])
! 		format3c(header, header, header)
! 		data = []
! 		height = 0
! 		for month in range(q, q+3):
! 			cal = monthcalendar(year, month)
! 			if len(cal) > height: height = len(cal)
! 			data.append(cal)
! 		for i in range(height):
! 			for cal in data:
! 				if i >= len(cal):
! 					print ' '*_colwidth,
! 				else:
! 					prweek(cal[i], 2)
! 				print _spacing,
! 			print
  
- # Unrelated but handy function to calculate Unix timestamp from GMT
  EPOCH = 1970
  def timegm(tuple):
! 	year, month, day, hour, minute, second = tuple[:6]
! 	assert year >= EPOCH
! 	assert 1 <= month <= 12
! 	days = 365*(year-EPOCH) + leapdays(EPOCH, year)
! 	for i in range(1, month):
! 		days = days + mdays[i]
! 	if month > 2 and isleap(year):
! 		days = days + 1
! 	days = days + day - 1
! 	hours = days*24 + hour
! 	minutes = hours*60 + minute
! 	seconds = minutes*60 + second
! 	return seconds
--- 21,168 ----
  
  # Full and abbreviated names of weekdays
! day_name = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
!             'Friday', 'Saturday', 'Sunday']
  day_abbr = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  
  # Full and abbreviated names of months (1-based arrays!!!)
! month_name = ['', 'January', 'February', 'March', 'April',
!               'May', 'June', 'July', 'August',
!               'September', 'October',  'November', 'December']
! month_abbr = ['   ', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
!               'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
  
  def isleap(year):
!     """Return 1 for leap years, 0 for non-leap years."""
!     return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0)
  
  def leapdays(y1, y2):
!     """Return number of leap years in range [y1, y2).
!     Assume y1 <= y2 and no funny (non-leap century) years."""
!     return (y2+3)/4 - (y1+3)/4
  
  def weekday(year, month, day):
!     """Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), day (1-31)."""
!     secs = mktime((year, month, day, 0, 0, 0, 0, 0, 0))
!     tuple = localtime(secs)
!     return tuple[6]
  
  def monthrange(year, month):
!     """Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month."""
!     if not 1 <= month <= 12: raise ValueError, 'bad month number'
!     day1 = weekday(year, month, 1)
!     ndays = mdays[month] + (month == February and isleap(year))
!     return day1, ndays
  
  def _monthcalendar(year, month):
!     """Return a matrix representing a month's calendar.
!     Each row represents a week; days outside this month are zero."""
!     day1, ndays = monthrange(year, month)
!     rows = []
!     r7 = range(7)
!     day = 1 - day1
!     while day <= ndays:
!         row = [0, 0, 0, 0, 0, 0, 0]
!         for i in r7:
!             if 1 <= day <= ndays: row[i] = day
!             day = day + 1
!         rows.append(row)
!     return rows
  
  _mc_cache = {}
  def monthcalendar(year, month):
!     """Caching interface to _monthcalendar."""
!     key = (year, month)
!     if _mc_cache.has_key(key):
!         return _mc_cache[key]
!     else:
!         _mc_cache[key] = ret = _monthcalendar(year, month)
!         return ret
  
  def _center(str, width):
!     """Center a string in a field."""
!     n = width - len(str)
!     if n <= 0: return str
!     return ' '*((n+1)/2) + str + ' '*((n)/2)
  
  # XXX The following code knows that print separates items with space!
  
  def prweek(week, width):
!     """Print a single week (no newline)."""
!     for day in week:
!         if day == 0: s = ''
!         else: s = `day`
!         print _center(s, width),
  
  def weekheader(width):
!     """Return a header for a week."""
!     str = ''
!     if width >= 9: names = day_name
!     else: names = day_abbr
!     for i in range(7):
!         if str: str = str + ' '
!         str = str + _center(names[i%7][:width], width)
!     return str
  
  def prmonth(year, month, w = 0, l = 0):
!     """Print a month's calendar."""
!     w = max(2, w)
!     l = max(1, l)
!     print _center(month_name[month] + ' ' + `year`, 7*(w+1) - 1),
!     print '\n'*l,
!     print weekheader(w),
!     print '\n'*l,
!     for week in monthcalendar(year, month):
!         prweek(week, w)
!         print '\n'*l,
  
  # Spacing of month columns
! _colwidth = 7*3 - 1         # Amount printed by prweek()
! _spacing = ' '*4            # Spaces between columns
  
  def format3c(a, b, c):
!     """3-column formatting for year calendars"""
!     print _center(a, _colwidth),
!     print _spacing,
!     print _center(b, _colwidth),
!     print _spacing,
!     print _center(c, _colwidth)
  
  def prcal(year):
!     """Print a year's calendar."""
!     header = weekheader(2)
!     format3c('', `year`, '')
!     for q in range(January, January+12, 3):
!         print
!         format3c(month_name[q], month_name[q+1], month_name[q+2])
!         format3c(header, header, header)
!         data = []
!         height = 0
!         for month in range(q, q+3):
!             cal = monthcalendar(year, month)
!             if len(cal) > height: height = len(cal)
!             data.append(cal)
!         for i in range(height):
!             for cal in data:
!                 if i >= len(cal):
!                     print ' '*_colwidth,
!                 else:
!                     prweek(cal[i], 2)
!                 print _spacing,
!             print
  
  EPOCH = 1970
  def timegm(tuple):
!     """Unrelated but handy function to calculate Unix timestamp from GMT."""
!     year, month, day, hour, minute, second = tuple[:6]
!     assert year >= EPOCH
!     assert 1 <= month <= 12
!     days = 365*(year-EPOCH) + leapdays(EPOCH, year)
!     for i in range(1, month):
!         days = days + mdays[i]
!     if month > 2 and isleap(year):
!         days = days + 1
!     days = days + day - 1
!     hours = days*24 + hour
!     minutes = hours*60 + minute
!     seconds = minutes*60 + second
!     return seconds

Index: binhex.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/binhex.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** binhex.py	1998/03/26 20:34:13	1.10
--- binhex.py	2000/02/02 15:10:14	1.11
***************
*** 1,3 ****
--- 1,4 ----
  """binhex - Macintosh binhex compression/decompression
+ 
  easy interface:
  binhex(inputfilename, outputfilename)
***************
*** 26,30 ****
  import string
  import binascii
! 	
[...982 lines suppressed...]
!         nfinfo.Flags = finfo.Flags
!         ofss.SetFInfo(nfinfo)
!     
!     ifp.close()
  
  def _test():
!     if os.name == 'mac':
!         fss, ok = macfs.PromptGetFile('File to convert:')
!         if not ok:
!             sys.exit(0)
!         fname = fss.as_pathname()
!     else:
!         fname = sys.argv[1]
!     binhex(fname, fname+'.hqx')
!     hexbin(fname+'.hqx', fname+'.viahqx')
!     #hexbin(fname, fname+'.unpacked')
!     sys.exit(1)
!     
  if __name__ == '__main__':
!     _test()

Index: bdb.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/bdb.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** bdb.py	2000/01/19 21:57:30	1.26
--- bdb.py	2000/02/02 15:10:14	1.27
***************
*** 1,3 ****
! # Debugger basics
  
  import sys
--- 1,3 ----
! """Debugger basics"""
  
  import sys
***************
*** 9,474 ****
  
[...1079 lines suppressed...]
!         line = linecache.getline(fn, frame.f_lineno)
!         print '+++', fn, frame.f_lineno, name, ':', string.strip(line)
!     def user_return(self, frame, retval):
!         print '+++ return', retval
!     def user_exception(self, frame, exc_stuff):
!         print '+++ exception', exc_stuff
!         self.set_continue()
  
  def foo(n):
!     print 'foo(', n, ')'
!     x = bar(n*10)
!     print 'bar returned', x
  
  def bar(a):
!     print 'bar(', a, ')'
!     return a/2
  
  def test():
!     t = Tdb()
!     t.run('import bdb; bdb.foo(10)')

Index: base64.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/base64.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** base64.py	2000/01/03 15:44:40	1.8
--- base64.py	2000/02/02 15:10:14	1.9
***************
*** 1,6 ****
  #! /usr/bin/env python
  
! # Conversions to/from base64 transport encoding as per RFC-1521.
! #
  # Modified 04-Oct-95 by Jack to use binascii module
  
--- 1,6 ----
  #! /usr/bin/env python
  
! """Conversions to/from base64 transport encoding as per RFC-1521."""
! 
  # Modified 04-Oct-95 by Jack to use binascii module
  
***************
*** 10,77 ****
  MAXBINSIZE = (MAXLINESIZE/4)*3
  
- # Encode a file.
  def encode(input, output):
! 	while 1:
! 		s = input.read(MAXBINSIZE)
! 		if not s: break
! 		while len(s) < MAXBINSIZE:
! 		    ns = input.read(MAXBINSIZE-len(s))
! 		    if not ns: break
! 		    s = s + ns
! 		line = binascii.b2a_base64(s)
! 		output.write(line)
  
- # Decode a file.
  def decode(input, output):
! 	while 1:
! 		line = input.readline()
! 		if not line: break
! 		s = binascii.a2b_base64(line)
! 		output.write(s)
  
  def encodestring(s):
! 	import StringIO
! 	f = StringIO.StringIO(s)
! 	g = StringIO.StringIO()
! 	encode(f, g)
! 	return g.getvalue()
  
  def decodestring(s):
! 	import StringIO
! 	f = StringIO.StringIO(s)
! 	g = StringIO.StringIO()
! 	decode(f, g)
! 	return g.getvalue()
  
- # Small test program
  def test():
! 	import sys, getopt
! 	try:
! 		opts, args = getopt.getopt(sys.argv[1:], 'deut')
! 	except getopt.error, msg:
! 		sys.stdout = sys.stderr
! 		print msg
! 		print """usage: basd64 [-d] [-e] [-u] [-t] [file|-]
! 		-d, -u: decode
! 		-e: encode (default)
! 		-t: decode string 'Aladdin:open sesame'"""
! 		sys.exit(2)
! 	func = encode
! 	for o, a in opts:
! 		if o == '-e': func = encode
! 		if o == '-d': func = decode
! 		if o == '-u': func = decode
! 		if o == '-t': test1(); return
! 	if args and args[0] != '-':
! 		func(open(args[0], 'rb'), sys.stdout)
! 	else:
! 		func(sys.stdin, sys.stdout)
  
  def test1():
! 	s0 = "Aladdin:open sesame"
! 	s1 = encodestring(s0)
! 	s2 = decodestring(s1)
! 	print s0, `s1`, s2
  
  if __name__ == '__main__':
! 	test()
--- 10,79 ----
  MAXBINSIZE = (MAXLINESIZE/4)*3
  
  def encode(input, output):
!     """Encode a file."""
!     while 1:
!         s = input.read(MAXBINSIZE)
!         if not s: break
!         while len(s) < MAXBINSIZE:
!             ns = input.read(MAXBINSIZE-len(s))
!             if not ns: break
!             s = s + ns
!         line = binascii.b2a_base64(s)
!         output.write(line)
  
  def decode(input, output):
!     """Decode a file."""
!     while 1:
!         line = input.readline()
!         if not line: break
!         s = binascii.a2b_base64(line)
!         output.write(s)
  
  def encodestring(s):
!     """Encode a string."""
!     import StringIO
!     f = StringIO.StringIO(s)
!     g = StringIO.StringIO()
!     encode(f, g)
!     return g.getvalue()
  
  def decodestring(s):
!     """Decode a string."""
!     import StringIO
!     f = StringIO.StringIO(s)
!     g = StringIO.StringIO()
!     decode(f, g)
!     return g.getvalue()
  
  def test():
!     """Small test program"""
!     import sys, getopt
!     try:
!         opts, args = getopt.getopt(sys.argv[1:], 'deut')
!     except getopt.error, msg:
!         sys.stdout = sys.stderr
!         print msg
!         print """usage: basd64 [-d] [-e] [-u] [-t] [file|-]
!         -d, -u: decode
!         -e: encode (default)
!         -t: decode string 'Aladdin:open sesame'"""
!         sys.exit(2)
!     func = encode
!     for o, a in opts:
!         if o == '-e': func = encode
!         if o == '-d': func = decode
!         if o == '-u': func = decode
!         if o == '-t': test1(); return
!     if args and args[0] != '-':
!         func(open(args[0], 'rb'), sys.stdout)
!     else:
!         func(sys.stdin, sys.stdout)
  
  def test1():
!     s0 = "Aladdin:open sesame"
!     s1 = encodestring(s0)
!     s2 = decodestring(s1)
!     print s0, `s1`, s2
  
  if __name__ == '__main__':
!     test()

Index: aifc.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/aifc.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** aifc.py	1999/08/26 15:50:43	1.34
--- aifc.py	2000/02/02 15:10:15	1.35
***************
*** 1,137 ****
! # Stuff to parse AIFF-C and AIFF files.
! #
! # Unless explicitly stated otherwise, the description below is true
! # both for AIFF-C files and AIFF files.
! #
! # An AIFF-C file has the following structure.
! #
! #	+-----------------+
! #	| FORM            |
! #	+-----------------+
[...1887 lines suppressed...]
!     print "Reading", fn
!     print "nchannels =", f.getnchannels()
!     print "nframes   =", f.getnframes()
!     print "sampwidth =", f.getsampwidth()
!     print "framerate =", f.getframerate()
!     print "comptype  =", f.getcomptype()
!     print "compname  =", f.getcompname()
!     if sys.argv[2:]:
!         gn = sys.argv[2]
!         print "Writing", gn
!         g = open(gn, 'w')
!         g.setparams(f.getparams())
!         while 1:
!             data = f.readframes(1024)
!             if not data:
!                 break
!             g.writeframes(data)
!         g.close()
!         f.close()
!         print "Done."