subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danie...@apache.org
Subject svn commit: r1871211 - /subversion/trunk/tools/dev/contribulyze.py
Date Thu, 12 Dec 2019 04:03:31 GMT
Author: danielsh
Date: Thu Dec 12 04:03:31 2019
New Revision: 1871211

URL: http://svn.apache.org/viewvc?rev=1871211&view=rev
Log:
contribulyze.py: Support Python 3 in addition to Python 2.

Explicitly specify how to sort lists of Contributor and lists of LogMessage.
In Python 2 instances of those classes are comparable to each other by way of
the __cmp__ member function, but Python 3 does not support that member
function.

An alternative would have been to implement __lt__ and use
functools.total_ordering.

* tools/dev/contribulyze.py
  (functools): Import.
  (Contributor.sort_key): New member function.
  (LogMessage.sort_key): New member function.
  (Contributor.html_out, drop): Specify sorting order.

Modified:
    subversion/trunk/tools/dev/contribulyze.py

Modified: subversion/trunk/tools/dev/contribulyze.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/contribulyze.py?rev=1871211&r1=1871210&r2=1871211&view=diff
==============================================================================
--- subversion/trunk/tools/dev/contribulyze.py (original)
+++ subversion/trunk/tools/dev/contribulyze.py Thu Dec 12 04:03:31 2019
@@ -56,6 +56,7 @@
 # a lot easier to whip up for straight 'svn log' output.  I'd have no
 # objection to it being rewritten to take XML input.
 
+import functools
 import os
 import sys
 import re
@@ -256,6 +257,9 @@ class Contributor(object):
     else:
       return 0 - result
 
+  def sort_key(self):
+      return (self.is_full_committer, self.score(), self.big_name())
+
   @staticmethod
   def parse(name):
     """Parse NAME, which can be
@@ -398,7 +402,7 @@ class Contributor(object):
     out.write('</table>\n\n')
     out.write('</div>\n\n')
 
-    sorted_logs = sorted(unique_logs.keys())
+    sorted_logs = sorted(unique_logs.keys(), key=LogMessage.sort_key)
     for log in sorted_logs:
       out.write('<hr />\n')
       out.write('<div class="h3" id="%s" title="%s">\n' % (log.revision,
@@ -490,6 +494,9 @@ class LogMessage(object):
     if a < b: return 1
     else:     return 0
 
+  def sort_key(self):
+    return int(self.revision[1:])
+
   def __str__(self):
     s = '=' * 15
     header = ' LOG: %s | %s ' % (self.revision, self.committer)
@@ -661,7 +668,8 @@ def drop(revision_url_pattern):
   # sort by number of contributions, so the most active people appear at
   # the top -- that way we know whom to look at first for commit access
   # proposals.
-  sorted_contributors = sorted(Contributor.all_contributors.values())
+  sorted_contributors = sorted(Contributor.all_contributors.values(),
+                               key = Contributor.sort_key)
   for c in sorted_contributors:
     if c not in seen_contributors:
       if c.score() > 0:



Mime
View raw message