[GRASS-SVN] r54767 - grass/trunk/lib/python/script

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 24 23:52:22 PST 2013


Author: huhabla
Date: 2013-01-24 23:52:22 -0800 (Thu, 24 Jan 2013)
New Revision: 54767

Modified:
   grass/trunk/lib/python/script/core.py
Log:
Take special care of the "+towgs84" value list comparison


Modified: grass/trunk/lib/python/script/core.py
===================================================================
--- grass/trunk/lib/python/script/core.py	2013-01-24 09:35:15 UTC (rev 54766)
+++ grass/trunk/lib/python/script/core.py	2013-01-25 07:52:22 UTC (rev 54767)
@@ -660,7 +660,7 @@
 def compare_key_value_text_files(filename_a, filename_b, sep=":",
                                  val_sep=",", precision=0.000001):
     """
-        !Compare two key-value text files that may contain projection parameter
+        !Compare two key-value text files that contain projection parameter
 
         @param filename_a The name of the first key-value text file
         @param filenmae_b The name of the second key-value text file
@@ -685,6 +685,9 @@
     """
     dict_a = _text_to_key_value_dict(filename_a, sep)
     dict_b = _text_to_key_value_dict(filename_b, sep)
+    
+    print dict_a
+    print dict_b
 
     missing_keys = 0
 
@@ -696,7 +699,13 @@
                 if abs(dict_a[key] - dict_b[key]) > precision:
                     return False
             elif isinstance(dict_a[key], float) or isinstance(dict_b[key], float):
-                return False
+                warning(_("Mixing value types. Will try to compare after "
+                          "integer conversion"))
+                return int(dict_a[key]) ==  int(dict_b[key])
+            elif key == "+towgs84":
+                # We compare the sum of the entries
+                if abs(sum(dict_a[key]) - sum(dict_b[key])) > precision:
+                    return False
             else:
                 if dict_a[key] != dict_b[key]:
                     return False



More information about the grass-commit mailing list