[Python-checkins] python/dist/src/Lib SimpleHTTPServer.py, 1.19, 1.20 UserList.py, 1.19, 1.20 _strptime.py, 1.27, 1.28 difflib.py, 1.16, 1.17 inspect.py, 1.47, 1.48 pydoc.py, 1.87, 1.88 sre_constants.py, 1.32, 1.33

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Thu Oct 16 01:53:18 EDT 2003


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

Modified Files:
	SimpleHTTPServer.py UserList.py _strptime.py difflib.py 
	inspect.py pydoc.py sre_constants.py 
Log Message:
Let library modules use the new keyword arguments for list.sort().



Index: SimpleHTTPServer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/SimpleHTTPServer.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** SimpleHTTPServer.py	1 Jun 2002 14:18:45 -0000	1.19
--- SimpleHTTPServer.py	16 Oct 2003 05:53:16 -0000	1.20
***************
*** 100,104 ****
              self.send_error(404, "No permission to list directory")
              return None
!         list.sort(lambda a, b: cmp(a.lower(), b.lower()))
          f = StringIO()
          f.write("<title>Directory listing for %s</title>\n" % self.path)
--- 100,104 ----
              self.send_error(404, "No permission to list directory")
              return None
!         list.sort(key=lambda a: a.lower())
          f = StringIO()
          f.write("<title>Directory listing for %s</title>\n" % self.path)

Index: UserList.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/UserList.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** UserList.py	17 Jun 2003 05:05:49 -0000	1.19
--- UserList.py	16 Oct 2003 05:53:16 -0000	1.20
***************
*** 78,82 ****
      def index(self, item, *args): return self.data.index(item, *args)
      def reverse(self): self.data.reverse()
!     def sort(self, *args): self.data.sort(*args)
      def extend(self, other):
          if isinstance(other, UserList):
--- 78,82 ----
      def index(self, item, *args): return self.data.index(item, *args)
      def reverse(self): self.data.reverse()
!     def sort(self, *args, **kwds): self.data.sort(*args, **kwds)
      def extend(self, other):
          if isinstance(other, UserList):

Index: _strptime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/_strptime.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** _strptime.py	29 Aug 2003 02:28:53 -0000	1.27
--- _strptime.py	16 Oct 2003 05:53:16 -0000	1.28
***************
*** 53,57 ****
      def __init__(self):
          """Set all attributes.
!         
          Order of methods called matters for dependency reasons.
  
--- 53,57 ----
      def __init__(self):
          """Set all attributes.
! 
          Order of methods called matters for dependency reasons.
  
***************
*** 69,73 ****
          not call tz.tzset .  That is an issue for the programmer, though,
          since changing the timezone is worthless without that call.
!         
          """
          self.lang = _getlang()
--- 69,73 ----
          not call tz.tzset .  That is an issue for the programmer, though,
          since changing the timezone is worthless without that call.
! 
          """
          self.lang = _getlang()
***************
*** 156,160 ****
          self.LC_date_time = date_time[0]
          self.LC_date = date_time[1]
!         self.LC_time = date_time[2] 
  
      def __calc_timezone(self):
--- 156,160 ----
          self.LC_date_time = date_time[0]
          self.LC_date = date_time[1]
!         self.LC_time = date_time[2]
  
      def __calc_timezone(self):
***************
*** 179,185 ****
      def __init__(self, locale_time=None):
          """Create keys/values.
!         
          Order of execution is important for dependency reasons.
!         
          """
          if locale_time:
--- 179,185 ----
      def __init__(self, locale_time=None):
          """Create keys/values.
! 
          Order of execution is important for dependency reasons.
! 
          """
          if locale_time:
***************
*** 220,229 ****
      def __seqToRE(self, to_convert, directive):
          """Convert a list to a regex string for matching a directive.
!         
          Want possible matching values to be from longest to shortest.  This
          prevents the possibility of a match occuring for a value that also
          a substring of a larger value that should have matched (e.g., 'abc'
          matching when 'abcdef' should have been the match).
!         
          """
          for value in to_convert:
--- 220,229 ----
      def __seqToRE(self, to_convert, directive):
          """Convert a list to a regex string for matching a directive.
! 
          Want possible matching values to be from longest to shortest.  This
          prevents the possibility of a match occuring for a value that also
          a substring of a larger value that should have matched (e.g., 'abc'
          matching when 'abcdef' should have been the match).
! 
          """
          for value in to_convert:
***************
*** 232,239 ****
          else:
              return ''
!         to_sort = [(len(item), item) for item in to_convert]
!         to_sort.sort()
!         to_sort.reverse()
!         to_convert = [item for length, item in to_sort]
          regex = '|'.join(to_convert)
          regex = '(?P<%s>%s' % (directive, regex)
--- 232,237 ----
          else:
              return ''
!         to_convert = to_convert[:]
!         to_convert.sort(key=len, reverse=True)
          regex = '|'.join(to_convert)
          regex = '(?P<%s>%s' % (directive, regex)

Index: difflib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/difflib.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** difflib.py	16 Jul 2003 04:32:32 -0000	1.16
--- difflib.py	16 Oct 2003 05:53:16 -0000	1.17
***************
*** 702,714 ****
             s.ratio() >= cutoff:
              result.append((s.ratio(), x))
-     # Sort by score.
-     result.sort()
-     # Retain only the best n.
-     result = result[-n:]
-     # Move best-scorer to head of list.
-     result.reverse()
-     # Strip scores.
-     return [x for score, x in result]
  
  
  def _count_leading(line, ch):
--- 702,710 ----
             s.ratio() >= cutoff:
              result.append((s.ratio(), x))
  
+     # Move the best scorers to head of list
+     result.sort(reverse=True)
+     # Strip scores for the best n matches
+     return [x for score, x in result[:n]]
  
  def _count_leading(line, ch):

Index: inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** inspect.py	29 Jun 2003 05:46:53 -0000	1.47
--- inspect.py	16 Oct 2003 05:53:16 -0000	1.48
***************
*** 554,558 ****
      """Recursive helper function for getclasstree()."""
      results = []
!     classes.sort(lambda a, b: cmp(a.__name__, b.__name__))
      for c in classes:
          results.append((c, c.__bases__))
--- 554,558 ----
      """Recursive helper function for getclasstree()."""
      results = []
!     classes.sort(key=lambda c: c.__name__)
      for c in classes:
          results.append((c, c.__bases__))

Index: pydoc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v
retrieving revision 1.87
retrieving revision 1.88
diff -C2 -d -r1.87 -r1.88
*** pydoc.py	10 Sep 2003 16:47:51 -0000	1.87
--- pydoc.py	16 Oct 2003 05:53:16 -0000	1.88
***************
*** 780,784 ****
  
              # Sort attrs by name.
!             attrs.sort(lambda t1, t2: cmp(t1[0], t2[0]))
  
              # Pump out the attrs, segregated by kind.
--- 780,784 ----
  
              # Sort attrs by name.
!             attrs.sort(key=lambda t: t[0])
  
              # Pump out the attrs, segregated by kind.

Index: sre_constants.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** sre_constants.py	19 Apr 2003 12:56:07 -0000	1.32
--- sre_constants.py	16 Oct 2003 05:53:16 -0000	1.33
***************
*** 220,224 ****
      def dump(f, d, prefix):
          items = d.items()
!         items.sort(lambda a, b: cmp(a[1], b[1]))
          for k, v in items:
              f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v))
--- 220,224 ----
      def dump(f, d, prefix):
          items = d.items()
!         items.sort(key=lambda a: a[1])
          for k, v in items:
              f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v))





More information about the Python-checkins mailing list