[GRASS-SVN] r53435 - grass/trunk/lib/python/temporal

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 17 04:00:34 PDT 2012


Author: huhabla
Date: 2012-10-17 04:00:34 -0700 (Wed, 17 Oct 2012)
New Revision: 53435

Modified:
   grass/trunk/lib/python/temporal/abstract_map_dataset.py
   grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
   grass/trunk/lib/python/temporal/datetime_math.py
   grass/trunk/lib/python/temporal/space_time_datasets.py
Log:
Removed dateutil dependency. Now only a subset of ISO formatted time strings are supported for parsing in the temporal GIS framework.


Modified: grass/trunk/lib/python/temporal/abstract_map_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_map_dataset.py	2012-10-16 19:54:20 UTC (rev 53434)
+++ grass/trunk/lib/python/temporal/abstract_map_dataset.py	2012-10-17 11:00:34 UTC (rev 53435)
@@ -540,7 +540,7 @@
         if self.get_type() == "raster3d":
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
-            print " +-------------------- Raster3d Dataset --------------------------------------+"
+            print " +-------------------- 3D Raster Dataset -------------------------------------+"
         if self.get_type() == "vector":
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678

Modified: grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2012-10-16 19:54:20 UTC (rev 53434)
+++ grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2012-10-17 11:00:34 UTC (rev 53435)
@@ -80,7 +80,7 @@
         if self.get_type() == "str3ds":
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
-            print " +-------------------- Space Time Raster3d Dataset ---------------------------+"
+            print " +-------------------- Space Time 3D Raster Dataset --------------------------+"
         if self.get_type() == "stvds":
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678

Modified: grass/trunk/lib/python/temporal/datetime_math.py
===================================================================
--- grass/trunk/lib/python/temporal/datetime_math.py	2012-10-16 19:54:20 UTC (rev 53434)
+++ grass/trunk/lib/python/temporal/datetime_math.py	2012-10-17 11:00:34 UTC (rev 53435)
@@ -14,7 +14,6 @@
 from datetime import datetime, date, time, timedelta
 import grass.script.core as core
 import copy
-from dateutil import parser
 
 DAY_IN_SECONDS = 86400
 SECOND_AS_DAY = 1.1574074074074073e-05
@@ -551,8 +550,17 @@
 
 
 def string_to_datetime(time_string):
-    """!Convert a string into a datetime object using the dateutil parser. 
-       Return None in case of failure"""
+    """!Convert a string into a datetime object 
+    
+        Supported ISO string formats are: 
+        - YYYY-mm-dd
+        - YYYY-mm-dd HH:MM:SS
+        
+        Time zones are not supported
+        
+        @param time_string: The time string to convert
+        @return datetime object or None in case of an error
+    """
 
     # BC is not supported
     if time_string.find("bc") > 0:
@@ -560,12 +568,24 @@
                    "in the temporal database")
         return None
 
+    # BC is not supported
+    if time_string.find("+") > 0:
+        core.error("Time zones are not supported "
+                   "in the temporal database")
+        return None
+        
+    if time_string.find(":") > 0:
+        time_format = "%Y-%m-%d %H:%M:%S"
+    else:
+        time_format = "%Y-%m-%d"
+  
     try:
-        dt = parser.parse(time_string)
-        return dt
+        return  datetime.strptime(time_string, time_format)
     except:
+        core.error("Unable to parse time string: %s"%time_string)
         return None
 
+
 ###############################################################################
 
 

Modified: grass/trunk/lib/python/temporal/space_time_datasets.py
===================================================================
--- grass/trunk/lib/python/temporal/space_time_datasets.py	2012-10-16 19:54:20 UTC (rev 53434)
+++ grass/trunk/lib/python/temporal/space_time_datasets.py	2012-10-17 11:00:34 UTC (rev 53435)
@@ -542,7 +542,7 @@
         # Get the data from an existing 3D raster map
         global use_ctypes_map_access
 
-	if use_ctypes_map_access:
+        if use_ctypes_map_access:
             kvp = self.read_info()
         else:
             kvp = raster3d.raster3d_info(self.get_id())



More information about the grass-commit mailing list