[csw-devel] SF.net SVN: gar:[12245] csw/mgar/gar/v2-uwatch2/bin/upstream_watch

wbonnet at users.sourceforge.net wbonnet at users.sourceforge.net
Sat Jan 8 01:25:28 CET 2011


Revision: 12245
          http://gar.svn.sourceforge.net/gar/?rev=12245&view=rev
Author:   wbonnet
Date:     2011-01-08 00:25:27 +0000 (Sat, 08 Jan 2011)

Log Message:
-----------
Sort version list and remove duplicated entries

Modified Paths:
--------------
    csw/mgar/gar/v2-uwatch2/bin/upstream_watch

Modified: csw/mgar/gar/v2-uwatch2/bin/upstream_watch
===================================================================
--- csw/mgar/gar/v2-uwatch2/bin/upstream_watch	2011-01-07 23:57:46 UTC (rev 12244)
+++ csw/mgar/gar/v2-uwatch2/bin/upstream_watch	2011-01-08 00:25:27 UTC (rev 12245)
@@ -578,6 +578,19 @@
 
     # -----------------------------------------------------------------------------------------------------------------
 
+    def compareAndSortVersion(self, a, b):
+        """This function is a wrapper to the comparison function. CompareVersionAndGetNewest returns the string containing
+        the newest version of the two arguments. Since sort method used on list need to have an integer return value, this
+        wrapper do the call to CompareVersionAndGetNewest and returns an int
+        """
+    
+        if self.CompareVersionAndGetNewest(a,b) == a:
+            return 1
+        else:
+            return -1
+
+    # -----------------------------------------------------------------------------------------------------------------
+
     def execute(self, opts, args):
 
         try:
@@ -601,8 +614,15 @@
                 print "No match found, we should trigger some error since even current version has not been found"
                 return False
             else:
+                # Remove duplicated entries
+                myList = []
+                for version in matches:
+                    myList.append(version)
+                l = list(set(myList))
+                l.sort(self.compareAndSortVersion)
+
                 # Print every version in the list
-                for version in matches:
+                for version in l:
                     print version
 
             # Exit after processing, eveythin gis ok, return true to the command processor


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list