mailr25619 - /trunk/test_suite/shared_data/dispersion/profiling/base.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on September 04, 2014 - 14:34:
Author: bugman
Date: Thu Sep  4 14:34:50 2014
New Revision: 25619

URL: http://svn.gna.org/viewcvs/relax?rev=25619&view=rev
Log:
Copied the dep_check.version_comparison() function into the dispersion model 
profiling base script.

This will be used to provide compatibility between different relax versions 
by allowing the version
numbers to be compared.  The function needs to be copied here as older relax 
versions do not provide
this function.


Modified:
    trunk/test_suite/shared_data/dispersion/profiling/base.py

Modified: trunk/test_suite/shared_data/dispersion/profiling/base.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/test_suite/shared_data/dispersion/profiling/base.py?rev=25619&r1=25618&r2=25619&view=diff
==============================================================================
--- trunk/test_suite/shared_data/dispersion/profiling/base.py   (original)
+++ trunk/test_suite/shared_data/dispersion/profiling/base.py   Thu Sep  4 
14:34:50 2014
@@ -108,6 +108,36 @@
         # Print report for clustered.
         if verbose:
             c_stats.print_stats()
+
+
+def version_comparison(version1, version2):
+    """Compare software versions.
+
+    This will return:
+
+        - When version 1 is older, -1,
+        - When both versions are equal, 0,
+        - When version 1 is newer, 1.
+
+
+    @param version1:    The first version number.
+    @type version1:     str
+    @param version2:    The second version number.
+    @type version2:     str
+    @return:            The comparison result of the Python cmp() function 
applied to two lists of integers.  This will be one of [-1, 0, 1].
+    @type return:       int
+    """
+
+    # Strip out trailing zeros.
+    version1 = sub(r'(\.0+)*$','', version1)
+    version2 = sub(r'(\.0+)*$','', version2)
+
+    # Convert to a list of numbers.
+    version1 = [int(val) for val in version1.split('.')]
+    version2 = [int(val) for val in version2.split('.')]
+
+    # Return the comparison.
+    return cmp(version1, version2)
 
 
 




Related Messages


Powered by MHonArc, Updated Thu Sep 04 15:00:02 2014