瀏覽代碼

temporal: make temporal python library importable from python3

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@68139 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 9 年之前
父節點
當前提交
9366bd5dcf
共有 34 個文件被更改,包括 871 次插入861 次删除
  1. 35 33
      lib/python/temporal/__init__.py
  2. 5 5
      lib/python/temporal/abstract_dataset.py
  3. 18 17
      lib/python/temporal/abstract_map_dataset.py
  4. 13 12
      lib/python/temporal/abstract_space_time_dataset.py
  5. 4 4
      lib/python/temporal/aggregation.py
  6. 32 32
      lib/python/temporal/base.py
  7. 18 18
      lib/python/temporal/c_libraries_interface.py
  8. 5 5
      lib/python/temporal/core.py
  9. 3 3
      lib/python/temporal/datetime_math.py
  10. 6 6
      lib/python/temporal/extract.py
  11. 1 1
      lib/python/temporal/factory.py
  12. 2 2
      lib/python/temporal/gui_support.py
  13. 11 11
      lib/python/temporal/list_stds.py
  14. 2 2
      lib/python/temporal/mapcalc.py
  15. 128 127
      lib/python/temporal/metadata.py
  16. 2 2
      lib/python/temporal/open_stds.py
  17. 1 1
      lib/python/temporal/register.py
  18. 4 4
      lib/python/temporal/sampling.py
  19. 2 2
      lib/python/temporal/space_time_datasets.py
  20. 15 14
      lib/python/temporal/spatial_extent.py
  21. 31 30
      lib/python/temporal/spatial_topology_dataset_connector.py
  22. 2 2
      lib/python/temporal/spatio_temporal_relationships.py
  23. 4 4
      lib/python/temporal/stds_export.py
  24. 5 5
      lib/python/temporal/stds_import.py
  25. 158 157
      lib/python/temporal/temporal_algebra.py
  26. 22 21
      lib/python/temporal/temporal_extent.py
  27. 25 25
      lib/python/temporal/temporal_granularity.py
  28. 37 36
      lib/python/temporal/temporal_operator.py
  29. 2 4
      lib/python/temporal/temporal_raster3d_algebra.py
  30. 3 3
      lib/python/temporal/temporal_raster_algebra.py
  31. 183 183
      lib/python/temporal/temporal_raster_base_algebra.py
  32. 50 49
      lib/python/temporal/temporal_topology_dataset_connector.py
  33. 36 36
      lib/python/temporal/temporal_vector_algebra.py
  34. 6 5
      lib/python/temporal/univar_statistics.py

+ 35 - 33
lib/python/temporal/__init__.py

@@ -1,33 +1,35 @@
-from core import *
-from base import *
-from spatial_extent import *
-from metadata import *
-from abstract_dataset import *
-from abstract_map_dataset import *
-from abstract_space_time_dataset import *
-from space_time_datasets import *
-from datetime_math import *
-from open_stds import *
-from factory import *
-from gui_support import *
-from list_stds import *
-from register import *
-from sampling import *
-from aggregation import *
-from extract import *
-from stds_export import *
-from stds_import import *
-from mapcalc import *
-from univar_statistics import *
-from c_libraries_interface import *
-from spatio_temporal_relationships import *
-from spatial_topology_dataset_connector import *
-from temporal_extent import *
-from temporal_topology_dataset_connector import *
-from temporal_granularity import *
-from temporal_algebra import *
-from temporal_vector_algebra import *
-from temporal_raster_base_algebra import *
-from temporal_raster_algebra import *
-from temporal_raster3d_algebra import *
-from temporal_operator import *
+from __future__ import (absolute_import)
+
+from .core import *
+from .base import *
+from .spatial_extent import *
+from .metadata import *
+from .abstract_dataset import *
+from .abstract_map_dataset import *
+from .abstract_space_time_dataset import *
+from .space_time_datasets import *
+from .datetime_math import *
+from .open_stds import *
+from .factory import *
+from .gui_support import *
+from .list_stds import *
+from .register import *
+from .sampling import *
+from .aggregation import *
+from .extract import *
+from .stds_export import *
+from .stds_import import *
+from .mapcalc import *
+from .univar_statistics import *
+from .c_libraries_interface import *
+from .spatio_temporal_relationships import *
+from .spatial_topology_dataset_connector import *
+from .temporal_extent import *
+from .temporal_topology_dataset_connector import *
+from .temporal_granularity import *
+from .temporal_algebra import *
+from .temporal_vector_algebra import *
+from .temporal_raster_base_algebra import *
+from .temporal_raster_algebra import *
+from .temporal_raster3d_algebra import *
+from .temporal_operator import *

+ 5 - 5
lib/python/temporal/abstract_dataset.py

@@ -11,11 +11,11 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 from abc import ABCMeta, abstractmethod
 from abc import ABCMeta, abstractmethod
-from temporal_extent import *
-from spatial_extent import *
-from metadata import *
-from temporal_topology_dataset_connector import *
-from spatial_topology_dataset_connector import *
+from .temporal_extent import *
+from .spatial_extent import *
+from .metadata import *
+from .temporal_topology_dataset_connector import *
+from .spatial_topology_dataset_connector import *
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 18 - 17
lib/python/temporal/abstract_map_dataset.py

@@ -10,8 +10,9 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-from abstract_dataset import *
-from datetime_math import *
+from __future__ import print_function
+from .abstract_dataset import *
+from .datetime_math import *
 
 
 
 
 class AbstractMapDataset(AbstractDataset):
 class AbstractMapDataset(AbstractDataset):
@@ -199,16 +200,16 @@ class AbstractMapDataset(AbstractDataset):
         if self.get_type() == "raster":
         if self.get_type() == "raster":
             #                1         2         3         4         5         6         7
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
-            print " +-------------------- Raster Dataset ----------------------------------------+"
+            print(" +-------------------- Raster Dataset ----------------------------------------+")
         if self.get_type() == "raster3d":
         if self.get_type() == "raster3d":
             #                1         2         3         4         5         6         7
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
-            print " +-------------------- 3D Raster Dataset -------------------------------------+"
+            print(" +-------------------- 3D Raster Dataset -------------------------------------+")
         if self.get_type() == "vector":
         if self.get_type() == "vector":
             #                1         2         3         4         5         6         7
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
-            print " +-------------------- Vector Dataset ----------------------------------------+"
-        print " |                                                                            |"
+            print(" +-------------------- Vector Dataset ----------------------------------------+")
+        print(" |                                                                            |")
         self.base.print_info()
         self.base.print_info()
         self.temporal_extent.print_info()
         self.temporal_extent.print_info()
         if self.is_topology_build():
         if self.is_topology_build():
@@ -228,8 +229,8 @@ class AbstractMapDataset(AbstractDataset):
                 else:
                 else:
                     string += ",%s" % ds
                     string += ",%s" % ds
                 count += 1
                 count += 1
-        print " | Registered datasets ........ " + string
-        print " +----------------------------------------------------------------------------+"
+        print(" | Registered datasets ........ " + string)
+        print(" +----------------------------------------------------------------------------+")
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this object in shell style"""
         """Print information about this object in shell style"""
@@ -247,7 +248,7 @@ class AbstractMapDataset(AbstractDataset):
                 else:
                 else:
                     string += ",%s" % ds
                     string += ",%s" % ds
                 count += 1
                 count += 1
-            print "registered_datasets=" + string
+            print("registered_datasets=" + string)
 
 
         if self.is_topology_build():
         if self.is_topology_build():
             self.print_topology_shell_info()
             self.print_topology_shell_info()
@@ -539,25 +540,25 @@ class AbstractMapDataset(AbstractDataset):
                >>> map      = tgis.RasterDataset(None)
                >>> map      = tgis.RasterDataset(None)
                >>> temp_ext = tgis.RasterRelativeTime(start_time=1, end_time=2, unit="years")
                >>> temp_ext = tgis.RasterRelativeTime(start_time=1, end_time=2, unit="years")
                >>> map.set_temporal_extent(temp_ext)
                >>> map.set_temporal_extent(temp_ext)
-               >>> print map.get_temporal_extent_as_tuple()
+               >>> print(map.get_temporal_extent_as_tuple())
                (1, 2)
                (1, 2)
                >>> map      = tgis.VectorDataset(None)
                >>> map      = tgis.VectorDataset(None)
                >>> temp_ext = tgis.VectorAbsoluteTime(start_time=datetime.datetime(2000, 1, 1),
                >>> temp_ext = tgis.VectorAbsoluteTime(start_time=datetime.datetime(2000, 1, 1),
                ...                                        end_time=datetime.datetime(2001, 1, 1))
                ...                                        end_time=datetime.datetime(2001, 1, 1))
                >>> map.set_temporal_extent(temp_ext)
                >>> map.set_temporal_extent(temp_ext)
-               >>> print map.get_temporal_extent_as_tuple()
+               >>> print(map.get_temporal_extent_as_tuple())
                (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
                (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
 
 
                >>> map1 = tgis.VectorDataset("A@P")
                >>> map1 = tgis.VectorDataset("A@P")
                >>> check = map1.set_absolute_time(datetime.datetime(2000,5,5), datetime.datetime(2005,6,6))
                >>> check = map1.set_absolute_time(datetime.datetime(2000,5,5), datetime.datetime(2005,6,6))
-               >>> print map1.get_temporal_extent_as_tuple()
+               >>> print(map1.get_temporal_extent_as_tuple())
                (datetime.datetime(2000, 5, 5, 0, 0), datetime.datetime(2005, 6, 6, 0, 0))
                (datetime.datetime(2000, 5, 5, 0, 0), datetime.datetime(2005, 6, 6, 0, 0))
                >>> map2 = tgis.RasterDataset("B@P")
                >>> map2 = tgis.RasterDataset("B@P")
                >>> check = map2.set_absolute_time(datetime.datetime(1990,1,1), datetime.datetime(1999,8,1))
                >>> check = map2.set_absolute_time(datetime.datetime(1990,1,1), datetime.datetime(1999,8,1))
-               >>> print map2.get_temporal_extent_as_tuple()
+               >>> print(map2.get_temporal_extent_as_tuple())
                (datetime.datetime(1990, 1, 1, 0, 0), datetime.datetime(1999, 8, 1, 0, 0))
                (datetime.datetime(1990, 1, 1, 0, 0), datetime.datetime(1999, 8, 1, 0, 0))
                >>> map2.set_temporal_extent(map1.get_temporal_extent())
                >>> map2.set_temporal_extent(map1.get_temporal_extent())
-               >>> print map2.get_temporal_extent_as_tuple()
+               >>> print(map2.get_temporal_extent_as_tuple())
                (datetime.datetime(2000, 5, 5, 0, 0), datetime.datetime(2005, 6, 6, 0, 0))
                (datetime.datetime(2000, 5, 5, 0, 0), datetime.datetime(2005, 6, 6, 0, 0))
 
 
         """
         """
@@ -710,7 +711,7 @@ class AbstractMapDataset(AbstractDataset):
                >>> map      = tgis.RasterDataset(None)
                >>> map      = tgis.RasterDataset(None)
                >>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
                >>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
                >>> map.set_spatial_extent(spat_ext)
                >>> map.set_spatial_extent(spat_ext)
-               >>> print map.get_spatial_extent_as_tuple()
+               >>> print(map.get_spatial_extent_as_tuple())
                (10.0, -10.0, 20.0, -20.0, 5.0, -5.0)
                (10.0, -10.0, 20.0, -20.0, 5.0, -5.0)
 
 
         """
         """
@@ -729,7 +730,7 @@ class AbstractMapDataset(AbstractDataset):
                >>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
                >>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
                >>> map.set_spatial_extent(spat_ext)
                >>> map.set_spatial_extent(spat_ext)
                >>> map.spatial_buffer(10)
                >>> map.spatial_buffer(10)
-               >>> print map.get_spatial_extent_as_tuple()
+               >>> print(map.get_spatial_extent_as_tuple())
                (20.0, -20.0, 30.0, -30.0, 15.0, -15.0)
                (20.0, -20.0, 30.0, -30.0, 15.0, -15.0)
 
 
         """
         """
@@ -756,7 +757,7 @@ class AbstractMapDataset(AbstractDataset):
                >>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
                >>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
                >>> map.set_spatial_extent(spat_ext)
                >>> map.set_spatial_extent(spat_ext)
                >>> map.spatial_buffer_2d(10)
                >>> map.spatial_buffer_2d(10)
-               >>> print map.get_spatial_extent_as_tuple()
+               >>> print(map.get_spatial_extent_as_tuple())
                (20.0, -20.0, 30.0, -30.0, 5.0, -5.0)
                (20.0, -20.0, 30.0, -30.0, 5.0, -5.0)
 
 
         """
         """

+ 13 - 12
lib/python/temporal/abstract_space_time_dataset.py

@@ -10,11 +10,12 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
+from __future__ import print_function
 import sys
 import sys
 import uuid
 import uuid
-from abstract_dataset import *
-from temporal_granularity import *
-from spatio_temporal_relationships import *
+from .abstract_dataset import *
+from .temporal_granularity import *
+from .spatio_temporal_relationships import *
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -98,21 +99,21 @@ class AbstractSpaceTimeDataset(AbstractDataset):
         if self.get_type() == "strds":
         if self.get_type() == "strds":
             #                1         2         3         4         5         6         7
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
-            print " +-------------------- Space Time Raster Dataset -----------------------------+"
+            print(" +-------------------- Space Time Raster Dataset -----------------------------+")
         if self.get_type() == "str3ds":
         if self.get_type() == "str3ds":
             #                1         2         3         4         5         6         7
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
-            print " +-------------------- Space Time 3D Raster Dataset --------------------------+"
+            print(" +-------------------- Space Time 3D Raster Dataset --------------------------+")
         if self.get_type() == "stvds":
         if self.get_type() == "stvds":
             #                1         2         3         4         5         6         7
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
-            print " +-------------------- Space Time Vector Dataset -----------------------------+"
-        print " |                                                                            |"
+            print(" +-------------------- Space Time Vector Dataset -----------------------------+")
+        print(" |                                                                            |")
         self.base.print_info()
         self.base.print_info()
         self.temporal_extent.print_info()
         self.temporal_extent.print_info()
         self.spatial_extent.print_info()
         self.spatial_extent.print_info()
         self.metadata.print_info()
         self.metadata.print_info()
-        print " +----------------------------------------------------------------------------+"
+        print(" +----------------------------------------------------------------------------+")
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
@@ -1137,7 +1138,7 @@ class AbstractSpaceTimeDataset(AbstractDataset):
                 ...     maps.append(map)
                 ...     maps.append(map)
                 >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,8,1)
                 >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,8,1)
                 >>> for map_list in grans:
                 >>> for map_list in grans:
-                ...    print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
+                ...    print(map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple())
                 None (0, 1)
                 None (0, 1)
                 None (1, 2)
                 None (1, 2)
                 map0@PERMANENT (2, 3)
                 map0@PERMANENT (2, 3)
@@ -1156,7 +1157,7 @@ class AbstractSpaceTimeDataset(AbstractDataset):
                 >>> maps.append(map2)
                 >>> maps.append(map2)
                 >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,16,2)
                 >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,16,2)
                 >>> for map_list in grans:
                 >>> for map_list in grans:
-                ...    print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
+                ...    print(map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple())
                 None (0, 2)
                 None (0, 2)
                 map1@PERMANENT (2, 4)
                 map1@PERMANENT (2, 4)
                 map1@PERMANENT (4, 6)
                 map1@PERMANENT (4, 6)
@@ -1175,7 +1176,7 @@ class AbstractSpaceTimeDataset(AbstractDataset):
                 >>> maps.append(map2)
                 >>> maps.append(map2)
                 >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,16,2)
                 >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,16,2)
                 >>> for map_list in grans:
                 >>> for map_list in grans:
-                ...    print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
+                ...    print(map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple())
                 None (0, 2)
                 None (0, 2)
                 map1@PERMANENT (2, 4)
                 map1@PERMANENT (2, 4)
                 None (4, 6)
                 None (4, 6)
@@ -1194,7 +1195,7 @@ class AbstractSpaceTimeDataset(AbstractDataset):
                 >>> maps.append(map2)
                 >>> maps.append(map2)
                 >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,datetime(2000,1,1),datetime(2001,4,1),"1 month")
                 >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,datetime(2000,1,1),datetime(2001,4,1),"1 month")
                 >>> for map_list in grans:
                 >>> for map_list in grans:
-                ...    print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
+                ...    print(map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple())
                 None (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 2, 1, 0, 0))
                 None (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 2, 1, 0, 0))
                 None (datetime.datetime(2000, 2, 1, 0, 0), datetime.datetime(2000, 3, 1, 0, 0))
                 None (datetime.datetime(2000, 2, 1, 0, 0), datetime.datetime(2000, 3, 1, 0, 0))
                 None (datetime.datetime(2000, 3, 1, 0, 0), datetime.datetime(2000, 4, 1, 0, 0))
                 None (datetime.datetime(2000, 3, 1, 0, 0), datetime.datetime(2000, 4, 1, 0, 0))

+ 4 - 4
lib/python/temporal/aggregation.py

@@ -17,10 +17,10 @@ for details.
 :author: Soeren Gebbert
 :author: Soeren Gebbert
 """
 """
 
 
-from space_time_datasets import *
-from datetime_math import create_suffix_from_datetime
-from datetime_math import create_time_suffix
-from datetime_math import create_numeric_suffic
+from .space_time_datasets import *
+from .datetime_math import create_suffix_from_datetime
+from .datetime_math import create_time_suffix
+from .datetime_math import create_numeric_suffic
 import grass.script as gscript
 import grass.script as gscript
 from grass.exceptions import CalledModuleError
 from grass.exceptions import CalledModuleError
 
 

+ 32 - 32
lib/python/temporal/base.py

@@ -24,9 +24,9 @@ for details.
 
 
 :author: Soeren Gebbert
 :author: Soeren Gebbert
 """
 """
-
+from __future__ import print_function
 from datetime import datetime
 from datetime import datetime
-from core import *
+from .core import *
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -186,7 +186,7 @@ class DictSQLSerializer(object):
     def print_self(self):
     def print_self(self):
         """Print the content of the internal dictionary to stdout
         """Print the content of the internal dictionary to stdout
         """
         """
-        print self.D
+        print(self.D)
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -276,7 +276,7 @@ class SQLDatabaseInterface(DictSQLSerializer):
                         if None a temporary connection will be established
                         if None a temporary connection will be established
         """
         """
         sql = self.get_delete_statement()
         sql = self.get_delete_statement()
-        #print sql
+        #print(sql)
 
 
         if dbif:
         if dbif:
             dbif.execute(sql,   mapset=self.mapset)
             dbif.execute(sql,   mapset=self.mapset)
@@ -350,8 +350,8 @@ class SQLDatabaseInterface(DictSQLSerializer):
                         if None a temporary connection will be established
                         if None a temporary connection will be established
         """
         """
         sql, args = self.get_select_statement()
         sql, args = self.get_select_statement()
-        #print sql
-        #print args
+        #print(sql)
+        #print(args)
 
 
         if dbif:
         if dbif:
             if len(args) == 0:
             if len(args) == 0:
@@ -408,8 +408,8 @@ class SQLDatabaseInterface(DictSQLSerializer):
                         if None a temporary connection will be established
                         if None a temporary connection will be established
         """
         """
         sql, args = self.get_insert_statement()
         sql, args = self.get_insert_statement()
-        #print sql
-        #print args
+        #print(sql)
+        #print(args)
 
 
         if dbif:
         if dbif:
             dbif.execute(sql, args, mapset=self.mapset)
             dbif.execute(sql, args, mapset=self.mapset)
@@ -462,8 +462,8 @@ class SQLDatabaseInterface(DictSQLSerializer):
             self.msgr.fatal(_("Missing identifer"))
             self.msgr.fatal(_("Missing identifer"))
 
 
         sql, args = self.get_update_statement(ident)
         sql, args = self.get_update_statement(ident)
-        #print sql
-        #print args
+        #print(sql)
+        #print(args)
 
 
         if dbif:
         if dbif:
             dbif.execute(sql, args, mapset=self.mapset)
             dbif.execute(sql, args, mapset=self.mapset)
@@ -513,8 +513,8 @@ class SQLDatabaseInterface(DictSQLSerializer):
             self.msgr.fatal(_("Missing identifer"))
             self.msgr.fatal(_("Missing identifer"))
 
 
         sql, args = self.get_update_all_statement(ident)
         sql, args = self.get_update_all_statement(ident)
-        #print sql
-        #print args
+        #print(sql)
+        #print(args)
 
 
         if dbif:
         if dbif:
             dbif.execute(sql, args, mapset=self.mapset)
             dbif.execute(sql, args, mapset=self.mapset)
@@ -766,26 +766,26 @@ class DatasetBase(SQLDatabaseInterface):
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " +-------------------- Basic information -------------------------------------+"
-        print " | Id: ........................ " + str(self.get_id())
-        print " | Name: ...................... " + str(self.get_name())
-        print " | Mapset: .................... " + str(self.get_mapset())
+        print( " +-------------------- Basic information -------------------------------------+")
+        print( " | Id: ........................ " + str(self.get_id()))
+        print(" | Name: ...................... " + str(self.get_name()))
+        print(" | Mapset: .................... " + str(self.get_mapset()))
         if self.get_layer():
         if self.get_layer():
-            print " | Layer:...................... " + str(self.get_layer())
-        print " | Creator: ................... " + str(self.get_creator())
-        print " | Temporal type: ............. " + str(self.get_ttype())
-        print " | Creation time: ............. " + str(self.get_ctime())
+            print(" | Layer:...................... " + str(self.get_layer()))
+        print(" | Creator: ................... " + str(self.get_creator()))
+        print(" | Temporal type: ............. " + str(self.get_ttype()))
+        print(" | Creation time: ............. " + str(self.get_ctime()))
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
-        print "id=" + str(self.get_id())
-        print "name=" + str(self.get_name())
-        print "mapset=" + str(self.get_mapset())
+        print("id=" + str(self.get_id()))
+        print("name=" + str(self.get_name()))
+        print("mapset=" + str(self.get_mapset()))
         if self.get_layer():
         if self.get_layer():
-            print "layer=" + str(self.get_layer())
-        print "creator=" + str(self.get_creator())
-        print "temporal_type=" + str(self.get_ttype())
-        print "creation_time=" + str(self.get_ctime())
+            print("layer=" + str(self.get_layer()))
+        print("creator=" + str(self.get_creator()))
+        print("temporal_type=" + str(self.get_ttype()))
+        print("creation_time=" + str(self.get_ctime()))
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -912,15 +912,15 @@ class STDSBase(DatasetBase):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
         DatasetBase.print_info(self)
         DatasetBase.print_info(self)
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " | Modification time:.......... " + str(self.get_mtime())
-        print " | Semantic type:.............. " + str(
-            self.get_semantic_type())
+        print(" | Modification time:.......... " + str(self.get_mtime()))
+        print(" | Semantic type:.............. " + str(
+            self.get_semantic_type()))
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
         DatasetBase.print_shell_info(self)
         DatasetBase.print_shell_info(self)
-        print "modification_time=" + str(self.get_mtime())
-        print "semantic_type=" + str(self.get_semantic_type())
+        print("modification_time=" + str(self.get_mtime()))
+        print("semantic_type=" + str(self.get_semantic_type()))
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 18 - 18
lib/python/temporal/c_libraries_interface.py

@@ -18,7 +18,7 @@ import sys
 from multiprocessing import Process, Lock, Pipe
 from multiprocessing import Process, Lock, Pipe
 import logging
 import logging
 from ctypes import *
 from ctypes import *
-from core import *
+from .core import *
 import grass.lib.gis as libgis
 import grass.lib.gis as libgis
 import grass.lib.raster as libraster
 import grass.lib.raster as libraster
 import grass.lib.vector as libvector
 import grass.lib.vector as libvector
@@ -59,7 +59,7 @@ class RPCDefs(object):
 
 
 
 
 def _read_map_full_info(lock, conn, data):
 def _read_map_full_info(lock, conn, data):
-    """Read full map specific metadata from the spatial database using 
+    """Read full map specific metadata from the spatial database using
        PyGRASS functions.
        PyGRASS functions.
 
 
        :param lock: A multiprocessing.Lock instance
        :param lock: A multiprocessing.Lock instance
@@ -85,21 +85,21 @@ def _read_map_full_info(lock, conn, data):
 
 
 def _read_raster_full_info(name, mapset):
 def _read_raster_full_info(name, mapset):
     """Read raster info, history and cats using PyGRASS RasterRow
     """Read raster info, history and cats using PyGRASS RasterRow
-       and return a dictionary. Colors should be supported in the 
+       and return a dictionary. Colors should be supported in the
        future.
        future.
     """
     """
-    
+
     info = {}
     info = {}
     r = RasterRow(name=name, mapset=mapset)
     r = RasterRow(name=name, mapset=mapset)
     if r.exist() is True:
     if r.exist() is True:
         r.open("r")
         r.open("r")
-        
+
         for item in r.info:
         for item in r.info:
             info[item[0]] = item[1]
             info[item[0]] = item[1]
 
 
         for item in r.hist:
         for item in r.hist:
             info[item[0]] = item[1]
             info[item[0]] = item[1]
-        
+
         info["full_name"] = r.name_mapset()
         info["full_name"] = r.name_mapset()
         info["mtype"] = r.mtype
         info["mtype"] = r.mtype
         if r.cats:
         if r.cats:
@@ -150,14 +150,14 @@ def _read_vector_full_info(name, mapset, layer = None):
         info["title"] = v.title
         info["title"] = v.title
         info["thresh"] = v.thresh
         info["thresh"] = v.thresh
         info["zone"] = v.zone
         info["zone"] = v.zone
-        vtypes = ['areas', 'dblinks', 'faces', 'holes', 'islands', 
-                  'kernels', 'lines', 'nodes', 'points', 'updated_lines', 
+        vtypes = ['areas', 'dblinks', 'faces', 'holes', 'islands',
+                  'kernels', 'lines', 'nodes', 'points', 'updated_lines',
                   'updated_nodes', 'volumes']
                   'updated_nodes', 'volumes']
         for vtype in vtypes:
         for vtype in vtypes:
             info[vtype] = v.number_of(vtype)
             info[vtype] = v.number_of(vtype)
-            
+
         info.update(v.num_primitives())
         info.update(v.num_primitives())
-        
+
         if v.table is not None:
         if v.table is not None:
             info["columns"] = v.table.columns
             info["columns"] = v.table.columns
 
 
@@ -293,15 +293,15 @@ def _available_mapsets(lock, conn, data):
         while mapsets[count]:
         while mapsets[count]:
             char_list = ""
             char_list = ""
             mapset = mapsets[count]
             mapset = mapsets[count]
-            
+
             permission = libgis.G_mapset_permissions(mapset)
             permission = libgis.G_mapset_permissions(mapset)
             in_search_path = libgis.G_is_mapset_in_search_path(mapset)
             in_search_path = libgis.G_is_mapset_in_search_path(mapset)
-            
+
             c = 0
             c = 0
             while mapset[c] != "\x00":
             while mapset[c] != "\x00":
                 char_list += mapset[c]
                 char_list += mapset[c]
                 c += 1
                 c += 1
-            
+
             if permission >= 0 and in_search_path == 1:
             if permission >= 0 and in_search_path == 1:
                 mapset_list.append(char_list)
                 mapset_list.append(char_list)
 
 
@@ -1172,10 +1172,10 @@ class CLibrariesInterface(RPCServerBase):
         self.client_conn.send([RPCDefs.READ_MAP_INFO, RPCDefs.TYPE_RASTER,
         self.client_conn.send([RPCDefs.READ_MAP_INFO, RPCDefs.TYPE_RASTER,
                                name, mapset, None])
                                name, mapset, None])
         return self.safe_receive("read_raster_info")
         return self.safe_receive("read_raster_info")
-        
+
     def read_raster_full_info(self, name, mapset):
     def read_raster_full_info(self, name, mapset):
         """Read raster info, history and cats using PyGRASS RasterRow
         """Read raster info, history and cats using PyGRASS RasterRow
-           and return a dictionary. Colors should be supported in the 
+           and return a dictionary. Colors should be supported in the
            future.
            future.
 
 
            :param name: The name of the map
            :param name: The name of the map
@@ -1184,7 +1184,7 @@ class CLibrariesInterface(RPCServerBase):
                      or None in case of an error
                      or None in case of an error
         """
         """
         self.check_server()
         self.check_server()
-        self.client_conn.send([RPCDefs.READ_MAP_FULL_INFO, 
+        self.client_conn.send([RPCDefs.READ_MAP_FULL_INFO,
                                RPCDefs.TYPE_RASTER,
                                RPCDefs.TYPE_RASTER,
                                name, mapset, None])
                                name, mapset, None])
         return self.safe_receive("read_raster_full_info")
         return self.safe_receive("read_raster_full_info")
@@ -1379,7 +1379,7 @@ class CLibrariesInterface(RPCServerBase):
 
 
     def read_vector_full_info(self, name, mapset):
     def read_vector_full_info(self, name, mapset):
         """Read vector info using PyGRASS VectorTopo
         """Read vector info using PyGRASS VectorTopo
-           and return a dictionary. 
+           and return a dictionary.
 
 
            :param name: The name of the map
            :param name: The name of the map
            :param mapset: The mapset of the map
            :param mapset: The mapset of the map
@@ -1387,7 +1387,7 @@ class CLibrariesInterface(RPCServerBase):
                      or None in case of an error
                      or None in case of an error
         """
         """
         self.check_server()
         self.check_server()
-        self.client_conn.send([RPCDefs.READ_MAP_FULL_INFO, 
+        self.client_conn.send([RPCDefs.READ_MAP_FULL_INFO,
                                RPCDefs.TYPE_VECTOR,
                                RPCDefs.TYPE_VECTOR,
                                name, mapset, None])
                                name, mapset, None])
         return self.safe_receive("read_vector_full_info")
         return self.safe_receive("read_vector_full_info")

+ 5 - 5
lib/python/temporal/core.py

@@ -36,7 +36,7 @@ gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'))
 
 
 import grass.script as gscript
 import grass.script as gscript
 from datetime import datetime
 from datetime import datetime
-from c_libraries_interface import *
+from .c_libraries_interface import *
 from grass.pygrass import messages
 from grass.pygrass import messages
 # Import all supported database backends
 # Import all supported database backends
 # Ignore import errors since they are checked later
 # Ignore import errors since they are checked later
@@ -70,7 +70,7 @@ def profile_function(func):
         sortby = 'cumulative'
         sortby = 'cumulative'
         ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
         ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
         ps.print_stats()
         ps.print_stats()
-        print s.getvalue()
+        print(s.getvalue())
     else:
     else:
         func()
         func()
 
 
@@ -1161,9 +1161,9 @@ class DBConnection(object):
                 if self.connected:
                 if self.connected:
                     try:
                     try:
                         return self.cursor.mogrify(sql, args)
                         return self.cursor.mogrify(sql, args)
-                    except:
-                        print sql, args
-                        raise
+                    except Exception as exc:
+                        print(sql, args)
+                        raise exc
                 else:
                 else:
                     self.connect()
                     self.connect()
                     statement = self.cursor.mogrify(sql, args)
                     statement = self.cursor.mogrify(sql, args)

+ 3 - 3
lib/python/temporal/datetime_math.py

@@ -9,7 +9,7 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 from datetime import datetime, timedelta
 from datetime import datetime, timedelta
-from core import *
+from .core import *
 import copy
 import copy
 
 
 try:
 try:
@@ -863,9 +863,9 @@ def create_suffix_from_datetime(start_time,  granularity):
 
 
 def create_time_suffix(mapp, end=False):
 def create_time_suffix(mapp, end=False):
     """Create a datetime string based on a map datetime object
     """Create a datetime string based on a map datetime object
-    
+
        :param mapp: a temporal map dataset
        :param mapp: a temporal map dataset
-       :param end: True if you want add also end time to the suffix    
+       :param end: True if you want add also end time to the suffix
     """
     """
     start = mapp.temporal_extent.get_start_time()
     start = mapp.temporal_extent.get_start_time()
     sstring = start.isoformat().replace(':', '_').replace('-', '_')
     sstring = start.isoformat().replace(':', '_').replace('-', '_')

+ 6 - 6
lib/python/temporal/extract.py

@@ -10,11 +10,11 @@ for details.
 """
 """
 
 
 from grass.script.utils import get_num_suffix
 from grass.script.utils import get_num_suffix
-from space_time_datasets import *
-from open_stds import *
-from datetime_math import create_suffix_from_datetime
-from datetime_math import create_time_suffix
-from datetime_math import create_numeric_suffic
+from .space_time_datasets import *
+from .open_stds import *
+from .datetime_math import create_suffix_from_datetime
+from .datetime_math import create_time_suffix
+from .datetime_math import create_numeric_suffic
 from multiprocessing import Process
 from multiprocessing import Process
 import grass.script as gscript
 import grass.script as gscript
 from grass.exceptions import CalledModuleError
 from grass.exceptions import CalledModuleError
@@ -183,7 +183,7 @@ def extract_dataset(input, output, type, where, expression, base, time_suffix,
         msgr.percent(0, num_rows, 1)
         msgr.percent(0, num_rows, 1)
 
 
         temporal_type, semantic_type, title, description = sp.get_initial_values()
         temporal_type, semantic_type, title, description = sp.get_initial_values()
-        new_sp = open_new_stds(output, type, sp.get_temporal_type(), title, 
+        new_sp = open_new_stds(output, type, sp.get_temporal_type(), title,
                                description, semantic_type, dbif,
                                description, semantic_type, dbif,
                                gscript.overwrite())
                                gscript.overwrite())
 
 

+ 1 - 1
lib/python/temporal/factory.py

@@ -18,7 +18,7 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 
 
-from space_time_datasets import *
+from .space_time_datasets import *
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 2 - 2
lib/python/temporal/gui_support.py

@@ -10,8 +10,8 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 
 
-from space_time_datasets import *
-from factory import *
+from .space_time_datasets import *
+from .factory import *
 import grass.script as gscript
 import grass.script as gscript
 
 
 ###############################################################################
 ###############################################################################

+ 11 - 11
lib/python/temporal/list_stds.py

@@ -17,10 +17,10 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-
-from space_time_datasets import *
-from factory import *
-from open_stds import *
+from __future__ import print_function
+from .space_time_datasets import *
+from .factory import *
+from .open_stds import *
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -58,13 +58,13 @@ def get_dataset_list(type, temporal_type, columns=None, where=None,
             >>> rows =  stds_list[mapset]
             >>> rows =  stds_list[mapset]
             >>> for row in rows:
             >>> for row in rows:
             ...     if row["name"] == name:
             ...     if row["name"] == name:
-            ...         print True
+            ...         print(True)
             True
             True
             >>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name,mapset", where="mapset = '%s'"%(mapset))
             >>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name,mapset", where="mapset = '%s'"%(mapset))
             >>> rows =  stds_list[mapset]
             >>> rows =  stds_list[mapset]
             >>> for row in rows:
             >>> for row in rows:
             ...     if row["name"] == name and row["mapset"] == mapset:
             ...     if row["name"] == name and row["mapset"] == mapset:
-            ...         print True
+            ...         print(True)
             True
             True
             >>> check = sp.delete()
             >>> check = sp.delete()
 
 
@@ -192,7 +192,7 @@ def list_maps_of_stds(type, input, columns, order, where, separator,
             if outpath:
             if outpath:
                 outfile.write('{st}\n'.format(st=string))
                 outfile.write('{st}\n'.format(st=string))
             else:
             else:
-                print string
+                print(string)
 
 
         if maps and len(maps) > 0:
         if maps and len(maps) > 0:
 
 
@@ -240,7 +240,7 @@ def list_maps_of_stds(type, input, columns, order, where, separator,
                 if outpath:
                 if outpath:
                     outfile.write('{st}\n'.format(st=string))
                     outfile.write('{st}\n'.format(st=string))
                 else:
                 else:
-                    print string
+                    print(string)
 
 
     else:
     else:
         # In comma separated mode only map ids are needed
         # In comma separated mode only map ids are needed
@@ -262,7 +262,7 @@ def list_maps_of_stds(type, input, columns, order, where, separator,
                 if outpath:
                 if outpath:
                     outfile.write('{st}\n'.format(st=string))
                     outfile.write('{st}\n'.format(st=string))
                 else:
                 else:
-                    print string
+                    print(string)
 
 
             elif method == "cols":
             elif method == "cols":
                 # Print the column names if requested
                 # Print the column names if requested
@@ -281,7 +281,7 @@ def list_maps_of_stds(type, input, columns, order, where, separator,
                     if outpath:
                     if outpath:
                         outfile.write('{st}\n'.format(st=output))
                         outfile.write('{st}\n'.format(st=output))
                     else:
                     else:
-                        print output
+                        print(output)
 
 
                 for row in rows:
                 for row in rows:
                     output = ""
                     output = ""
@@ -295,7 +295,7 @@ def list_maps_of_stds(type, input, columns, order, where, separator,
                     if outpath:
                     if outpath:
                         outfile.write('{st}\n'.format(st=output))
                         outfile.write('{st}\n'.format(st=output))
                     else:
                     else:
-                        print output
+                        print(output)
     if outpath:
     if outpath:
         outfile.close()
         outfile.close()
     if connected:
     if connected:

+ 2 - 2
lib/python/temporal/mapcalc.py

@@ -9,8 +9,8 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 
 
-from space_time_datasets import *
-from open_stds import *
+from .space_time_datasets import *
+from .open_stds import *
 from multiprocessing import Process
 from multiprocessing import Process
 import grass.script as gscript
 import grass.script as gscript
 from grass.exceptions import CalledModuleError
 from grass.exceptions import CalledModuleError

+ 128 - 127
lib/python/temporal/metadata.py

@@ -21,7 +21,8 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-from base import *
+from __future__ import print_function
+from .base import *
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -234,26 +235,26 @@ class RasterMetadataBase(SQLDatabaseInterface):
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " | Datatype:................... " + str(self.get_datatype())
-        print " | Number of columns:.......... " + str(self.get_cols())
-        print " | Number of rows:............. " + str(self.get_rows())
-        print " | Number of cells:............ " + str(
-            self.get_number_of_cells())
-        print " | North-South resolution:..... " + str(self.get_nsres())
-        print " | East-west resolution:....... " + str(self.get_ewres())
-        print " | Minimum value:.............. " + str(self.get_min())
-        print " | Maximum value:.............. " + str(self.get_max())
+        print(" | Datatype:................... " + str(self.get_datatype()))
+        print(" | Number of columns:.......... " + str(self.get_cols()))
+        print(" | Number of rows:............. " + str(self.get_rows()))
+        print(" | Number of cells:............ " + str(
+            self.get_number_of_cells()))
+        print(" | North-South resolution:..... " + str(self.get_nsres()))
+        print(" | East-west resolution:....... " + str(self.get_ewres()))
+        print(" | Minimum value:.............. " + str(self.get_min()))
+        print(" | Maximum value:.............. " + str(self.get_max()))
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
-        print "datatype=" + str(self.get_datatype())
-        print "cols=" + str(self.get_cols())
-        print "rows=" + str(self.get_rows())
-        print "number_of_cells=" + str(self.get_number_of_cells())
-        print "nsres=" + str(self.get_nsres())
-        print "ewres=" + str(self.get_ewres())
-        print "min=" + str(self.get_min())
-        print "max=" + str(self.get_max())
+        print("datatype=" + str(self.get_datatype()))
+        print("cols=" + str(self.get_cols()))
+        print("rows=" + str(self.get_rows()))
+        print("number_of_cells=" + str(self.get_number_of_cells()))
+        print("nsres=" + str(self.get_nsres()))
+        print("ewres=" + str(self.get_ewres()))
+        print("min=" + str(self.get_min()))
+        print("max=" + str(self.get_max()))
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -323,7 +324,7 @@ class RasterMetadata(RasterMetadataBase):
 
 
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
-        print " +-------------------- Metadata information ----------------------------------+"
+        print(" +-------------------- Metadata information ----------------------------------+")
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
         RasterMetadataBase.print_info(self)
         RasterMetadataBase.print_info(self)
 
 
@@ -445,18 +446,18 @@ class Raster3DMetadata(RasterMetadataBase):
 
 
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
-        print " +-------------------- Metadata information ----------------------------------+"
+        print(" +-------------------- Metadata information ----------------------------------+")
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
         RasterMetadataBase.print_info(self)
         RasterMetadataBase.print_info(self)
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " | Number of depths:........... " + str(self.get_depths())
-        print " | Top-Bottom resolution:...... " + str(self.get_tbres())
+        print(" | Number of depths:........... " + str(self.get_depths()))
+        print(" | Top-Bottom resolution:...... " + str(self.get_tbres()))
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
         RasterMetadataBase.print_shell_info(self)
         RasterMetadataBase.print_shell_info(self)
-        print "depths=" + str(self.get_depths())
-        print "tbres=" + str(self.get_tbres())
+        print("depths=" + str(self.get_depths()))
+        print("tbres=" + str(self.get_tbres()))
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -763,36 +764,36 @@ class VectorMetadata(SQLDatabaseInterface):
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " +-------------------- Metadata information ----------------------------------+"
-        print " | Is map 3d .................. " + str(self.get_3d_info())
-        print " | Number of points ........... " + str(self.get_number_of_points())
-        print " | Number of lines ............ " + str(self.get_number_of_lines())
-        print " | Number of boundaries ....... " + str(self.get_number_of_boundaries())
-        print " | Number of centroids ........ " + str(self.get_number_of_centroids())
-        print " | Number of faces ............ " + str(self.get_number_of_faces())
-        print " | Number of kernels .......... " + str(self.get_number_of_kernels())
-        print " | Number of primitives ....... " + str(self.get_number_of_primitives())
-        print " | Number of nodes ............ " + str(self.get_number_of_nodes())
-        print " | Number of areas ............ " + str(self.get_number_of_areas())
-        print " | Number of islands .......... " + str(self.get_number_of_islands())
-        print " | Number of holes ............ " + str(self.get_number_of_holes())
-        print " | Number of volumes .......... " + str(self.get_number_of_volumes())
+        print(" +-------------------- Metadata information ----------------------------------+")
+        print(" | Is map 3d .................. " + str(self.get_3d_info()))
+        print(" | Number of points ........... " + str(self.get_number_of_points()))
+        print(" | Number of lines ............ " + str(self.get_number_of_lines()))
+        print(" | Number of boundaries ....... " + str(self.get_number_of_boundaries()))
+        print(" | Number of centroids ........ " + str(self.get_number_of_centroids()))
+        print(" | Number of faces ............ " + str(self.get_number_of_faces()))
+        print(" | Number of kernels .......... " + str(self.get_number_of_kernels()))
+        print(" | Number of primitives ....... " + str(self.get_number_of_primitives()))
+        print(" | Number of nodes ............ " + str(self.get_number_of_nodes()))
+        print(" | Number of areas ............ " + str(self.get_number_of_areas()))
+        print(" | Number of islands .......... " + str(self.get_number_of_islands()))
+        print(" | Number of holes ............ " + str(self.get_number_of_holes()))
+        print(" | Number of volumes .......... " + str(self.get_number_of_volumes()))
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
-        print "is_3d=" + str(self.get_3d_info())
-        print "points=" + str(self.get_number_of_points())
-        print "lines=" + str(self.get_number_of_lines())
-        print "boundaries=" + str(self.get_number_of_boundaries())
-        print "centroids=" + str(self.get_number_of_centroids())
-        print "faces=" + str(self.get_number_of_faces())
-        print "kernels=" + str(self.get_number_of_kernels())
-        print "primitives=" + str(self.get_number_of_primitives())
-        print "nodes=" + str(self.get_number_of_nodes())
-        print "areas=" + str(self.get_number_of_areas())
-        print "islands=" + str(self.get_number_of_islands())
-        print "holes=" + str(self.get_number_of_holes())
-        print "volumes=" + str(self.get_number_of_volumes())
+        print("is_3d=" + str(self.get_3d_info()))
+        print("points=" + str(self.get_number_of_points()))
+        print("lines=" + str(self.get_number_of_lines()))
+        print("boundaries=" + str(self.get_number_of_boundaries()))
+        print("centroids=" + str(self.get_number_of_centroids()))
+        print("faces=" + str(self.get_number_of_faces()))
+        print("kernels=" + str(self.get_number_of_kernels()))
+        print("primitives=" + str(self.get_number_of_primitives()))
+        print("nodes=" + str(self.get_number_of_nodes()))
+        print("areas=" + str(self.get_number_of_areas()))
+        print("islands=" + str(self.get_number_of_islands()))
+        print("holes=" + str(self.get_number_of_holes()))
+        print("volumes=" + str(self.get_number_of_volumes()))
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -908,29 +909,29 @@ class STDSMetadataBase(SQLDatabaseInterface):
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " | Number of registered maps:.. " + str(
-            self.get_number_of_maps())
-        print " |"
-        print " | Title:"
-        print " | " + str(self.get_title())
-        print " | Description:"
-        print " | " + str(self.get_description())
-        print " | Command history:"
+        print(" | Number of registered maps:.. " + str(
+            self.get_number_of_maps()))
+        print(" |")
+        print(" | Title:")
+        print(" | " + str(self.get_title()))
+        print(" | Description:")
+        print(" | " + str(self.get_description()))
+        print(" | Command history:")
         command = self.get_command()
         command = self.get_command()
         if command:
         if command:
             for token in command.split("\n"):
             for token in command.split("\n"):
-                print " | " + str(token)
+                print(" | " + str(token))
 
 
     def print_history(self):
     def print_history(self):
         """Print history information about this class in human readable
         """Print history information about this class in human readable
             shell style
             shell style
         """
         """
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print "# Title:"
-        print "# " + str(self.get_title())
-        print "# Description:"
-        print "# " + str(self.get_description())
-        print "# Command history:"
+        print("# Title:")
+        print("# " + str(self.get_title()))
+        print("# Description:")
+        print("# " + str(self.get_description()))
+        print("# Command history:")
         command = self.get_command()
         command = self.get_command()
 
 
         if command:
         if command:
@@ -946,15 +947,15 @@ class STDSMetadataBase(SQLDatabaseInterface):
                 count += 1
                 count += 1
                 if len(token) > 1:
                 if len(token) > 1:
                     if token[0] == "#":
                     if token[0] == "#":
-                        print token
+                        print(token)
                     elif count < len(print_list):
                     elif count < len(print_list):
-                        print token + " \\"
+                        print(token + " \\")
                     else:
                     else:
-                        print token
+                        print(token)
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
-        print "number_of_maps=" + str(self.get_number_of_maps())
+        print("number_of_maps=" + str(self.get_number_of_maps()))
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -1142,29 +1143,29 @@ class STDSRasterMetadataBase(STDSMetadataBase):
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " | North-South resolution min:. " + str(self.get_nsres_min())
-        print " | North-South resolution max:. " + str(self.get_nsres_max())
-        print " | East-west resolution min:... " + str(self.get_ewres_min())
-        print " | East-west resolution max:... " + str(self.get_ewres_max())
-        print " | Minimum value min:.......... " + str(self.get_min_min())
-        print " | Minimum value max:.......... " + str(self.get_min_max())
-        print " | Maximum value min:.......... " + str(self.get_max_min())
-        print " | Maximum value max:.......... " + str(self.get_max_max())
-        print " | Aggregation type:........... " + str(self.get_aggregation_type())
+        print(" | North-South resolution min:. " + str(self.get_nsres_min()))
+        print(" | North-South resolution max:. " + str(self.get_nsres_max()))
+        print(" | East-west resolution min:... " + str(self.get_ewres_min()))
+        print(" | East-west resolution max:... " + str(self.get_ewres_max()))
+        print(" | Minimum value min:.......... " + str(self.get_min_min()))
+        print(" | Minimum value max:.......... " + str(self.get_min_max()))
+        print(" | Maximum value min:.......... " + str(self.get_max_min()))
+        print(" | Maximum value max:.......... " + str(self.get_max_max()))
+        print(" | Aggregation type:........... " + str(self.get_aggregation_type()))
         STDSMetadataBase.print_info(self)
         STDSMetadataBase.print_info(self)
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
-        print "aggregation_type=" + str(self.get_aggregation_type())
+        print("aggregation_type=" + str(self.get_aggregation_type()))
         STDSMetadataBase.print_shell_info(self)
         STDSMetadataBase.print_shell_info(self)
-        print "nsres_min=" + str(self.get_nsres_min())
-        print "nsres_max=" + str(self.get_nsres_max())
-        print "ewres_min=" + str(self.get_ewres_min())
-        print "ewres_max=" + str(self.get_ewres_max())
-        print "min_min=" + str(self.get_min_min())
-        print "min_max=" + str(self.get_min_max())
-        print "max_min=" + str(self.get_max_min())
-        print "max_max=" + str(self.get_max_max())
+        print("nsres_min=" + str(self.get_nsres_min()))
+        print("nsres_max=" + str(self.get_nsres_max()))
+        print("ewres_min=" + str(self.get_ewres_min()))
+        print("ewres_max=" + str(self.get_ewres_max()))
+        print("min_min=" + str(self.get_min_min()))
+        print("min_max=" + str(self.get_min_max()))
+        print("max_min=" + str(self.get_max_min()))
+        print("max_max=" + str(self.get_max_max()))
 
 
 
 
 ###############################################################################
 ###############################################################################
@@ -1261,16 +1262,16 @@ class STRDSMetadata(STDSRasterMetadataBase):
 
 
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
-        print " +-------------------- Metadata information ----------------------------------+"
+        print(" +-------------------- Metadata information ----------------------------------+")
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " | Raster register table:...... " + str(
-            self.get_raster_register())
+        print(" | Raster register table:...... " + str(
+            self.get_raster_register()))
         STDSRasterMetadataBase.print_info(self)
         STDSRasterMetadataBase.print_info(self)
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
         STDSRasterMetadataBase.print_shell_info(self)
         STDSRasterMetadataBase.print_shell_info(self)
-        print "raster_register=" + str(self.get_raster_register())
+        print("raster_register=" + str(self.get_raster_register()))
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -1397,21 +1398,21 @@ class STR3DSMetadata(STDSRasterMetadataBase):
 
 
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
-        print " +-------------------- Metadata information ----------------------------------+"
+        print(" +-------------------- Metadata information ----------------------------------+")
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " | 3D raster register table:... " + str(
-            self.get_raster3d_register())
-        print " | Top-bottom resolution min:.. " + str(self.get_ewres_min())
-        print " | Top-bottom resolution max:.. " + str(self.get_ewres_max())
+        print(" | 3D raster register table:... " + str(
+            self.get_raster3d_register()))
+        print(" | Top-bottom resolution min:.. " + str(self.get_ewres_min()))
+        print(" | Top-bottom resolution max:.. " + str(self.get_ewres_max()))
         STDSRasterMetadataBase.print_info(self)
         STDSRasterMetadataBase.print_info(self)
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
         STDSRasterMetadataBase.print_shell_info(self)
         STDSRasterMetadataBase.print_shell_info(self)
-        print "tbres_min=" + str(self.get_tbres_min())
-        print "tbres_max=" + str(self.get_tbres_max())
-        print "raster3d_register=" + str(self.get_raster3d_register())
+        print("tbres_min=" + str(self.get_tbres_min()))
+        print("tbres_max=" + str(self.get_tbres_max()))
+        print("raster3d_register=" + str(self.get_raster3d_register()))
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -1662,40 +1663,40 @@ class STVDSMetadata(STDSMetadataBase):
 
 
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
-        print " +-------------------- Metadata information ----------------------------------+"
+        print(" +-------------------- Metadata information ----------------------------------+")
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " | Vector register table:...... " + str(
-            self.get_vector_register())
-        print " | Number of points ........... " + str(self.number_of_points)
-        print " | Number of lines ............ " + str(self.number_of_lines)
-        print " | Number of boundaries ....... " + str(self.number_of_boundaries)
-        print " | Number of centroids ........ " + str(self.number_of_centroids)
-        print " | Number of faces ............ " + str(self.number_of_faces)
-        print " | Number of kernels .......... " + str(self.number_of_kernels)
-        print " | Number of primitives ....... " + str(self.number_of_primitives)
-        print " | Number of nodes ............ " + str(self.number_of_nodes)
-        print " | Number of areas ............ " + str(self.number_of_areas)
-        print " | Number of islands .......... " + str(self.number_of_islands)
-        print " | Number of holes ............ " + str(self.number_of_holes)
-        print " | Number of volumes .......... " + str(self.number_of_volumes)
+        print(" | Vector register table:...... " + str(
+            self.get_vector_register()))
+        print(" | Number of points ........... " + str(self.number_of_points))
+        print(" | Number of lines ............ " + str(self.number_of_lines))
+        print(" | Number of boundaries ....... " + str(self.number_of_boundaries))
+        print(" | Number of centroids ........ " + str(self.number_of_centroids))
+        print(" | Number of faces ............ " + str(self.number_of_faces))
+        print(" | Number of kernels .......... " + str(self.number_of_kernels))
+        print(" | Number of primitives ....... " + str(self.number_of_primitives))
+        print(" | Number of nodes ............ " + str(self.number_of_nodes))
+        print(" | Number of areas ............ " + str(self.number_of_areas))
+        print(" | Number of islands .......... " + str(self.number_of_islands))
+        print(" | Number of holes ............ " + str(self.number_of_holes))
+        print(" | Number of volumes .......... " + str(self.number_of_volumes))
         STDSMetadataBase.print_info(self)
         STDSMetadataBase.print_info(self)
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
         STDSMetadataBase.print_shell_info(self)
         STDSMetadataBase.print_shell_info(self)
-        print "vector_register=" + str(self.get_vector_register())
-        print "points=" + str(self.get_number_of_points())
-        print "lines=" + str(self.get_number_of_lines())
-        print "boundaries=" + str(self.get_number_of_boundaries())
-        print "centroids=" + str(self.get_number_of_centroids())
-        print "faces=" + str(self.get_number_of_faces())
-        print "kernels=" + str(self.get_number_of_kernels())
-        print "primitives=" + str(self.get_number_of_primitives())
-        print "nodes=" + str(self.get_number_of_nodes())
-        print "areas=" + str(self.get_number_of_areas())
-        print "islands=" + str(self.get_number_of_islands())
-        print "holes=" + str(self.get_number_of_holes())
-        print "volumes=" + str(self.get_number_of_volumes())
+        print("vector_register=" + str(self.get_vector_register()))
+        print("points=" + str(self.get_number_of_points()))
+        print("lines=" + str(self.get_number_of_lines()))
+        print("boundaries=" + str(self.get_number_of_boundaries()))
+        print("centroids=" + str(self.get_number_of_centroids()))
+        print("faces=" + str(self.get_number_of_faces()))
+        print("kernels=" + str(self.get_number_of_kernels()))
+        print("primitives=" + str(self.get_number_of_primitives()))
+        print("nodes=" + str(self.get_number_of_nodes()))
+        print("areas=" + str(self.get_number_of_areas()))
+        print("islands=" + str(self.get_number_of_islands()))
+        print("holes=" + str(self.get_number_of_holes()))
+        print("volumes=" + str(self.get_number_of_volumes()))
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 2 - 2
lib/python/temporal/open_stds.py

@@ -18,7 +18,7 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 
 
-from factory import *
+from .factory import *
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -37,7 +37,7 @@ def open_old_stds(name, type, dbif=None):
        :param type: The type of the space time dataset (strd, str3ds, stvds,
        :param type: The type of the space time dataset (strd, str3ds, stvds,
                     raster, vector, raster3d)
                     raster, vector, raster3d)
        :param dbif: The optional database interface to be used
        :param dbif: The optional database interface to be used
-       
+
        :return: New stds object
        :return: New stds object
 
 
     """
     """

+ 1 - 1
lib/python/temporal/register.py

@@ -17,7 +17,7 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 
 
-from open_stds import *
+from .open_stds import *
 import grass.script as gscript
 import grass.script as gscript
 
 
 ###############################################################################
 ###############################################################################

+ 4 - 4
lib/python/temporal/sampling.py

@@ -16,8 +16,8 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-
-from factory import *
+from __future__ import print_function
+from .factory import *
 
 
 
 
 def sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header,
 def sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header,
@@ -122,7 +122,7 @@ def sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header,
             string += "%s%s" % ("end_time", separator)
             string += "%s%s" % ("end_time", separator)
             string += "%s%s" % ("interval_length", separator)
             string += "%s%s" % ("interval_length", separator)
             string += "%s" % ("distance_from_begin")
             string += "%s" % ("distance_from_begin")
-            print string
+            print(string)
 
 
         first_time, dummy = mapmatrizes[0][0]["granule"].get_temporal_extent_as_tuple()
         first_time, dummy = mapmatrizes[0][0]["granule"].get_temporal_extent_as_tuple()
 
 
@@ -163,7 +163,7 @@ def sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header,
             string += "%s%s" % (end, separator)
             string += "%s%s" % (end, separator)
             string += "%s%s" % (delta, separator)
             string += "%s%s" % (delta, separator)
             string += "%s" % (delta_first)
             string += "%s" % (delta_first)
-            print string
+            print(string)
 
 
     dbif.close()
     dbif.close()
     if len(mapmatrizes) > 0:
     if len(mapmatrizes) > 0:

+ 2 - 2
lib/python/temporal/space_time_datasets.py

@@ -9,8 +9,8 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 import getpass
 import getpass
-from abstract_map_dataset import *
-from abstract_space_time_dataset import *
+from .abstract_map_dataset import *
+from .abstract_space_time_dataset import *
 import grass.script.array as garray
 import grass.script.array as garray
 
 
 ###############################################################################
 ###############################################################################

+ 15 - 14
lib/python/temporal/spatial_extent.py

@@ -33,7 +33,8 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-from base import *
+from __future__ import print_function
+from .base import *
 
 
 
 
 class SpatialExtent(SQLDatabaseInterface):
 class SpatialExtent(SQLDatabaseInterface):
@@ -1782,22 +1783,22 @@ class SpatialExtent(SQLDatabaseInterface):
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " +-------------------- Spatial extent ----------------------------------------+"
-        print " | North:...................... " + str(self.get_north())
-        print " | South:...................... " + str(self.get_south())
-        print " | East:.. .................... " + str(self.get_east())
-        print " | West:....................... " + str(self.get_west())
-        print " | Top:........................ " + str(self.get_top())
-        print " | Bottom:..................... " + str(self.get_bottom())
+        print(" +-------------------- Spatial extent ----------------------------------------+")
+        print(" | North:...................... " + str(self.get_north()))
+        print(" | South:...................... " + str(self.get_south()))
+        print(" | East:.. .................... " + str(self.get_east()))
+        print(" | West:....................... " + str(self.get_west()))
+        print(" | Top:........................ " + str(self.get_top()))
+        print(" | Bottom:..................... " + str(self.get_bottom()))
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
-        print "north=" + str(self.get_north())
-        print "south=" + str(self.get_south())
-        print "east=" + str(self.get_east())
-        print "west=" + str(self.get_west())
-        print "top=" + str(self.get_top())
-        print "bottom=" + str(self.get_bottom())
+        print("north=" + str(self.get_north()))
+        print("south=" + str(self.get_south()))
+        print("east=" + str(self.get_east()))
+        print("west=" + str(self.get_west()))
+        print("top=" + str(self.get_top()))
+        print("bottom=" + str(self.get_bottom()))
 
 
 
 
 ###############################################################################
 ###############################################################################

+ 31 - 30
lib/python/temporal/spatial_topology_dataset_connector.py

@@ -14,6 +14,7 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
+from __future__ import print_function
 import copy
 import copy
 
 
 
 
@@ -68,7 +69,7 @@ class SpatialTopologyDatasetConnector(object):
             meet=a@P
             meet=a@P
             >>> rlist = tmr.get_spatial_relations()
             >>> rlist = tmr.get_spatial_relations()
             >>> if "COVER" in rlist.keys():
             >>> if "COVER" in rlist.keys():
-            ...    print rlist["COVER"][0].get_id()
+            ...    print(rlist["COVER"][0].get_id())
             a@P
             a@P
 
 
     """
     """
@@ -318,54 +319,54 @@ class SpatialTopologyDatasetConnector(object):
     def print_spatial_topology_info(self):
     def print_spatial_topology_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
 
 
-        print " +-------------------- Spatial Topology --------------------------------------+"
+        print(" +-------------------- Spatial Topology --------------------------------------+")
         #          0123456789012345678901234567890
         #          0123456789012345678901234567890
         if self.equivalent is not None:
         if self.equivalent is not None:
-            print " | Equivalent: ................ " + \
-                self._generate_map_list_string(self.equivalent)
+            print(" | Equivalent: ................ " +
+                  self._generate_map_list_string(self.equivalent))
         if self.cover is not None:
         if self.cover is not None:
-            print " | Cover: ..................... " + \
-                self._generate_map_list_string(self.cover)
+            print(" | Cover: ..................... " +
+                  self._generate_map_list_string(self.cover))
         if self.covered is not None:
         if self.covered is not None:
-            print " | Covered: ................... " + \
-                self._generate_map_list_string(self.covered)
+            print(" | Covered: ................... " +
+                  self._generate_map_list_string(self.covered))
         if self.overlap is not None:
         if self.overlap is not None:
-            print " | Overlap: ................... " + \
-                self._generate_map_list_string(self.overlap)
+            print(" | Overlap: ................... " +
+                  self._generate_map_list_string(self.overlap))
         if self.in_ is not None:
         if self.in_ is not None:
-            print " | In: ........................ " + \
-                self._generate_map_list_string(self.in_)
+            print(" | In: ........................ " +
+                  self._generate_map_list_string(self.in_))
         if self.contain is not None:
         if self.contain is not None:
-            print " | Contain: ................... " + \
-                self._generate_map_list_string(self.contain)
+            print(" | Contain: ................... " +
+                  self._generate_map_list_string(self.contain))
         if self.meet is not None:
         if self.meet is not None:
-            print " | Meet: ...................... " + \
-                self._generate_map_list_string(self.meet)
+            print(" | Meet: ...................... " +
+                  self._generate_map_list_string(self.meet))
 
 
     def print_spatial_topology_shell_info(self):
     def print_spatial_topology_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
 
 
         if self.equivalent is not None:
         if self.equivalent is not None:
-            print "equivalent=" + self._generate_map_list_string(self.equivalent,
-                                                                 False)
+            print("equivalent=" + self._generate_map_list_string(self.equivalent,
+                                                                 False))
         if self.cover is not None:
         if self.cover is not None:
-            print "cover=" + self._generate_map_list_string(
-                self.cover, False)
+            print("cover=" + self._generate_map_list_string(
+                  self.cover, False))
         if self.covered is not None:
         if self.covered is not None:
-            print "covered=" + \
-                self._generate_map_list_string(self.covered, False)
+            print("covered=" +
+                  self._generate_map_list_string(self.covered, False))
         if self.overlap is not None:
         if self.overlap is not None:
-            print "overlap=" + \
-                self._generate_map_list_string(self.overlap)
+            print("overlap=" +
+                  self._generate_map_list_string(self.overlap))
         if self.in_ is not None:
         if self.in_ is not None:
-            print "in=" + \
-                self._generate_map_list_string(self.in_)
+            print("in=" +
+                  self._generate_map_list_string(self.in_))
         if self.contain is not None:
         if self.contain is not None:
-            print "contain=" + \
-                self._generate_map_list_string(self.contain)
+            print("contain=" +
+                  self._generate_map_list_string(self.contain))
         if self.meet is not None:
         if self.meet is not None:
-            print "meet=" + \
-                self._generate_map_list_string(self.meet)
+            print("meet=" +
+                  self._generate_map_list_string(self.meet))
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 2 - 2
lib/python/temporal/spatio_temporal_relationships.py

@@ -17,8 +17,8 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-from abstract_dataset import *
-from datetime_math import *
+from .abstract_dataset import *
+from .datetime_math import *
 import grass.lib.vector as vector
 import grass.lib.vector as vector
 import grass.lib.rtree as rtree
 import grass.lib.rtree as rtree
 import grass.lib.gis as gis
 import grass.lib.gis as gis

+ 4 - 4
lib/python/temporal/stds_export.py

@@ -30,9 +30,9 @@ import os
 import tarfile
 import tarfile
 import tempfile
 import tempfile
 
 
-from space_time_datasets import *
-from factory import *
-from open_stds import *
+from .space_time_datasets import *
+from .factory import *
+from .open_stds import *
 import grass.script as gscript
 import grass.script as gscript
 from grass.exceptions import CalledModuleError
 from grass.exceptions import CalledModuleError
 
 
@@ -52,7 +52,7 @@ exported_maps = {}
 ############################################################################
 ############################################################################
 
 
 
 
-def _export_raster_maps_as_gdal(rows, tar, list_file, new_cwd, fs, format_, 
+def _export_raster_maps_as_gdal(rows, tar, list_file, new_cwd, fs, format_,
                                 type_):
                                 type_):
     for row in rows:
     for row in rows:
         name = row["name"]
         name = row["name"]

+ 5 - 5
lib/python/temporal/stds_import.py

@@ -33,10 +33,10 @@ import os
 import os.path
 import os.path
 import tarfile
 import tarfile
 
 
-from space_time_datasets import *
-from register import *
-import factory
-from factory import *
+from .space_time_datasets import *
+from .register import *
+from . import factory
+from .factory import *
 import grass.script as gscript
 import grass.script as gscript
 from grass.exceptions import CalledModuleError
 from grass.exceptions import CalledModuleError
 
 
@@ -244,7 +244,7 @@ def import_stds(input, output, directory, title=None, descr=None, location=None,
         temp_file = open(temp_name, "w")
         temp_file = open(temp_name, "w")
         proj_name = os.path.abspath(proj_file_name)
         proj_name = os.path.abspath(proj_file_name)
 
 
-        # We need to convert projection strings generated 
+        # We need to convert projection strings generated
         # from other programms than g.proj into
         # from other programms than g.proj into
         # new line format so that the grass file comparison function
         # new line format so that the grass file comparison function
         # can be used to compare the projections
         # can be used to compare the projections

+ 158 - 157
lib/python/temporal/temporal_algebra.py

@@ -367,7 +367,7 @@ for details.
     None || None
     None || None
     A* =  if condition None  then  A  else  B
     A* =  if condition None  then  A  else  B
     C = A*
     C = A*
-    
+
     >>> p = tgis.TemporalAlgebraLexer()
     >>> p = tgis.TemporalAlgebraLexer()
     >>> p.build()
     >>> p.build()
     >>> p.debug = True
     >>> p.debug = True
@@ -390,7 +390,7 @@ for details.
     LexToken(LPAREN,'(',1,32)
     LexToken(LPAREN,'(',1,32)
     LexToken(NAME,'C',1,33)
     LexToken(NAME,'C',1,33)
     LexToken(RPAREN,')',1,34)
     LexToken(RPAREN,')',1,34)
-    
+
     >>> p = tgis.TemporalAlgebraLexer()
     >>> p = tgis.TemporalAlgebraLexer()
     >>> p.build()
     >>> p.build()
     >>> p.debug = True
     >>> p.debug = True
@@ -412,7 +412,7 @@ for details.
     LexToken(COMMA,',',1,33)
     LexToken(COMMA,',',1,33)
     LexToken(NAME,'A',1,35)
     LexToken(NAME,'A',1,35)
     LexToken(RPAREN,')',1,36)
     LexToken(RPAREN,')',1,36)
-    
+
     >>> p = tgis.TemporalAlgebraLexer()
     >>> p = tgis.TemporalAlgebraLexer()
     >>> p.build()
     >>> p.build()
     >>> p.debug = True
     >>> p.debug = True
@@ -438,6 +438,7 @@ for details.
     LexToken(RPAREN,')',1,48)
     LexToken(RPAREN,')',1,48)
 
 
 """
 """
+from __future__ import print_function
 
 
 try:
 try:
     import ply.lex as lex
     import ply.lex as lex
@@ -448,17 +449,17 @@ except:
 import os
 import os
 import copy
 import copy
 import grass.pygrass.modules as pymod
 import grass.pygrass.modules as pymod
-from space_time_datasets import *
-from factory import *
-from open_stds import *
-from temporal_operator import *
+from .space_time_datasets import *
+from .factory import *
+from .open_stds import *
+from .temporal_operator import *
 
 
 ##############################################################################
 ##############################################################################
 
 
 class TemporalAlgebraLexer(object):
 class TemporalAlgebraLexer(object):
     """Lexical analyzer for the GRASS GIS temporal algebra"""
     """Lexical analyzer for the GRASS GIS temporal algebra"""
 
 
-    # Functions that defines an if condition, temporal buffering, snapping and 
+    # Functions that defines an if condition, temporal buffering, snapping and
     # selection of maps with temporal extent.
     # selection of maps with temporal extent.
     conditional_functions = {
     conditional_functions = {
         'if'    : 'IF',
         'if'    : 'IF',
@@ -471,7 +472,7 @@ class TemporalAlgebraLexer(object):
         'str3ds' : 'STR3DS',
         'str3ds' : 'STR3DS',
         'stvds' : 'STVDS',
         'stvds' : 'STVDS',
     }
     }
-    
+
     # Variables with date and time strings
     # Variables with date and time strings
     datetime_functions = {
     datetime_functions = {
         'start_time'     : 'START_TIME',     # start time as HH::MM:SS
         'start_time'     : 'START_TIME',     # start time as HH::MM:SS
@@ -565,7 +566,7 @@ class TemporalAlgebraLexer(object):
     t_T_REL_OPERATOR     = r'\{([a-zA-Z\| ])+\}'
     t_T_REL_OPERATOR     = r'\{([a-zA-Z\| ])+\}'
     t_T_SELECT           = r':'
     t_T_SELECT           = r':'
     t_T_NOT_SELECT       = r'!:'
     t_T_NOT_SELECT       = r'!:'
-    t_LPAREN             = r'\('    
+    t_LPAREN             = r'\('
     t_RPAREN             = r'\)'
     t_RPAREN             = r'\)'
     t_COMMA              = r','
     t_COMMA              = r','
     t_CEQUALS            = r'=='
     t_CEQUALS            = r'=='
@@ -664,7 +665,7 @@ class TemporalAlgebraLexer(object):
         while True:
         while True:
              tok = self.lexer.token()
              tok = self.lexer.token()
              if not tok: break
              if not tok: break
-             print tok
+             print(tok)
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -736,7 +737,7 @@ class TemporalAlgebraParser(object):
         ('left', 'AND', 'OR', 'T_COMP_OPERATOR'), #2
         ('left', 'AND', 'OR', 'T_COMP_OPERATOR'), #2
         )
         )
 
 
-    def __init__(self, pid=None, run = True, debug = False, spatial = False, 
+    def __init__(self, pid=None, run = True, debug = False, spatial = False,
                         null = False, register_null = False,  nprocs = 1):
                         null = False, register_null = False,  nprocs = 1):
         self.run = run
         self.run = run
         self.debug = debug
         self.debug = debug
@@ -761,45 +762,45 @@ class TemporalAlgebraParser(object):
     def __del__(self):
     def __del__(self):
         if self.dbif.connected:
         if self.dbif.connected:
             self.dbif.close()
             self.dbif.close()
-            
+
     def setup_common_granularity(self,  expression,  stdstype = 'strds',  lexer = None):
     def setup_common_granularity(self,  expression,  stdstype = 'strds',  lexer = None):
         """Configure the temporal algebra to use the common granularity of all
         """Configure the temporal algebra to use the common granularity of all
              space time datasets in the expression to generate the map lists.
              space time datasets in the expression to generate the map lists.
-             
+
              This function will analyze the expression to detect space time datasets
              This function will analyze the expression to detect space time datasets
              and computes the common granularity from all granularities.
              and computes the common granularity from all granularities.
-          
+
              This granularity is then be used to generate the map lists. Hence, all
              This granularity is then be used to generate the map lists. Hence, all
              maps from all STDS will have equidistant temporal extents. The only meaningful
              maps from all STDS will have equidistant temporal extents. The only meaningful
              temporal relation is "equal".
              temporal relation is "equal".
-             
+
              :param expression: The algebra expression to analyze
              :param expression: The algebra expression to analyze
-             
+
              :param lexer: The temporal algebra lexer (select, raster, voxel, vector) that should be used to
              :param lexer: The temporal algebra lexer (select, raster, voxel, vector) that should be used to
                                     parse the expression, default is TemporalAlgebraLexer
                                     parse the expression, default is TemporalAlgebraLexer
-             
+
              :return: True if successful, False otherwise
              :return: True if successful, False otherwise
- 
+
         """
         """
         l = lexer
         l = lexer
         # Split the expression to ignore the left part
         # Split the expression to ignore the left part
         expressions = expression.split("=")[1:]
         expressions = expression.split("=")[1:]
         expression = " ".join(expressions)
         expression = " ".join(expressions)
-        
+
         # Check if spatio-temporal operators are present in the expression
         # Check if spatio-temporal operators are present in the expression
         if "{" in expression or "}" in expression:
         if "{" in expression or "}" in expression:
             self.msgr.error(_("Spatio temporal operators are not supported in granularity algebra mode"))
             self.msgr.error(_("Spatio temporal operators are not supported in granularity algebra mode"))
             return False
             return False
-            
+
         # detect all STDS
         # detect all STDS
         if l is None:
         if l is None:
             l = TemporalAlgebraLexer()
             l = TemporalAlgebraLexer()
         l.build()
         l.build()
         l.lexer.input(expression)
         l.lexer.input(expression)
-        
+
         name_list = []
         name_list = []
         tokens = []
         tokens = []
-        
+
         count = 0
         count = 0
         while True:
         while True:
             tok = l.lexer.token()
             tok = l.lexer.token()
@@ -811,7 +812,7 @@ class TemporalAlgebraParser(object):
             if count > 1:
             if count > 1:
                 if tokens[count - 2] == "MAP" or tokens[count - 2] == "TMAP":
                 if tokens[count - 2] == "MAP" or tokens[count - 2] == "TMAP":
                     ignore = True
                     ignore = True
-            
+
             if tok.type == "NAME" and ignore == False:
             if tok.type == "NAME" and ignore == False:
                 name_list.append(tok.value)
                 name_list.append(tok.value)
             count += 1
             count += 1
@@ -831,23 +832,23 @@ class TemporalAlgebraParser(object):
             grans.append(stds.get_granularity())
             grans.append(stds.get_granularity())
             start_times.append(stds.get_temporal_extent_as_tuple()[0])
             start_times.append(stds.get_temporal_extent_as_tuple()[0])
             ttypes[stds.get_temporal_type()] = stds.get_temporal_type()
             ttypes[stds.get_temporal_type()] = stds.get_temporal_type()
-        
+
         # Only one temporal type is allowed
         # Only one temporal type is allowed
         if len(ttypes) > 1:
         if len(ttypes) > 1:
             self.msgr.error(_("All input space time datasets must have the same temporal type."))
             self.msgr.error(_("All input space time datasets must have the same temporal type."))
             return False
             return False
-            
+
         # Compute the common granularity
         # Compute the common granularity
         if "absolute" in ttypes.keys():
         if "absolute" in ttypes.keys():
             self.granularity = compute_common_absolute_time_granularity(grans, start_times)
             self.granularity = compute_common_absolute_time_granularity(grans, start_times)
         else:
         else:
             self.granularity = compute_common_relative_time_granularity(grans)
             self.granularity = compute_common_relative_time_granularity(grans)
-            
+
         self.use_granularity = True
         self.use_granularity = True
-        
+
         return True
         return True
 
 
-    def parse(self, expression, stdstype = 'strds', maptype = 'rast',  mapclass = RasterDataset, 
+    def parse(self, expression, stdstype = 'strds', maptype = 'rast',  mapclass = RasterDataset,
                       basename = None, overwrite=False):
                       basename = None, overwrite=False):
         self.lexer = TemporalAlgebraLexer()
         self.lexer = TemporalAlgebraLexer()
         self.lexer.build()
         self.lexer.build()
@@ -877,7 +878,7 @@ class TemporalAlgebraParser(object):
         self.names[name] = name
         self.names[name] = name
         return name
         return name
 
 
-    def generate_new_map(self, base_map, bool_op = 'and', copy = True,  rename = True, 
+    def generate_new_map(self, base_map, bool_op = 'and', copy = True,  rename = True,
                                               remove = False):
                                               remove = False):
         """Generate a new map using the spatio-temporal extent of the base map
         """Generate a new map using the spatio-temporal extent of the base map
 
 
@@ -967,7 +968,7 @@ class TemporalAlgebraParser(object):
                 if temp_ext != None:
                 if temp_ext != None:
                     mapA.set_temporal_extent(temp_ext)
                     mapA.set_temporal_extent(temp_ext)
                 else:
                 else:
-                    returncode = 0                   
+                    returncode = 0
             elif temp_op == 'd':
             elif temp_op == 'd':
                 temp_ext = mapA.temporal_disjoint_union(mapB)
                 temp_ext = mapA.temporal_disjoint_union(mapB)
                 if temp_ext != None:
                 if temp_ext != None:
@@ -983,25 +984,25 @@ class TemporalAlgebraParser(object):
         return(returncode)
         return(returncode)
 
 
     def set_temporal_extent_list(self, maplist, topolist = ["EQUAL"], temporal = 'l' ):
     def set_temporal_extent_list(self, maplist, topolist = ["EQUAL"], temporal = 'l' ):
-        """ Change temporal extent of map list based on temporal relations to 
+        """ Change temporal extent of map list based on temporal relations to
                 other map list and given temporal operator.
                 other map list and given temporal operator.
 
 
-            :param maplist: List of map objects for which relations has been build 
+            :param maplist: List of map objects for which relations has been build
                                         correctely.
                                         correctely.
             :param topolist: List of strings of temporal relations.
             :param topolist: List of strings of temporal relations.
             :param temporal: The temporal operator specifying the temporal
             :param temporal: The temporal operator specifying the temporal
-                                            extent operation (intersection, union, disjoint 
+                                            extent operation (intersection, union, disjoint
                                             union, right reference, left reference).
                                             union, right reference, left reference).
 
 
             :return: Map list with specified temporal extent.
             :return: Map list with specified temporal extent.
         """
         """
         resultdict = {}
         resultdict = {}
-        
+
         for map_i in maplist:
         for map_i in maplist:
             # Loop over temporal related maps and create overlay modules.
             # Loop over temporal related maps and create overlay modules.
             tbrelations = map_i.get_temporal_relations()
             tbrelations = map_i.get_temporal_relations()
             # Generate an intermediate map for the result map list.
             # Generate an intermediate map for the result map list.
-            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', 
+            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
                                                                         copy = True,  rename = True)
                                                                         copy = True,  rename = True)
             # Combine temporal and spatial extents of intermediate map with related maps.
             # Combine temporal and spatial extents of intermediate map with related maps.
             for topo in topolist:
             for topo in topolist:
@@ -1009,7 +1010,7 @@ class TemporalAlgebraParser(object):
                     for map_j in (tbrelations[topo]):
                     for map_j in (tbrelations[topo]):
                         if temporal == 'r':
                         if temporal == 'r':
                             # Generate an intermediate map for the result map list.
                             # Generate an intermediate map for the result map list.
-                            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', 
+                            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
                                                                                         copy = True,  rename = True)
                                                                                         copy = True,  rename = True)
                         # Create overlayed map extent.
                         # Create overlayed map extent.
                         returncode = self.overlay_map_extent(map_new, map_j, 'and', \
                         returncode = self.overlay_map_extent(map_new, map_j, 'and', \
@@ -1024,10 +1025,10 @@ class TemporalAlgebraParser(object):
                             # print(map_new.cmd_list)
                             # print(map_new.cmd_list)
                             # resultlist.append(map_new)
                             # resultlist.append(map_new)
                             resultdict[map_new.get_id()] = map_new
                             resultdict[map_new.get_id()] = map_new
-        
+
                         # Create r.mapcalc expression string for the operation.
                         # Create r.mapcalc expression string for the operation.
-                        #cmdstring = self.build_command_string(s_expr_a = map_new,  
-                        #                                                                s_expr_b = map_j,  
+                        #cmdstring = self.build_command_string(s_expr_a = map_new,
+                        #                                                                s_expr_b = map_j,
                         #                                                                operator = function)
                         #                                                                operator = function)
                         # Conditional append of module command.
                         # Conditional append of module command.
                         #map_new.cmd_list = cmdstring
                         #map_new.cmd_list = cmdstring
@@ -1039,24 +1040,24 @@ class TemporalAlgebraParser(object):
         # Get sorted map objects as values from result dictionoary.
         # Get sorted map objects as values from result dictionoary.
         resultlist = resultdict.values()
         resultlist = resultdict.values()
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
-        
+
         return(resultlist)
         return(resultlist)
-    
+
     ######################### Temporal functions ##############################
     ######################### Temporal functions ##############################
 
 
     def remove_maps(self):
     def remove_maps(self):
         """Removes empty or intermediate maps of different type.
         """Removes empty or intermediate maps of different type.
         """
         """
-        
+
         map_names = {}
         map_names = {}
         map_names["raster"] = []
         map_names["raster"] = []
         map_names["raster3d"] = []
         map_names["raster3d"] = []
         map_names["vector"] = []
         map_names["vector"] = []
-                
+
         if self.removable_maps:
         if self.removable_maps:
             for map in self.removable_maps.values():
             for map in self.removable_maps.values():
                     map_names[map.get_type()].append(map.get_name())
                     map_names[map.get_type()].append(map.get_name())
-        
+
         for key in map_names.keys():
         for key in map_names.keys():
             if map_names[key]:
             if map_names[key]:
                 self.msgr.message(_("Removing un-needed or empty %s maps"%(key)))
                 self.msgr.message(_("Removing un-needed or empty %s maps"%(key)))
@@ -1064,7 +1065,7 @@ class TemporalAlgebraParser(object):
 
 
     def _remove_maps(self,  namelist,  map_type):
     def _remove_maps(self,  namelist,  map_type):
         """Remove maps of specific type
         """Remove maps of specific type
-        
+
             :param namelist: List of map names to be removed
             :param namelist: List of map names to be removed
             :param map_type: The type of the maps  (raster, raster_3d or vector)
             :param map_type: The type of the maps  (raster, raster_3d or vector)
         """
         """
@@ -1072,13 +1073,13 @@ class TemporalAlgebraParser(object):
         chunklist = [namelist[i:i + max] for i in range(0, len(namelist), max)]
         chunklist = [namelist[i:i + max] for i in range(0, len(namelist), max)]
         for chunk in chunklist:
         for chunk in chunklist:
             stringlist = ",".join(chunk)
             stringlist = ",".join(chunk)
-            
+
             if self.run:
             if self.run:
                 m = copy.deepcopy(self.m_mremove)
                 m = copy.deepcopy(self.m_mremove)
                 m.inputs["type"].value = map_type
                 m.inputs["type"].value = map_type
                 m.inputs["name"].value = stringlist
                 m.inputs["name"].value = stringlist
                 m.flags["f"].value = True
                 m.flags["f"].value = True
-                print m.get_bash()
+                print(m.get_bash())
                 m.run()
                 m.run()
 
 
     def check_stds(self, input, clear = False,  stds_type = None,  check_type=True):
     def check_stds(self, input, clear = False,  stds_type = None,  check_type=True):
@@ -1087,7 +1088,7 @@ class TemporalAlgebraParser(object):
             :param input: Name of space time data set as string or list of maps.
             :param input: Name of space time data set as string or list of maps.
             :param clear: Reset the stored conditional values to empty list.
             :param clear: Reset the stored conditional values to empty list.
             :param check_type: Check the type of the space time dataset to match the global stds type
             :param check_type: Check the type of the space time dataset to match the global stds type
-            :param stds_type: The type of the space time dataset to be opened, if not provided 
+            :param stds_type: The type of the space time dataset to be opened, if not provided
                                           then self.stdstype will be used
                                           then self.stdstype will be used
 
 
             :return: List of maps.
             :return: List of maps.
@@ -1143,7 +1144,7 @@ class TemporalAlgebraParser(object):
         elif isinstance(input,  self.mapclass):
         elif isinstance(input,  self.mapclass):
             # Check if the input is a single map and return it as list with one entry.
             # Check if the input is a single map and return it as list with one entry.
             maplist = [input]
             maplist = [input]
-        
+
         elif isinstance(input,  list):
         elif isinstance(input,  list):
             maplist = input
             maplist = input
             # Create map_value as empty list item.
             # Create map_value as empty list item.
@@ -1158,19 +1159,19 @@ class TemporalAlgebraParser(object):
                     map_i.condition_value = []
                     map_i.condition_value = []
         else:
         else:
             self.msgr.fatal(_("Wrong type of input " + str(input)))
             self.msgr.fatal(_("Wrong type of input " + str(input)))
-            
+
         # We generate a unique map id that will be used
         # We generate a unique map id that will be used
-        # in the topology analysis, since the maplist can 
-        # contain maps with equal map ids 
+        # in the topology analysis, since the maplist can
+        # contain maps with equal map ids
         for map in maplist:
         for map in maplist:
             map.uid = self.generate_map_name()
             map.uid = self.generate_map_name()
             if self.debug:
             if self.debug:
-                print map.get_name(), map.uid,  map.get_temporal_extent_as_tuple()
-        
+                print(map.get_name(), map.uid,  map.get_temporal_extent_as_tuple())
+
         return(maplist)
         return(maplist)
 
 
     def get_temporal_topo_list(self, maplistA, maplistB = None, topolist = ["EQUAL"],
     def get_temporal_topo_list(self, maplistA, maplistB = None, topolist = ["EQUAL"],
-                               assign_val = False, count_map = False, compare_bool = False,  
+                               assign_val = False, count_map = False, compare_bool = False,
                                compop = None, aggregate = None):
                                compop = None, aggregate = None):
         """Build temporal topology for two space time data sets, copy map objects
         """Build temporal topology for two space time data sets, copy map objects
           for given relation into map list.
           for given relation into map list.
@@ -1187,7 +1188,7 @@ class TemporalAlgebraParser(object):
                             related map list and compariosn operator.
                             related map list and compariosn operator.
           :param compop: Comparison operator, && or ||.
           :param compop: Comparison operator, && or ||.
           :param aggregate: Aggregation operator for relation map list, & or |.
           :param aggregate: Aggregation operator for relation map list, & or |.
-          
+
           :return: List of maps from maplistA that fulfil the topological relationships
           :return: List of maps from maplistA that fulfil the topological relationships
                   to maplistB specified in topolist.
                   to maplistB specified in topolist.
 
 
@@ -1215,8 +1216,8 @@ class TemporalAlgebraParser(object):
               >>> for map in resultlist:
               >>> for map in resultlist:
               ...     if map.get_equal():
               ...     if map.get_equal():
               ...         relations = map.get_equal()
               ...         relations = map.get_equal()
-              ...         print "Map %s has equal relation to map %s"%(map.get_name(),
-              ...               relations[0].get_name())
+              ...         print("Map %s has equal relation to map %s"%(map.get_name(),
+              ...               relations[0].get_name()))
               Map a0 has equal relation to map b0
               Map a0 has equal relation to map b0
               Map a1 has equal relation to map b1
               Map a1 has equal relation to map b1
               Map a2 has equal relation to map b2
               Map a2 has equal relation to map b2
@@ -1248,8 +1249,8 @@ class TemporalAlgebraParser(object):
               >>> for map in resultlist:
               >>> for map in resultlist:
               ...     if map.get_starts():
               ...     if map.get_starts():
               ...         relations = map.get_starts()
               ...         relations = map.get_starts()
-              ...         print "Map %s has start relation to map %s"%(map.get_name(),
-              ...               relations[0].get_name())
+              ...         print("Map %s has start relation to map %s"%(map.get_name(),
+              ...               relations[0].get_name()))
               Map a0 has start relation to map b0
               Map a0 has start relation to map b0
               Map a1 has start relation to map b1
               Map a1 has start relation to map b1
               Map a2 has start relation to map b2
               Map a2 has start relation to map b2
@@ -1263,8 +1264,8 @@ class TemporalAlgebraParser(object):
               >>> for map in resultlist:
               >>> for map in resultlist:
               ...     if map.get_during():
               ...     if map.get_during():
               ...         relations = map.get_during()
               ...         relations = map.get_during()
-              ...         print "Map %s has during relation to map %s"%(map.get_name(),
-              ...               relations[0].get_name())
+              ...         print("Map %s has during relation to map %s"%(map.get_name(),
+              ...               relations[0].get_name()))
               Map a0 has during relation to map b0
               Map a0 has during relation to map b0
               Map a1 has during relation to map b0
               Map a1 has during relation to map b0
               Map a2 has during relation to map b1
               Map a2 has during relation to map b1
@@ -1366,22 +1367,22 @@ class TemporalAlgebraParser(object):
                     # Use unique identifier, since map names may be equal
                     # Use unique identifier, since map names may be equal
                     resultdict[map_i.uid] = map_i
                     resultdict[map_i.uid] = map_i
         resultlist = resultdict.values()
         resultlist = resultdict.values()
-        
+
         # Sort list of maps chronological.
         # Sort list of maps chronological.
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
-        
+
         return(resultlist)
         return(resultlist)
-    
+
     def assign_bool_value(self,  map_i, tbrelations, topolist = ["EQUAL"]):
     def assign_bool_value(self,  map_i, tbrelations, topolist = ["EQUAL"]):
-        """ Function to assign boolean map value based on the map_values from the 
+        """ Function to assign boolean map value based on the map_values from the
                 compared map list by topological relationships.
                 compared map list by topological relationships.
-                
+
           :param map_i: Map object with temporal extent.
           :param map_i: Map object with temporal extent.
           :param tbrelations: List of temporal relation to map_i.
           :param tbrelations: List of temporal relation to map_i.
           :param topolist: List of strings for given temporal relations.
           :param topolist: List of strings for given temporal relations.
-          
-          :return: Map object with conditional value that has been assigned by 
-                        relation maps that fulfil the topological relationships to 
+
+          :return: Map object with conditional value that has been assigned by
+                        relation maps that fulfil the topological relationships to
                         maplistB specified in topolist.
                         maplistB specified in topolist.
         """
         """
         condition_value_list = []
         condition_value_list = []
@@ -1400,19 +1401,19 @@ class TemporalAlgebraParser(object):
         else:
         else:
             resultbool = False
             resultbool = False
         map_i.condition_value = [resultbool]
         map_i.condition_value = [resultbool]
-        
+
         return(resultbool)
         return(resultbool)
 
 
     def compare_bool_value(self,  map_i, tbrelations, compop, aggregate,  topolist = ["EQUAL"]):
     def compare_bool_value(self,  map_i, tbrelations, compop, aggregate,  topolist = ["EQUAL"]):
-        """ Function to evaluate two map lists with boolean values by boolean 
-            comparison operator. 
-            
+        """ Function to evaluate two map lists with boolean values by boolean
+            comparison operator.
+
           :param map_i: Map object with temporal extent.
           :param map_i: Map object with temporal extent.
           :param tbrelations: List of temporal relation to map_i.
           :param tbrelations: List of temporal relation to map_i.
           :param topolist: List of strings for given temporal relations.
           :param topolist: List of strings for given temporal relations.
           :param compop: Comparison operator, && or ||.
           :param compop: Comparison operator, && or ||.
           :param aggregate: Aggregation operator for relation map list, & or |.
           :param aggregate: Aggregation operator for relation map list, & or |.
-          
+
           :return: Map object with conditional value that has been evaluated by
           :return: Map object with conditional value that has been evaluated by
                         comparison operators.
                         comparison operators.
         """
         """
@@ -1444,20 +1445,20 @@ class TemporalAlgebraParser(object):
             print(resultbool)
             print(resultbool)
         # Add boolean value to result list.
         # Add boolean value to result list.
         map_i.condition_value = [resultbool]
         map_i.condition_value = [resultbool]
-        
+
         return(resultbool)
         return(resultbool)
-    
+
     def eval_toperator(self, operator, optype = 'relation'):
     def eval_toperator(self, operator, optype = 'relation'):
         """This function evaluates a string containing temporal operations.
         """This function evaluates a string containing temporal operations.
 
 
          :param operator: String of temporal operations, e.g. {!=,equal|during,l}.
          :param operator: String of temporal operations, e.g. {!=,equal|during,l}.
          :param optype: String to define operator type.
          :param optype: String to define operator type.
-         
+
          :return :List of temporal relations (equal, during), the given function
          :return :List of temporal relations (equal, during), the given function
           (!:) and the interval/instances (l).
           (!:) and the interval/instances (l).
-          
+
         .. code-block:: python
         .. code-block:: python
-        
+
              >>> import grass.temporal as tgis
              >>> import grass.temporal as tgis
              >>> tgis.init()
              >>> tgis.init()
              >>> p = tgis.TemporalOperatorParser()
              >>> p = tgis.TemporalOperatorParser()
@@ -1470,7 +1471,7 @@ class TemporalAlgebraParser(object):
         p = TemporalOperatorParser()
         p = TemporalOperatorParser()
         p.parse(operator, optype)
         p.parse(operator, optype)
         p.relations = [rel.upper() for rel in p.relations]
         p.relations = [rel.upper() for rel in p.relations]
-        
+
         return(p.relations, p.temporal, p.function,  p.aggregate)
         return(p.relations, p.temporal, p.function,  p.aggregate)
 
 
     def perform_temporal_selection(self, maplistA, maplistB, topolist = ["EQUAL"],
     def perform_temporal_selection(self, maplistA, maplistB, topolist = ["EQUAL"],
@@ -1515,8 +1516,8 @@ class TemporalAlgebraParser(object):
               >>> for map in resultlist:
               >>> for map in resultlist:
               ...     if map.get_equal():
               ...     if map.get_equal():
               ...         relations = map.get_equal()
               ...         relations = map.get_equal()
-              ...         print "Map %s has equal relation to map %s"%(map.get_name(),
-              ...               relations[0].get_name())
+              ...         print("Map %s has equal relation to map %s"%(map.get_name(),
+              ...               relations[0].get_name()))
               Map a5 has equal relation to map b0
               Map a5 has equal relation to map b0
               Map a6 has equal relation to map b1
               Map a6 has equal relation to map b1
               Map a7 has equal relation to map b2
               Map a7 has equal relation to map b2
@@ -1526,7 +1527,7 @@ class TemporalAlgebraParser(object):
               ...                                           True)
               ...                                           True)
               >>> for map in resultlist:
               >>> for map in resultlist:
               ...     if not map.get_equal():
               ...     if not map.get_equal():
-              ...         print "Map %s has no equal relation to mapset mapsB"%(map.get_name())
+              ...         print("Map %s has no equal relation to mapset mapsB"%(map.get_name()))
               Map a0 has no equal relation to mapset mapsB
               Map a0 has no equal relation to mapset mapsB
               Map a1 has no equal relation to mapset mapsB
               Map a1 has no equal relation to mapset mapsB
               Map a2 has no equal relation to mapset mapsB
               Map a2 has no equal relation to mapset mapsB
@@ -1662,7 +1663,7 @@ class TemporalAlgebraParser(object):
             if unchanged == True:
             if unchanged == True:
                 if self.debug:
                 if self.debug:
                     print('Leave temporal extend of result map: ' +  map_i.get_map_id() + ' unchanged.')
                     print('Leave temporal extend of result map: ' +  map_i.get_map_id() + ' unchanged.')
-        
+
         resultlist = resultdict.values()
         resultlist = resultdict.values()
         # Sort list of maps chronological.
         # Sort list of maps chronological.
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
@@ -1682,7 +1683,7 @@ class TemporalAlgebraParser(object):
           :return: Dictionary with temporal functions for given input map.
           :return: Dictionary with temporal functions for given input map.
 
 
           .. code-block:: python
           .. code-block:: python
-          
+
               >>> import grass.temporal as tgis
               >>> import grass.temporal as tgis
               >>> import datetime
               >>> import datetime
               >>> tgis.init()
               >>> tgis.init()
@@ -1853,14 +1854,14 @@ class TemporalAlgebraParser(object):
         """ This function evaluates temporal variable expressions of a conditional
         """ This function evaluates temporal variable expressions of a conditional
              expression in two steps.
              expression in two steps.
              At first it combines stepwise the single conditions by their relations with LALR.
              At first it combines stepwise the single conditions by their relations with LALR.
-             In this prossess sub condition map lists will be created which will include 
-             information of the underlying single conditions. Important: The temporal 
-             relations between conditions are evaluated by implicit aggregation. 
-             In the second step the aggregated condition map list will be compared with the 
+             In this prossess sub condition map lists will be created which will include
+             information of the underlying single conditions. Important: The temporal
+             relations between conditions are evaluated by implicit aggregation.
+             In the second step the aggregated condition map list will be compared with the
              map list of conclusion statements by the given temporal relation.
              map list of conclusion statements by the given temporal relation.
-             
-             The result is writen as 'condition_value' attribute to the resulting map objects. 
-             These attribute consists of boolean expressions and operators which can be 
+
+             The result is writen as 'condition_value' attribute to the resulting map objects.
+             These attribute consists of boolean expressions and operators which can be
              evaluated with the eval_condition_list function.
              evaluated with the eval_condition_list function.
              [True,  '||', False, '&&', True]
              [True,  '||', False, '&&', True]
 
 
@@ -1873,17 +1874,17 @@ class TemporalAlgebraParser(object):
 
 
              :param thenlist: Map list object of the conclusion statement.
              :param thenlist: Map list object of the conclusion statement.
                          It will be compared and evaluated by the conditions.
                          It will be compared and evaluated by the conditions.
-          
-             :param topolist: List of temporal relations between the conditions and the 
+
+             :param topolist: List of temporal relations between the conditions and the
                          conclusions.
                          conclusions.
-                          
+
              :return: Map list with conditional values for all temporal expressions.
              :return: Map list with conditional values for all temporal expressions.
 
 
         """
         """
-        
-        # Evaluate the temporal variable expression and compute the temporal combination 
+
+        # Evaluate the temporal variable expression and compute the temporal combination
         # of conditions.
         # of conditions.
-        
+
         # Check if the input expression is a valid single global variable.
         # Check if the input expression is a valid single global variable.
         if isinstance(tvarexpr, GlobalTemporalVar) and tvarexpr.get_type() == "global" :
         if isinstance(tvarexpr, GlobalTemporalVar) and tvarexpr.get_type() == "global" :
             # Use method eval_global_var to evaluate expression.
             # Use method eval_global_var to evaluate expression.
@@ -1930,14 +1931,14 @@ class TemporalAlgebraParser(object):
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
 
 
         return(resultlist)
         return(resultlist)
-        
+
     def eval_condition_list(self, maplist, inverse = False):
     def eval_condition_list(self, maplist, inverse = False):
         """ This function evaluates conditional values of a map list.
         """ This function evaluates conditional values of a map list.
              A recursive function is used to evaluate comparison statements
              A recursive function is used to evaluate comparison statements
              from left to right in the given conditional list.
              from left to right in the given conditional list.
 
 
-             For example: 
-            
+             For example:
+
                   - [True,  '||', False, '&&', True]  -> True
                   - [True,  '||', False, '&&', True]  -> True
                   - [True,  '||', False, '&&', False] -> False
                   - [True,  '||', False, '&&', False] -> False
                   - [True,  '&&', False, '&&', True]  -> False
                   - [True,  '&&', False, '&&', True]  -> False
@@ -2021,12 +2022,12 @@ class TemporalAlgebraParser(object):
             if isinstance(t[3], list):
             if isinstance(t[3], list):
                 num = len(t[3])
                 num = len(t[3])
                 count = 0
                 count = 0
-                register_list = []      
+                register_list = []
                 if num > 0:
                 if num > 0:
                     process_queue = pymod.ParallelModuleQueue(int(self.nprocs))
                     process_queue = pymod.ParallelModuleQueue(int(self.nprocs))
                     for map_i in t[3]:
                     for map_i in t[3]:
-                        # Test if temporal extents have been changed by temporal 
-                        # relation operators (i|r). 
+                        # Test if temporal extents have been changed by temporal
+                        # relation operators (i|r).
                         if count == 0:
                         if count == 0:
                             maps_stds_type = map_i.get_new_stds_instance(None).get_type()
                             maps_stds_type = map_i.get_new_stds_instance(None).get_type()
                             map_type = map_i.get_type()
                             map_type = map_i.get_type()
@@ -2082,14 +2083,14 @@ class TemporalAlgebraParser(object):
 
 
                     # Wait for running processes
                     # Wait for running processes
                     process_queue.wait()
                     process_queue.wait()
-                    
+
                     # Open connection to temporal database.
                     # Open connection to temporal database.
-                    # Create result space time dataset based on the map stds type        
+                    # Create result space time dataset based on the map stds type
                     resultstds = open_new_stds(t[1],maps_stds_type, \
                     resultstds = open_new_stds(t[1],maps_stds_type, \
                                                              'absolute', t[1], t[1], \
                                                              'absolute', t[1], t[1], \
                                                              'mean', self.dbif, \
                                                              'mean', self.dbif, \
-                                                             overwrite = self.overwrite)                            
-                    for map_i in register_list:                
+                                                             overwrite = self.overwrite)
+                    for map_i in register_list:
                         # Get meta data from grass database.
                         # Get meta data from grass database.
                         map_i.load()
                         map_i.load()
                         # Check if temporal extents have changed and a new map was created
                         # Check if temporal extents have changed and a new map was created
@@ -2119,7 +2120,7 @@ class TemporalAlgebraParser(object):
                     self.msgr.warning("Empty result space time dataset. "\
                     self.msgr.warning("Empty result space time dataset. "\
                                                   "No map has been registered in %s"  %(t[1] ))
                                                   "No map has been registered in %s"  %(t[1] ))
                     # Open connection to temporal database.
                     # Open connection to temporal database.
-                    # Create result space time dataset.                        
+                    # Create result space time dataset.
                     resultstds = open_new_stds(t[1], self.stdstype, \
                     resultstds = open_new_stds(t[1], self.stdstype, \
                                                              'absolute', t[1], t[1], \
                                                              'absolute', t[1], t[1], \
                                                              'mean', dbif, \
                                                              'mean', dbif, \
@@ -2131,7 +2132,7 @@ class TemporalAlgebraParser(object):
             t[0] = t[3]
             t[0] = t[3]
 
 
         if self.debug:
         if self.debug:
-            print t[1], "=", t[3]
+            print(t[1], "=", t[3])
 
 
     def p_stds_1(self, t):
     def p_stds_1(self, t):
         # Definition of a space time dataset
         # Definition of a space time dataset
@@ -2152,7 +2153,7 @@ class TemporalAlgebraParser(object):
 
 
     def p_expr_strds_function(self, t):
     def p_expr_strds_function(self, t):
         # Explicitly specify a space time raster dataset
         # Explicitly specify a space time raster dataset
-        # R = A : strds(B) 
+        # R = A : strds(B)
         """
         """
         expr : STRDS LPAREN stds RPAREN
         expr : STRDS LPAREN stds RPAREN
         """
         """
@@ -2161,11 +2162,11 @@ class TemporalAlgebraParser(object):
         else:
         else:
             t[0] = t[3]
             t[0] = t[3]
             if self.debug:
             if self.debug:
-                print "Opening STRDS: ",  t[0]
+                print("Opening STRDS: ",  t[0])
 
 
     def p_expr_str3ds_function(self, t):
     def p_expr_str3ds_function(self, t):
         # Explicitly specify a space time raster dataset
         # Explicitly specify a space time raster dataset
-        # R = A : str3ds(B) 
+        # R = A : str3ds(B)
         """
         """
         expr : STR3DS LPAREN stds RPAREN
         expr : STR3DS LPAREN stds RPAREN
         """
         """
@@ -2174,28 +2175,28 @@ class TemporalAlgebraParser(object):
         else:
         else:
             t[0] = t[3]
             t[0] = t[3]
             if self.debug:
             if self.debug:
-                print "Opening STR3DS: ",  t[0]
+                print("Opening STR3DS: ",  t[0])
 
 
     def p_expr_stvds_function(self, t):
     def p_expr_stvds_function(self, t):
         # Explicitly specify a space time vector dataset
         # Explicitly specify a space time vector dataset
-        # R = A : stvds(B) 
+        # R = A : stvds(B)
         """
         """
         expr : STVDS LPAREN stds RPAREN
         expr : STVDS LPAREN stds RPAREN
         """
         """
         if self.run:
         if self.run:
-            print t[3]
+            print(t[3])
             t[0] = self.check_stds(t[3], stds_type = "stvds",  check_type=False)
             t[0] = self.check_stds(t[3], stds_type = "stvds",  check_type=False)
         else:
         else:
             t[0] = t[3]
             t[0] = t[3]
             if self.debug:
             if self.debug:
-                print "Opening STVDS: ",  t[0]
+                print("Opening STVDS: ",  t[0])
 
 
     def p_expr_tmap_function(self, t):
     def p_expr_tmap_function(self, t):
         # Add a single map.
         # Add a single map.
-        # Only the spatial extent of the map is evaluated. 
+        # Only the spatial extent of the map is evaluated.
         # Temporal extent is not existing.
         # Temporal extent is not existing.
         # Examples:
         # Examples:
-        #    R = tmap(A) 
+        #    R = tmap(A)
         """
         """
         expr : TMAP LPAREN stds RPAREN
         expr : TMAP LPAREN stds RPAREN
         """
         """
@@ -2227,7 +2228,7 @@ class TemporalAlgebraParser(object):
             t[0] = "tmap(",  t[3] , ")"
             t[0] = "tmap(",  t[3] , ")"
 
 
         if self.debug:
         if self.debug:
-            print "tmap(", t[3] , ")"
+            print("tmap(", t[3] , ")")
 
 
     def p_expr_tmerge_function(self, t):
     def p_expr_tmerge_function(self, t):
         # Merge two maplists of same STDS type into a result map list.
         # Merge two maplists of same STDS type into a result map list.
@@ -2244,7 +2245,7 @@ class TemporalAlgebraParser(object):
             # Check input map.
             # Check input map.
             maplistA   = self.check_stds(t[3])
             maplistA   = self.check_stds(t[3])
             maplistB   = self.check_stds(t[5])
             maplistB   = self.check_stds(t[5])
-            
+
             # Check empty lists.
             # Check empty lists.
             if len(maplistA) == 0 and len(maplistB) == 0:
             if len(maplistA) == 0 and len(maplistB) == 0:
                 self.msgr.warning(_("Merging empty map lists"))
                 self.msgr.warning(_("Merging empty map lists"))
@@ -2264,14 +2265,14 @@ class TemporalAlgebraParser(object):
                     grass.fatal(_("Space time datasets to merge must have the same temporal type"))
                     grass.fatal(_("Space time datasets to merge must have the same temporal type"))
 
 
                 resultlist = maplistA + maplistB
                 resultlist = maplistA + maplistB
-            
+
             # Return map list.
             # Return map list.
             t[0] = resultlist
             t[0] = resultlist
         else:
         else:
             t[0] = "merge(",  t[3], ",", t[5], ")"
             t[0] = "merge(",  t[3], ",", t[5], ")"
 
 
         if self.debug:
         if self.debug:
-            print "merge(", t[3], ",", t[5], ")"
+            print("merge(", t[3], ",", t[5], ")")
 
 
     def p_t_hash(self,t):
     def p_t_hash(self,t):
         """
         """
@@ -2332,7 +2333,7 @@ class TemporalAlgebraParser(object):
             t[0] = "td(" + str(t[3]) + ")"
             t[0] = "td(" + str(t[3]) + ")"
 
 
         if self.debug:
         if self.debug:
-            print "td(" + str(t[3]) + ")"
+            print("td(" + str(t[3]) + ")")
 
 
 
 
     def p_t_time_var(self, t):
     def p_t_time_var(self, t):
@@ -2396,11 +2397,11 @@ class TemporalAlgebraParser(object):
                         map_i.condition_value = boolname
                         map_i.condition_value = boolname
                 except:
                 except:
                     self.msgr.fatal("Error: the given expression does not contain a correct time difference object.")
                     self.msgr.fatal("Error: the given expression does not contain a correct time difference object.")
-            
+
             t[0] = maplist
             t[0] = maplist
-            
+
         if self.debug:
         if self.debug:
-            print t[1], t[2], t[3]
+            print(t[1], t[2], t[3])
 
 
     def p_t_var_expr_number(self, t):
     def p_t_var_expr_number(self, t):
         # Examples:
         # Examples:
@@ -2409,7 +2410,7 @@ class TemporalAlgebraParser(object):
         #    start_day(B) < start_month(A)
         #    start_day(B) < start_month(A)
         """
         """
         t_var_expr : t_var LPAREN stds RPAREN comp_op number
         t_var_expr : t_var LPAREN stds RPAREN comp_op number
-                | t_var LPAREN expr RPAREN comp_op number      
+                | t_var LPAREN expr RPAREN comp_op number
         """
         """
         # TODO:  Implement comparison operator for map lists.
         # TODO:  Implement comparison operator for map lists.
         #| t_var LPAREN stds RPAREN comp_op t_var LPAREN stds RPAREN
         #| t_var LPAREN stds RPAREN comp_op t_var LPAREN stds RPAREN
@@ -2429,7 +2430,7 @@ class TemporalAlgebraParser(object):
             t[0] = resultlist
             t[0] = resultlist
 
 
         if self.debug:
         if self.debug:
-                print t[1], t[3], t[5], t[6]
+                print(t[1], t[3], t[5], t[6])
 
 
     def p_t_var_expr_time(self, t):
     def p_t_var_expr_time(self, t):
         # Examples:
         # Examples:
@@ -2462,12 +2463,12 @@ class TemporalAlgebraParser(object):
             gvar.value  = t[6]
             gvar.value  = t[6]
             # Evaluate temporal variable for given maplist.
             # Evaluate temporal variable for given maplist.
             resultlist = self.eval_global_var(gvar, maplist)
             resultlist = self.eval_global_var(gvar, maplist)
-            
+
             t[0] = resultlist
             t[0] = resultlist
 
 
 
 
         if self.debug:
         if self.debug:
-            print t[1], t[3],  t[5], t[6]
+            print(t[1], t[3],  t[5], t[6])
 
 
     def p_t_var_expr_comp(self, t):
     def p_t_var_expr_comp(self, t):
         """
         """
@@ -2481,18 +2482,18 @@ class TemporalAlgebraParser(object):
             relations = ["EQUAL"]
             relations = ["EQUAL"]
             temporal = "l"
             temporal = "l"
             function = t[2] + t[3]
             function = t[2] + t[3]
-            aggregate = t[2] 
-            # Build conditional values based on topological relationships.            
+            aggregate = t[2]
+            # Build conditional values based on topological relationships.
             complist = self.get_temporal_topo_list(tvarexprA, tvarexprB, topolist = relations,
             complist = self.get_temporal_topo_list(tvarexprA, tvarexprB, topolist = relations,
                                compare_bool = True, compop = function[0], aggregate = aggregate)
                                compare_bool = True, compop = function[0], aggregate = aggregate)
             # Set temporal extent based on topological relationships.
             # Set temporal extent based on topological relationships.
-            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations,
                                 temporal = temporal)
                                 temporal = temporal)
-            
+
             t[0] = resultlist
             t[0] = resultlist
 
 
         if self.debug:
         if self.debug:
-            print t[1], t[2] + t[3], t[4]
+            print(t[1], t[2] + t[3], t[4])
 
 
     def p_t_var_expr_comp_op(self, t):
     def p_t_var_expr_comp_op(self, t):
         """
         """
@@ -2507,13 +2508,13 @@ class TemporalAlgebraParser(object):
             complist = self.get_temporal_topo_list(tvarexprA, tvarexprB, topolist = relations,
             complist = self.get_temporal_topo_list(tvarexprA, tvarexprB, topolist = relations,
                                compare_bool = True, compop = function[0], aggregate = aggregate)
                                compare_bool = True, compop = function[0], aggregate = aggregate)
             # Set temporal extent based on topological relationships.
             # Set temporal extent based on topological relationships.
-            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations,
                                 temporal = temporal)
                                 temporal = temporal)
 
 
             t[0] = resultlist
             t[0] = resultlist
 
 
         if self.debug:
         if self.debug:
-            print t[1], t[2], t[3]
+            print(t[1], t[2], t[3])
 
 
     def p_expr_t_select(self, t):
     def p_expr_t_select(self, t):
         # Temporal equal selection
         # Temporal equal selection
@@ -2540,7 +2541,7 @@ class TemporalAlgebraParser(object):
             t[0] = t[1] , "*"
             t[0] = t[1] , "*"
 
 
         if self.debug:
         if self.debug:
-            print str(t[1]),  "* = ", t[1], t[2], t[3]
+            print(str(t[1]),  "* = ", t[1], t[2], t[3])
 
 
     def p_expr_t_not_select(self, t):
     def p_expr_t_not_select(self, t):
         # Temporal equal selection
         # Temporal equal selection
@@ -2566,7 +2567,7 @@ class TemporalAlgebraParser(object):
             t[0] = t[1] + "*"
             t[0] = t[1] + "*"
 
 
         if self.debug:
         if self.debug:
-            print t[1] + "* = ", t[1], t[2], t[3]
+            print(t[1] + "* = ", t[1], t[2], t[3])
 
 
 
 
     def p_expr_t_select_operator(self, t):
     def p_expr_t_select_operator(self, t):
@@ -2599,7 +2600,7 @@ class TemporalAlgebraParser(object):
             # Perform selection.
             # Perform selection.
             selectlist = self.perform_temporal_selection(maplistA, maplistB,
             selectlist = self.perform_temporal_selection(maplistA, maplistB,
                          topolist = operators[0], inverse = negation)
                          topolist = operators[0], inverse = negation)
-            selectlist = self.set_granularity(selectlist, maplistB, operators[1], 
+            selectlist = self.set_granularity(selectlist, maplistB, operators[1],
                 operators[0])
                 operators[0])
             # Return map list.
             # Return map list.
             t[0] = selectlist
             t[0] = selectlist
@@ -2607,7 +2608,7 @@ class TemporalAlgebraParser(object):
             t[0] = t[1] + "*"
             t[0] = t[1] + "*"
 
 
         if self.debug:
         if self.debug:
-            print t[1] + "* = ", t[1], t[2], t[3]
+            print(t[1] + "* = ", t[1], t[2], t[3])
 
 
 
 
     def p_expr_condition_if(self, t):
     def p_expr_condition_if(self, t):
@@ -2622,7 +2623,7 @@ class TemporalAlgebraParser(object):
             thenlist     = self.check_stds(t[5])
             thenlist     = self.check_stds(t[5])
             # Get temporal conditional statement.
             # Get temporal conditional statement.
             tvarexpr     = t[3]
             tvarexpr     = t[3]
-            thencond     = self.build_condition_list(tvarexpr, thenlist)      
+            thencond     = self.build_condition_list(tvarexpr, thenlist)
             thenresult   = self.eval_condition_list(thencond)
             thenresult   = self.eval_condition_list(thencond)
             # Clear the map and conditional values of the map list.
             # Clear the map and conditional values of the map list.
             resultlist   = self.check_stds(thenresult, clear = True)
             resultlist   = self.check_stds(thenresult, clear = True)
@@ -2632,7 +2633,7 @@ class TemporalAlgebraParser(object):
             t[0] = t[5] + "*"
             t[0] = t[5] + "*"
 
 
         if self.debug:
         if self.debug:
-            print str(t[5]) + "* = ", "if condition", str(t[3]), ' then ', str(t[5])
+            print(str(t[5]) + "* = ", "if condition", str(t[3]), ' then ', str(t[5]))
 
 
     def p_expr_condition_if_relation(self, t):
     def p_expr_condition_if_relation(self, t):
         # Examples
         # Examples
@@ -2647,8 +2648,8 @@ class TemporalAlgebraParser(object):
             # Get temporal conditional statement.
             # Get temporal conditional statement.
             tvarexpr     = t[5]
             tvarexpr     = t[5]
             topolist     = self.eval_toperator(t[3],  optype = 'relation')[0]
             topolist     = self.eval_toperator(t[3],  optype = 'relation')[0]
-            thencond     = self.build_condition_list(tvarexpr, thenlist, topolist)            
-            thenresult   = self.eval_condition_list(thencond)          
+            thencond     = self.build_condition_list(tvarexpr, thenlist, topolist)
+            thenresult   = self.eval_condition_list(thencond)
             # Clear the map and conditional values of the map list.
             # Clear the map and conditional values of the map list.
             resultlist   = self.check_stds(thenresult, clear = True)
             resultlist   = self.check_stds(thenresult, clear = True)
             # Return resulting map list.
             # Return resulting map list.
@@ -2657,7 +2658,7 @@ class TemporalAlgebraParser(object):
             t[0] = t[7] + "*"
             t[0] = t[7] + "*"
 
 
         if self.debug:
         if self.debug:
-            print "result* = ", "if ", str(t[3]),  "condition", str(t[5]), " then ", str(t[7])
+            print("result* = ", "if ", str(t[3]),  "condition", str(t[5]), " then ", str(t[7]))
 
 
     def p_expr_condition_elif(self, t):
     def p_expr_condition_elif(self, t):
         # Examples
         # Examples
@@ -2690,7 +2691,7 @@ class TemporalAlgebraParser(object):
             t[0] = t[5] + "*"
             t[0] = t[5] + "*"
 
 
         if self.debug:
         if self.debug:
-            print str(t[5]) + "* = ", "if condition", str(t[3]), " then ", str(t[5]), ' else ', str(t[7])
+            print(str(t[5]) + "* = ", "if condition", str(t[3]), " then ", str(t[5]), ' else ', str(t[7]))
 
 
     def p_expr_condition_elif_relation(self, t):
     def p_expr_condition_elif_relation(self, t):
         # Examples
         # Examples
@@ -2730,9 +2731,9 @@ class TemporalAlgebraParser(object):
 
 
         if self.debug:
         if self.debug:
             if t[5]:
             if t[5]:
-                print str(t[7]), "* = ", "if condition", str(t[5]), " then ", str(t[7]), ' else ', str(t[9])
+                print(str(t[7]), "* = ", "if condition", str(t[5]), " then ", str(t[7]), ' else ', str(t[9]))
             else:
             else:
-                print str(t[9]), "* = ", "if condition", str(t[5]), " then ", str(t[7]), ' else ', str(t[9])
+                print(str(t[9]), "* = ", "if condition", str(t[5]), " then ", str(t[7]), ' else ', str(t[9]))
 
 
     def p_expr_t_buff(self, t):
     def p_expr_t_buff(self, t):
         # Examples
         # Examples
@@ -2761,9 +2762,9 @@ class TemporalAlgebraParser(object):
 
 
         if self.debug:
         if self.debug:
             if len(t) == 10:
             if len(t) == 10:
-                print str(t[3]) + "* = buff_t(", str(t[3]), "," , '"', str(t[6]), str(t[7]), '"', ")"
+                print(str(t[3]) + "* = buff_t(", str(t[3]), "," , '"', str(t[6]), str(t[7]), '"', ")")
             elif len(t) == 7:
             elif len(t) == 7:
-                print str(t[3]) + "* = buff_t(", str(t[3]), ",", str(t[5]), ")"
+                print(str(t[3]) + "* = buff_t(", str(t[3]), ",", str(t[5]), ")")
 
 
     def p_expr_t_snap(self, t):
     def p_expr_t_snap(self, t):
         # Examples
         # Examples
@@ -2782,7 +2783,7 @@ class TemporalAlgebraParser(object):
             t[0] = t[3] + "*"
             t[0] = t[3] + "*"
 
 
         if self.debug:
         if self.debug:
-            print str(t[3]) + "* = tsnap(", str(t[3]), ")"
+            print(str(t[3]) + "* = tsnap(", str(t[3]), ")")
 
 
     def p_expr_t_shift(self, t):
     def p_expr_t_shift(self, t):
         # Examples
         # Examples
@@ -2810,9 +2811,9 @@ class TemporalAlgebraParser(object):
 
 
         if self.debug:
         if self.debug:
             if len(t) == 10:
             if len(t) == 10:
-                print str(t[3]) + "* = tshift(", str(t[3]), "," , '"', str(t[6]), str(t[7]), '"', ")"
+                print(str(t[3]) + "* = tshift(", str(t[3]), "," , '"', str(t[6]), str(t[7]), '"', ")")
             elif len(t) == 7:
             elif len(t) == 7:
-                print str(t[3]) + "* = tshift(", str(t[3]), ",", str(t[5]), ")"
+                print(str(t[3]) + "* = tshift(", str(t[3]), ",", str(t[5]), ")")
 
 
     # Handle errors.
     # Handle errors.
     def p_error(self, t):
     def p_error(self, t):

+ 22 - 21
lib/python/temporal/temporal_extent.py

@@ -19,7 +19,8 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-from base import *
+from __future__ import print_function
+from .base import *
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -156,13 +157,13 @@ class TemporalExtent(SQLDatabaseInterface):
                >>> A = TemporalExtent(start_time=5, end_time=8 )
                >>> A = TemporalExtent(start_time=5, end_time=8 )
                >>> B = TemporalExtent(start_time=3, end_time=4 )
                >>> B = TemporalExtent(start_time=3, end_time=4 )
                >>> inter = A.intersect(B)
                >>> inter = A.intersect(B)
-               >>> print inter
+               >>> print(inter)
                None
                None
 
 
                >>> A = TemporalExtent(start_time=5, end_time=8 )
                >>> A = TemporalExtent(start_time=5, end_time=8 )
                >>> B = TemporalExtent(start_time=3, end_time=None )
                >>> B = TemporalExtent(start_time=3, end_time=None )
                >>> inter = A.intersect(B)
                >>> inter = A.intersect(B)
-               >>> print inter
+               >>> print(inter)
                None
                None
 
 
         """
         """
@@ -396,13 +397,13 @@ class TemporalExtent(SQLDatabaseInterface):
                >>> A = TemporalExtent(start_time=5, end_time=8 )
                >>> A = TemporalExtent(start_time=5, end_time=8 )
                >>> B = TemporalExtent(start_time=3, end_time=4 )
                >>> B = TemporalExtent(start_time=3, end_time=4 )
                >>> inter = A.intersect(B)
                >>> inter = A.intersect(B)
-               >>> print inter
+               >>> print(inter)
                None
                None
 
 
                >>> A = TemporalExtent(start_time=5, end_time=8 )
                >>> A = TemporalExtent(start_time=5, end_time=8 )
                >>> B = TemporalExtent(start_time=3, end_time=None )
                >>> B = TemporalExtent(start_time=3, end_time=None )
                >>> inter = A.intersect(B)
                >>> inter = A.intersect(B)
-               >>> print inter
+               >>> print(inter)
                None
                None
 
 
         """
         """
@@ -1028,13 +1029,13 @@ class TemporalExtent(SQLDatabaseInterface):
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " | Start time:................. " + str(self.get_start_time())
-        print " | End time:................... " + str(self.get_end_time())
+        print(" | Start time:................. " + str(self.get_start_time()))
+        print(" | End time:................... " + str(self.get_end_time()))
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
-        print "start_time=" + str(self.get_start_time())
-        print "end_time=" + str(self.get_end_time())
+        print("start_time=" + str(self.get_start_time()))
+        print("end_time=" + str(self.get_end_time()))
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -1052,7 +1053,7 @@ class AbsoluteTemporalExtent(TemporalExtent):
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " +-------------------- Absolute time -----------------------------------------+"
+        print(" +-------------------- Absolute time -----------------------------------------+")
         TemporalExtent.print_info(self)
         TemporalExtent.print_info(self)
 
 
     def print_shell_info(self):
     def print_shell_info(self):
@@ -1177,14 +1178,14 @@ class STDSAbsoluteTime(AbsoluteTemporalExtent):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
         AbsoluteTemporalExtent.print_info(self)
         AbsoluteTemporalExtent.print_info(self)
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " | Granularity:................ " + str(self.get_granularity())
-        print " | Temporal type of maps:...... " + str(self.get_map_time())
+        print(" | Granularity:................ " + str(self.get_granularity()))
+        print(" | Temporal type of maps:...... " + str(self.get_map_time()))
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
         AbsoluteTemporalExtent.print_shell_info(self)
         AbsoluteTemporalExtent.print_shell_info(self)
-        print "granularity=" + str(self.get_granularity())
-        print "map_time=" + str(self.get_map_time())
+        print("granularity=" + str(self.get_granularity()))
+        print("map_time=" + str(self.get_map_time()))
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -1294,14 +1295,14 @@ class RelativeTemporalExtent(TemporalExtent):
     def print_info(self):
     def print_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " +-------------------- Relative time -----------------------------------------+"
+        print(" +-------------------- Relative time -----------------------------------------+")
         TemporalExtent.print_info(self)
         TemporalExtent.print_info(self)
-        print " | Relative time unit:......... " + str(self.get_unit())
+        print(" | Relative time unit:......... " + str(self.get_unit()))
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
         TemporalExtent.print_shell_info(self)
         TemporalExtent.print_shell_info(self)
-        print "unit=" + str(self.get_unit())
+        print("unit=" + str(self.get_unit()))
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -1426,14 +1427,14 @@ class STDSRelativeTime(RelativeTemporalExtent):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
         RelativeTemporalExtent.print_info(self)
         RelativeTemporalExtent.print_info(self)
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
-        print " | Granularity:................ " + str(self.get_granularity())
-        print " | Temporal type of maps:...... " + str(self.get_map_time())
+        print(" | Granularity:................ " + str(self.get_granularity()))
+        print(" | Temporal type of maps:...... " + str(self.get_map_time()))
 
 
     def print_shell_info(self):
     def print_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
         RelativeTemporalExtent.print_shell_info(self)
         RelativeTemporalExtent.print_shell_info(self)
-        print "granularity=" + str(self.get_granularity())
-        print "map_time=" + str(self.get_map_time())
+        print("granularity=" + str(self.get_granularity()))
+        print("map_time=" + str(self.get_map_time()))
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 25 - 25
lib/python/temporal/temporal_granularity.py

@@ -17,8 +17,8 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-from abstract_dataset import *
-from datetime_math import *
+from .abstract_dataset import *
+from .datetime_math import *
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -497,7 +497,7 @@ def compute_absolute_time_granularity(maps):
 
 
 def compute_common_relative_time_granularity(gran_list):
 def compute_common_relative_time_granularity(gran_list):
 	"""Compute the greatest common granule from a list of relative time granules
 	"""Compute the greatest common granule from a list of relative time granules
-    
+
         .. code-block:: python
         .. code-block:: python
 
 
             >>> import grass.temporal as tgis
             >>> import grass.temporal as tgis
@@ -505,7 +505,7 @@ def compute_common_relative_time_granularity(gran_list):
             >>> grans = [1,2,30]
             >>> grans = [1,2,30]
             >>> tgis.compute_common_relative_time_granularity(grans)
             >>> tgis.compute_common_relative_time_granularity(grans)
             1
             1
-            
+
             >>> import grass.temporal as tgis
             >>> import grass.temporal as tgis
             >>> tgis.init()
             >>> tgis.init()
             >>> grans = [10,20,30]
             >>> grans = [10,20,30]
@@ -756,23 +756,23 @@ def compute_common_absolute_time_granularity_simple(gran_list):
             >>> grans = ["1 second", "2 seconds", "30 seconds"]
             >>> grans = ["1 second", "2 seconds", "30 seconds"]
             >>> tgis.compute_common_absolute_time_granularity(grans)
             >>> tgis.compute_common_absolute_time_granularity(grans)
             '1 second'
             '1 second'
-            
+
             >>> grans = ["3 second", "6 seconds", "30 seconds"]
             >>> grans = ["3 second", "6 seconds", "30 seconds"]
             >>> tgis.compute_common_absolute_time_granularity(grans)
             >>> tgis.compute_common_absolute_time_granularity(grans)
             '3 seconds'
             '3 seconds'
-            
+
             >>> grans = ["12 second", "18 seconds", "30 seconds", "10 minutes"]
             >>> grans = ["12 second", "18 seconds", "30 seconds", "10 minutes"]
             >>> tgis.compute_common_absolute_time_granularity(grans)
             >>> tgis.compute_common_absolute_time_granularity(grans)
             '6 seconds'
             '6 seconds'
-            
+
             >>> grans = ["20 second", "10 minutes", "2 hours"]
             >>> grans = ["20 second", "10 minutes", "2 hours"]
             >>> tgis.compute_common_absolute_time_granularity(grans)
             >>> tgis.compute_common_absolute_time_granularity(grans)
             '20 seconds'
             '20 seconds'
-            
+
             >>> grans = ["7200 second", "240 minutes", "1 year"]
             >>> grans = ["7200 second", "240 minutes", "1 year"]
             >>> tgis.compute_common_absolute_time_granularity(grans)
             >>> tgis.compute_common_absolute_time_granularity(grans)
             '7200 seconds'
             '7200 seconds'
-            
+
             >>> grans = ["7200 second", "89 minutes", "1 year"]
             >>> grans = ["7200 second", "89 minutes", "1 year"]
             >>> tgis.compute_common_absolute_time_granularity(grans)
             >>> tgis.compute_common_absolute_time_granularity(grans)
             '60 seconds'
             '60 seconds'
@@ -821,37 +821,37 @@ def compute_common_absolute_time_granularity_simple(gran_list):
             >>> tgis.compute_common_absolute_time_granularity(grans)
             >>> tgis.compute_common_absolute_time_granularity(grans)
             '1 year'
             '1 year'
     """
     """
-    
+
     has_seconds = False # 0
     has_seconds = False # 0
     has_minutes = False # 1
     has_minutes = False # 1
     has_hours = False     # 2
     has_hours = False     # 2
     has_days = False      # 3
     has_days = False      # 3
     has_months = False  # 4
     has_months = False  # 4
     has_years = False     # 5
     has_years = False     # 5
-    
+
     seconds = []
     seconds = []
     minutes = []
     minutes = []
     hours = []
     hours = []
     days = []
     days = []
     months = []
     months = []
     years = []
     years = []
-    
+
     min_gran = 6
     min_gran = 6
     max_gran = -1
     max_gran = -1
-    
+
     for entry in gran_list:
     for entry in gran_list:
         if not check_granularity_string(entry, "absolute"):
         if not check_granularity_string(entry, "absolute"):
             return False
             return False
 
 
         num,  gran = entry.split()
         num,  gran = entry.split()
-        
+
         if gran in ["seconds",  "second"]:
         if gran in ["seconds",  "second"]:
             has_seconds = True
             has_seconds = True
             if min_gran > 0:
             if min_gran > 0:
                 min_gran = 0
                 min_gran = 0
             if max_gran < 0:
             if max_gran < 0:
                 max_gran = 0
                 max_gran = 0
-                
+
             seconds.append(int(num))
             seconds.append(int(num))
 
 
         if gran in ["minutes",  "minute"]:
         if gran in ["minutes",  "minute"]:
@@ -860,7 +860,7 @@ def compute_common_absolute_time_granularity_simple(gran_list):
                 min_gran = 1
                 min_gran = 1
             if max_gran < 1:
             if max_gran < 1:
                 max_gran = 1
                 max_gran = 1
-                
+
             minutes.append(int(num))
             minutes.append(int(num))
 
 
         if gran in ["hours",  "hour"]:
         if gran in ["hours",  "hour"]:
@@ -869,7 +869,7 @@ def compute_common_absolute_time_granularity_simple(gran_list):
                 min_gran = 2
                 min_gran = 2
             if max_gran < 2:
             if max_gran < 2:
                 max_gran = 2
                 max_gran = 2
-                
+
             hours.append(int(num))
             hours.append(int(num))
 
 
         if gran in ["days",  "day"]:
         if gran in ["days",  "day"]:
@@ -878,7 +878,7 @@ def compute_common_absolute_time_granularity_simple(gran_list):
                 min_gran = 3
                 min_gran = 3
             if max_gran < 3:
             if max_gran < 3:
                 max_gran = 3
                 max_gran = 3
-                
+
             days.append(int(num))
             days.append(int(num))
 
 
         if gran in ["months",  "month"]:
         if gran in ["months",  "month"]:
@@ -887,7 +887,7 @@ def compute_common_absolute_time_granularity_simple(gran_list):
                 min_gran = 4
                 min_gran = 4
             if max_gran < 4:
             if max_gran < 4:
                 max_gran = 4
                 max_gran = 4
-                
+
             months.append(int(num))
             months.append(int(num))
 
 
         if gran in ["years",  "year"]:
         if gran in ["years",  "year"]:
@@ -896,9 +896,9 @@ def compute_common_absolute_time_granularity_simple(gran_list):
                 min_gran = 5
                 min_gran = 5
             if max_gran < 5:
             if max_gran < 5:
                 max_gran = 5
                 max_gran = 5
-                
+
             years.append(int(num))
             years.append(int(num))
-            
+
     if has_seconds:
     if has_seconds:
         if has_minutes:
         if has_minutes:
             minutes.sort()
             minutes.sort()
@@ -925,7 +925,7 @@ def compute_common_absolute_time_granularity_simple(gran_list):
         if num > 1:
         if num > 1:
             gran += "s"
             gran += "s"
         return "%i %s"%(num,  gran)
         return "%i %s"%(num,  gran)
-        
+
     elif has_minutes:
     elif has_minutes:
         if has_hours:
         if has_hours:
             hours.sort()
             hours.sort()
@@ -948,7 +948,7 @@ def compute_common_absolute_time_granularity_simple(gran_list):
         if num > 1:
         if num > 1:
             gran += "s"
             gran += "s"
         return "%i %s"%(num,  gran)
         return "%i %s"%(num,  gran)
-        
+
     elif has_hours:
     elif has_hours:
         if has_days:
         if has_days:
             days.sort()
             days.sort()
@@ -995,14 +995,14 @@ def compute_common_absolute_time_granularity_simple(gran_list):
         if num > 1:
         if num > 1:
             gran += "s"
             gran += "s"
         return "%i %s"%(num,  gran)
         return "%i %s"%(num,  gran)
-        
+
     elif has_years:
     elif has_years:
         num = gcd_list(years)
         num = gcd_list(years)
         gran = "year"
         gran = "year"
         if num > 1:
         if num > 1:
             gran += "s"
             gran += "s"
         return "%i %s"%(num,  gran)
         return "%i %s"%(num,  gran)
-        
+
 
 
 ###############################################################################
 ###############################################################################
 # http://akiscode.com/articles/gcd_of_a_list.shtml
 # http://akiscode.com/articles/gcd_of_a_list.shtml

+ 37 - 36
lib/python/temporal/temporal_operator.py

@@ -16,93 +16,94 @@ for details.
     >>> p.parse(expression, optype = 'relation')
     >>> p.parse(expression, optype = 'relation')
     >>> print(p.relations, p.temporal, p.function)
     >>> print(p.relations, p.temporal, p.function)
     (['equal', 'during'], None, None)
     (['equal', 'during'], None, None)
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{contains | starts}"
     >>> expression =  "{contains | starts}"
     >>> p.parse(expression)
     >>> p.parse(expression)
     >>> print(p.relations, p.temporal, p.function)
     >>> print(p.relations, p.temporal, p.function)
     (['contains', 'starts'], None, None)
     (['contains', 'starts'], None, None)
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{&&, during}"
     >>> expression =  "{&&, during}"
     >>> p.parse(expression, optype = 'boolean')
     >>> p.parse(expression, optype = 'boolean')
     >>> print(p.relations, p.temporal, p.function,p.aggregate)
     >>> print(p.relations, p.temporal, p.function,p.aggregate)
     (['during'], 'l', '&&', '&')
     (['during'], 'l', '&&', '&')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{||, equal | during}"
     >>> expression =  "{||, equal | during}"
     >>> p.parse(expression, optype = 'boolean')
     >>> p.parse(expression, optype = 'boolean')
     >>> print(p.relations, p.temporal, p.function,p.aggregate)
     >>> print(p.relations, p.temporal, p.function,p.aggregate)
     (['equal', 'during'], 'l', '||', '|')
     (['equal', 'during'], 'l', '||', '|')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{||, equal | during, &}"
     >>> expression =  "{||, equal | during, &}"
     >>> p.parse(expression, optype = 'boolean')
     >>> p.parse(expression, optype = 'boolean')
     >>> print(p.relations, p.temporal, p.function,p.aggregate)
     >>> print(p.relations, p.temporal, p.function,p.aggregate)
     (['equal', 'during'], 'l', '||', '&')
     (['equal', 'during'], 'l', '||', '&')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{&&, during, |}"
     >>> expression =  "{&&, during, |}"
     >>> p.parse(expression, optype = 'boolean')
     >>> p.parse(expression, optype = 'boolean')
     >>> print(p.relations, p.temporal, p.function,p.aggregate)
     >>> print(p.relations, p.temporal, p.function,p.aggregate)
     (['during'], 'l', '&&', '|')
     (['during'], 'l', '&&', '|')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{&&, during, |, r}"
     >>> expression =  "{&&, during, |, r}"
     >>> p.parse(expression, optype = 'boolean')
     >>> p.parse(expression, optype = 'boolean')
     >>> print(p.relations, p.temporal, p.function,p.aggregate)
     >>> print(p.relations, p.temporal, p.function,p.aggregate)
     (['during'], 'r', '&&', '|')
     (['during'], 'r', '&&', '|')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{&&, during, u}"
     >>> expression =  "{&&, during, u}"
     >>> p.parse(expression, optype = 'boolean')
     >>> p.parse(expression, optype = 'boolean')
     >>> print(p.relations, p.temporal, p.function,p.aggregate)
     >>> print(p.relations, p.temporal, p.function,p.aggregate)
     (['during'], 'u', '&&', '&')
     (['during'], 'u', '&&', '&')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{:, during, r}"
     >>> expression =  "{:, during, r}"
     >>> p.parse(expression, optype = 'select')
     >>> p.parse(expression, optype = 'select')
     >>> print(p.relations, p.temporal, p.function)
     >>> print(p.relations, p.temporal, p.function)
     (['during'], 'r', ':')
     (['during'], 'r', ':')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{!:, equal | contains, d}"
     >>> expression =  "{!:, equal | contains, d}"
     >>> p.parse(expression, optype = 'select')
     >>> p.parse(expression, optype = 'select')
     >>> print(p.relations, p.temporal, p.function)
     >>> print(p.relations, p.temporal, p.function)
     (['equal', 'contains'], 'd', '!:')
     (['equal', 'contains'], 'd', '!:')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{#, during, r}"
     >>> expression =  "{#, during, r}"
     >>> p.parse(expression, optype = 'hash')
     >>> p.parse(expression, optype = 'hash')
     >>> print(p.relations, p.temporal, p.function)
     >>> print(p.relations, p.temporal, p.function)
     (['during'], 'r', '#')
     (['during'], 'r', '#')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{#, equal | contains}"
     >>> expression =  "{#, equal | contains}"
     >>> p.parse(expression, optype = 'hash')
     >>> p.parse(expression, optype = 'hash')
     >>> print(p.relations, p.temporal, p.function)
     >>> print(p.relations, p.temporal, p.function)
     (['equal', 'contains'], 'l', '#')
     (['equal', 'contains'], 'l', '#')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{+, during, r}"
     >>> expression =  "{+, during, r}"
     >>> p.parse(expression, optype = 'raster')
     >>> p.parse(expression, optype = 'raster')
     >>> print(p.relations, p.temporal, p.function)
     >>> print(p.relations, p.temporal, p.function)
     (['during'], 'r', '+')
     (['during'], 'r', '+')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{/, equal | contains}"
     >>> expression =  "{/, equal | contains}"
     >>> p.parse(expression, optype = 'raster')
     >>> p.parse(expression, optype = 'raster')
     >>> print(p.relations, p.temporal, p.function)
     >>> print(p.relations, p.temporal, p.function)
     (['equal', 'contains'], 'l', '/')
     (['equal', 'contains'], 'l', '/')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{+, equal | contains,intersect}"
     >>> expression =  "{+, equal | contains,intersect}"
     >>> p.parse(expression, optype = 'raster')
     >>> p.parse(expression, optype = 'raster')
     >>> print(p.relations, p.temporal, p.function)
     >>> print(p.relations, p.temporal, p.function)
     (['equal', 'contains'], 'i', '+')
     (['equal', 'contains'], 'i', '+')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{*, contains,disjoint}"
     >>> expression =  "{*, contains,disjoint}"
     >>> p.parse(expression, optype = 'raster')
     >>> p.parse(expression, optype = 'raster')
     >>> print(p.relations, p.temporal, p.function)
     >>> print(p.relations, p.temporal, p.function)
     (['contains'], 'd', '*')
     (['contains'], 'd', '*')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{~, equal,left}"
     >>> expression =  "{~, equal,left}"
     >>> p.parse(expression, optype = 'overlay')
     >>> p.parse(expression, optype = 'overlay')
     >>> print(p.relations, p.temporal, p.function)
     >>> print(p.relations, p.temporal, p.function)
     (['equal'], 'l', '~')
     (['equal'], 'l', '~')
-    >>> p = TemporalOperatorParser()    
+    >>> p = TemporalOperatorParser()
     >>> expression =  "{^, over,right}"
     >>> expression =  "{^, over,right}"
     >>> p.parse(expression, optype = 'overlay')
     >>> p.parse(expression, optype = 'overlay')
     >>> print(p.relations, p.temporal, p.function)
     >>> print(p.relations, p.temporal, p.function)
     (['overlaps', 'overlapped'], 'r', '^')
     (['overlaps', 'overlapped'], 'r', '^')
 
 
 """
 """
+from __future__ import print_function
 
 
 try:
 try:
     import ply.lex as lex
     import ply.lex as lex
@@ -134,7 +135,7 @@ class TemporalOperatorLexer(object):
         'COMMA',
         'COMMA',
         'LEFTREF',
         'LEFTREF',
         'RIGHTREF',
         'RIGHTREF',
-        'UNION', 
+        'UNION',
         'DISJOINT',
         'DISJOINT',
         'INTERSECT',
         'INTERSECT',
         'HASH',
         'HASH',
@@ -142,11 +143,11 @@ class TemporalOperatorLexer(object):
         'AND',
         'AND',
         'DISOR',
         'DISOR',
         'XOR',
         'XOR',
-        'NOT',        
+        'NOT',
         'MOD',
         'MOD',
         'DIV',
         'DIV',
         'MULT',
         'MULT',
-        'ADD',      
+        'ADD',
         'SUB',
         'SUB',
         'T_SELECT',
         'T_SELECT',
         'T_NOT_SELECT',
         'T_NOT_SELECT',
@@ -171,7 +172,7 @@ class TemporalOperatorLexer(object):
     t_AND                        = r'[&]'
     t_AND                        = r'[&]'
     t_DISOR                     = r'\+'
     t_DISOR                     = r'\+'
     t_XOR                         = r'\^'
     t_XOR                         = r'\^'
-    t_NOT                         = r'\~'    
+    t_NOT                         = r'\~'
     t_MOD                       = r'[\%]'
     t_MOD                       = r'[\%]'
     t_DIV                         = r'[\/]'
     t_DIV                         = r'[\/]'
     t_MULT                      = r'[\*]'
     t_MULT                      = r'[\*]'
@@ -234,7 +235,7 @@ class TemporalOperatorLexer(object):
         while True:
         while True:
              tok = self.lexer.token()
              tok = self.lexer.token()
              if not tok: break
              if not tok: break
-             print tok
+             print(tok)
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -251,19 +252,19 @@ class TemporalOperatorParser(object):
         self.aggregate = None
         self.aggregate = None
 
 
     def parse(self, expression,  optype = 'relation'):
     def parse(self, expression,  optype = 'relation'):
-        self.optype = optype        
+        self.optype = optype
         self.parser.parse(expression)
         self.parser.parse(expression)
-        # The parameter optype can be of type: select {:, during, r}, boolean{&&, contains, |}, 
+        # The parameter optype can be of type: select {:, during, r}, boolean{&&, contains, |},
         #                                                            raster{*, equal, |}, vector {|, starts, &},
         #                                                            raster{*, equal, |}, vector {|, starts, &},
         #                                                            hash{#, during, l} or relation {during}.
         #                                                            hash{#, during, l} or relation {during}.
-    
+
     # Error rule for syntax errors.
     # Error rule for syntax errors.
     def p_error(self, t):
     def p_error(self, t):
         raise SyntaxError("Unexpected syntax error")
         raise SyntaxError("Unexpected syntax error")
 
 
     # Get the tokens from the lexer class
     # Get the tokens from the lexer class
     tokens = TemporalOperatorLexer.tokens
     tokens = TemporalOperatorLexer.tokens
- 
+
     def p_relation_operator(self, t):
     def p_relation_operator(self, t):
         # The expression should always return a list of maps.
         # The expression should always return a list of maps.
         """
         """
@@ -294,7 +295,7 @@ class TemporalOperatorParser(object):
         """
         """
         if not self.optype == 'boolean':
         if not self.optype == 'boolean':
             raise SyntaxError("invalid syntax")
             raise SyntaxError("invalid syntax")
-        else:        
+        else:
             # Set three operator components.
             # Set three operator components.
             if isinstance(t[5], list):
             if isinstance(t[5], list):
                 self.relations = t[5]
                 self.relations = t[5]
@@ -303,7 +304,7 @@ class TemporalOperatorParser(object):
             self.temporal  = "l"
             self.temporal  = "l"
             self.function  = t[2] + t[3]
             self.function  = t[2] + t[3]
             self.aggregate = t[2]
             self.aggregate = t[2]
-            
+
             t[0] = t[2]
             t[0] = t[2]
 
 
     def p_relation_bool_combi_operator(self, t):
     def p_relation_bool_combi_operator(self, t):
@@ -320,7 +321,7 @@ class TemporalOperatorParser(object):
         """
         """
         if not self.optype == 'boolean':
         if not self.optype == 'boolean':
             raise SyntaxError("invalid syntax")
             raise SyntaxError("invalid syntax")
-        else:        
+        else:
             # Set three operator components.
             # Set three operator components.
             if isinstance(t[5], list):
             if isinstance(t[5], list):
                 self.relations = t[5]
                 self.relations = t[5]
@@ -329,7 +330,7 @@ class TemporalOperatorParser(object):
             self.temporal  = "l"
             self.temporal  = "l"
             self.function  = t[2] + t[3]
             self.function  = t[2] + t[3]
             self.aggregate = t[7]
             self.aggregate = t[7]
-            
+
             t[0] = t[2]
             t[0] = t[2]
 
 
     def p_relation_bool_combi_operator2(self, t):
     def p_relation_bool_combi_operator2(self, t):
@@ -342,7 +343,7 @@ class TemporalOperatorParser(object):
         """
         """
         if not self.optype == 'boolean':
         if not self.optype == 'boolean':
             raise SyntaxError("invalid syntax")
             raise SyntaxError("invalid syntax")
-        else:        
+        else:
             # Set three operator components.
             # Set three operator components.
             if isinstance(t[5], list):
             if isinstance(t[5], list):
                 self.relations = t[5]
                 self.relations = t[5]
@@ -351,9 +352,9 @@ class TemporalOperatorParser(object):
             self.temporal  = t[7]
             self.temporal  = t[7]
             self.function  = t[2] + t[3]
             self.function  = t[2] + t[3]
             self.aggregate = t[2]
             self.aggregate = t[2]
-            
+
             t[0] = t[2]
             t[0] = t[2]
-    
+
     def p_relation_bool_combi_operator3(self, t):
     def p_relation_bool_combi_operator3(self, t):
         # The expression should always return a list of maps.
         # The expression should always return a list of maps.
         """
         """
@@ -368,7 +369,7 @@ class TemporalOperatorParser(object):
         """
         """
         if not self.optype == 'boolean':
         if not self.optype == 'boolean':
             raise SyntaxError("invalid syntax")
             raise SyntaxError("invalid syntax")
-        else:        
+        else:
             # Set three operator components.
             # Set three operator components.
             if isinstance(t[5], list):
             if isinstance(t[5], list):
                 self.relations = t[5]
                 self.relations = t[5]
@@ -377,9 +378,9 @@ class TemporalOperatorParser(object):
             self.temporal  = t[9]
             self.temporal  = t[9]
             self.function  = t[2] + t[3]
             self.function  = t[2] + t[3]
             self.aggregate = t[7]
             self.aggregate = t[7]
-            
+
             t[0] = t[2]
             t[0] = t[2]
-    
+
     def p_select_relation_operator(self, t):
     def p_select_relation_operator(self, t):
         # The expression should always return a list of maps.
         # The expression should always return a list of maps.
         """
         """

+ 2 - 4
lib/python/temporal/temporal_raster3d_algebra.py

@@ -10,9 +10,7 @@ for details.
 :authors: Thomas Leppelt and Soeren Gebbert
 :authors: Thomas Leppelt and Soeren Gebbert
 
 
 """
 """
-
-import grass.pygrass.modules as pygrass
-from temporal_raster_base_algebra import *
+from .temporal_raster_base_algebra import *
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -34,7 +32,7 @@ class TemporalRaster3DAlgebraParser(TemporalRasterBaseAlgebraParser):
         while True:
         while True:
             tok = l.lexer.token()
             tok = l.lexer.token()
             if not tok: break
             if not tok: break
-            
+
             if tok.type == "STVDS" or tok.type == "STRDS" or tok.type == "STR3DS":
             if tok.type == "STVDS" or tok.type == "STRDS" or tok.type == "STR3DS":
                 raise SyntaxError("Syntax error near '%s'" %(tok.type))
                 raise SyntaxError("Syntax error near '%s'" %(tok.type))
 
 

+ 3 - 3
lib/python/temporal/temporal_raster_algebra.py

@@ -52,7 +52,7 @@ for details.
 
 
 """
 """
 
 
-from temporal_raster_base_algebra import *
+from .temporal_raster_base_algebra import *
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -74,10 +74,10 @@ class TemporalRasterAlgebraParser(TemporalRasterBaseAlgebraParser):
         while True:
         while True:
             tok = l.lexer.token()
             tok = l.lexer.token()
             if not tok: break
             if not tok: break
-            
+
             if tok.type == "STVDS" or tok.type == "STRDS" or tok.type == "STR3DS":
             if tok.type == "STVDS" or tok.type == "STRDS" or tok.type == "STR3DS":
                 raise SyntaxError("Syntax error near '%s'" %(tok.type))
                 raise SyntaxError("Syntax error near '%s'" %(tok.type))
-        
+
         self.lexer = TemporalRasterAlgebraLexer()
         self.lexer = TemporalRasterAlgebraLexer()
         self.lexer.build()
         self.lexer.build()
         self.parser = yacc.yacc(module=self, debug=self.debug)
         self.parser = yacc.yacc(module=self, debug=self.debug)

文件差異過大導致無法顯示
+ 183 - 183
lib/python/temporal/temporal_raster_base_algebra.py


+ 50 - 49
lib/python/temporal/temporal_topology_dataset_connector.py

@@ -16,6 +16,7 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
+from __future__ import print_function
 import copy
 import copy
 
 
 
 
@@ -104,7 +105,7 @@ class TemporalTopologyDatasetConnector(object):
             finished=a@P
             finished=a@P
             >>> rlist = tmr.get_temporal_relations()
             >>> rlist = tmr.get_temporal_relations()
             >>> if "FINISHED" in rlist.keys():
             >>> if "FINISHED" in rlist.keys():
-            ...    print rlist["FINISHED"][0].get_id()
+            ...    print(rlist["FINISHED"][0].get_id())
             a@P
             a@P
 
 
     """
     """
@@ -503,85 +504,85 @@ class TemporalTopologyDatasetConnector(object):
     def print_temporal_topology_info(self):
     def print_temporal_topology_info(self):
         """Print information about this class in human readable style"""
         """Print information about this class in human readable style"""
 
 
-        print " +-------------------- Temporal Topology -------------------------------------+"
+        print(" +-------------------- Temporal Topology -------------------------------------+")
         #          0123456789012345678901234567890
         #          0123456789012345678901234567890
         if self.next() is not None:
         if self.next() is not None:
-            print " | Next: ...................... " + str(self.next().get_id())
+            print(" | Next: ...................... " + str(self.next().get_id()))
         if self.prev() is not None:
         if self.prev() is not None:
-            print " | Previous: .................. " + str(self.prev().get_id())
+            print(" | Previous: .................. " + str(self.prev().get_id()))
         if self.equal is not None:
         if self.equal is not None:
-            print " | Equal:...................... " + \
-                self._generate_map_list_string(self.equal)
+            print(" | Equal:...................... " +
+                  self._generate_map_list_string(self.equal))
         if self.follows is not None:
         if self.follows is not None:
-            print " | Follows: ................... " + \
-                self._generate_map_list_string(self.follows)
+            print(" | Follows: ................... " +
+                  self._generate_map_list_string(self.follows))
         if self.precedes is not None:
         if self.precedes is not None:
-            print " | Precedes: .................. " + \
-                self._generate_map_list_string(self.precedes)
+            print(" | Precedes: .................. " +
+                  self._generate_map_list_string(self.precedes))
         if self.overlaps is not None:
         if self.overlaps is not None:
-            print " | Overlaps: .................. " + \
-                self._generate_map_list_string(self.overlaps)
+            print(" | Overlaps: .................. " +
+                  self._generate_map_list_string(self.overlaps))
         if self.overlapped is not None:
         if self.overlapped is not None:
-            print " | Overlapped: ................ " + \
-                self._generate_map_list_string(self.overlapped)
+            print(" | Overlapped: ................ " +
+                  self._generate_map_list_string(self.overlapped))
         if self.during is not None:
         if self.during is not None:
-            print " | During: .................... " + \
-                self._generate_map_list_string(self.during)
+            print(" | During: .................... " +
+                  self._generate_map_list_string(self.during))
         if self.contains is not None:
         if self.contains is not None:
-            print " | Contains: .................. " + \
-                self._generate_map_list_string(self.contains)
+            print(" | Contains: .................. " +
+                  self._generate_map_list_string(self.contains))
         if self.starts is not None:
         if self.starts is not None:
-            print " | Starts:.. .................. " + \
-                self._generate_map_list_string(self.starts)
+            print(" | Starts:.. .................. " +
+                  self._generate_map_list_string(self.starts))
         if self.started is not None:
         if self.started is not None:
-            print " | Started:. .................. " + \
-                self._generate_map_list_string(self.started)
+            print(" | Started:. .................. " +
+                  self._generate_map_list_string(self.started))
         if self.finishes is not None:
         if self.finishes is not None:
-            print " | Finishes:................... " + \
-                self._generate_map_list_string(self.finishes)
+            print(" | Finishes:................... " +
+                  self._generate_map_list_string(self.finishes))
         if self.finished is not None:
         if self.finished is not None:
-            print " | Finished:................... " + \
-                self._generate_map_list_string(self.finished)
+            print(" | Finished:................... " +
+                  self._generate_map_list_string(self.finished))
 
 
     def print_temporal_topology_shell_info(self):
     def print_temporal_topology_shell_info(self):
         """Print information about this class in shell style"""
         """Print information about this class in shell style"""
 
 
         if self.next() is not None:
         if self.next() is not None:
-            print "next=" + self.next().get_id()
+            print("next=" + self.next().get_id())
         if self.prev() is not None:
         if self.prev() is not None:
-            print "prev=" + self.prev().get_id()
+            print("prev=" + self.prev().get_id())
         if self.equal is not None:
         if self.equal is not None:
-            print "equal=" + self._generate_map_list_string(self.equal, False)
+            print("equal=" + self._generate_map_list_string(self.equal, False))
         if self.follows is not None:
         if self.follows is not None:
-            print "follows=" + self._generate_map_list_string(self.follows,
-                                                              False)
+            print("follows=" + self._generate_map_list_string(self.follows,
+                                                              False))
         if self.precedes is not None:
         if self.precedes is not None:
-            print "precedes=" + self._generate_map_list_string(
-                self.precedes, False)
+            print("precedes=" + self._generate_map_list_string(
+                  self.precedes, False))
         if self.overlaps is not None:
         if self.overlaps is not None:
-            print "overlaps=" + self._generate_map_list_string(
-                self.overlaps, False)
+            print("overlaps=" + self._generate_map_list_string(
+                  self.overlaps, False))
         if self.overlapped is not None:
         if self.overlapped is not None:
-            print "overlapped=" + \
-                self._generate_map_list_string(self.overlapped, False)
+            print("overlapped=" +
+                  self._generate_map_list_string(self.overlapped, False))
         if self.during is not None:
         if self.during is not None:
-            print "during=" + self._generate_map_list_string(self.during,
-                                                             False)
+            print("during=" + self._generate_map_list_string(self.during,
+                                                             False))
         if self.contains is not None:
         if self.contains is not None:
-            print "contains=" + self._generate_map_list_string(
-                self.contains, False)
+            print("contains=" + self._generate_map_list_string(
+                  self.contains, False))
         if self.starts is not None:
         if self.starts is not None:
-            print "starts=" + \
-                self._generate_map_list_string(self.starts)
+            print("starts=" +
+                  self._generate_map_list_string(self.starts))
         if self.started is not None:
         if self.started is not None:
-            print "started=" + \
-                self._generate_map_list_string(self.started)
+            print("started=" +
+                  self._generate_map_list_string(self.started))
         if self.finishes is not None:
         if self.finishes is not None:
-            print "finishes=" + \
-                self._generate_map_list_string(self.finishes)
+            print("finishes=" +
+                  self._generate_map_list_string(self.finishes))
         if self.finished is not None:
         if self.finished is not None:
-            print "finished=" + \
-                self._generate_map_list_string(self.finished)
+            print("finished=" +
+                  self._generate_map_list_string(self.finished))
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 36 - 36
lib/python/temporal/temporal_vector_algebra.py

@@ -41,10 +41,10 @@ for details.
     LexToken(RPAREN,')',1,16)
     LexToken(RPAREN,')',1,16)
 
 
 """
 """
-
+from __future__ import print_function
 import grass.pygrass.modules as pygrass
 import grass.pygrass.modules as pygrass
-from temporal_operator import *
-from temporal_algebra import *
+from .temporal_operator import *
+from .temporal_algebra import *
 
 
 ##############################################################################
 ##############################################################################
 
 
@@ -129,7 +129,7 @@ class TemporalVectorAlgebraParser(TemporalAlgebraParser):
         while True:
         while True:
             tok = l.lexer.token()
             tok = l.lexer.token()
             if not tok: break
             if not tok: break
-            
+
             if tok.type == "STVDS" or tok.type == "STRDS" or tok.type == "STR3DS":
             if tok.type == "STVDS" or tok.type == "STRDS" or tok.type == "STR3DS":
                 raise SyntaxError("Syntax error near '%s'" %(tok.type))
                 raise SyntaxError("Syntax error near '%s'" %(tok.type))
 
 
@@ -149,12 +149,12 @@ class TemporalVectorAlgebraParser(TemporalAlgebraParser):
     ######################### Temporal functions ##############################
     ######################### Temporal functions ##############################
 
 
     def get_temporal_topo_list(self, maplistA, maplistB = None, topolist = ["EQUAL"],
     def get_temporal_topo_list(self, maplistA, maplistB = None, topolist = ["EQUAL"],
-                               assign_val = False, count_map = False, compare_bool = False,  
-                               compare_cmd = False,  compop = None, aggregate = None,  
+                               assign_val = False, count_map = False, compare_bool = False,
+                               compare_cmd = False,  compop = None, aggregate = None,
                                new = False,  convert = False,  overlay_cmd = False):
                                new = False,  convert = False,  overlay_cmd = False):
         """Build temporal topology for two space time data sets, copy map objects
         """Build temporal topology for two space time data sets, copy map objects
           for given relation into map list.
           for given relation into map list.
-          
+
           :param maplistA: List of maps.
           :param maplistA: List of maps.
           :param maplistB: List of maps.
           :param maplistB: List of maps.
           :param topolist: List of strings of temporal relations.
           :param topolist: List of strings of temporal relations.
@@ -170,11 +170,11 @@ class TemporalVectorAlgebraParser(TemporalAlgebraParser):
           :param compop: Comparison operator, && or ||.
           :param compop: Comparison operator, && or ||.
           :param aggregate: Aggregation operator for relation map list, & or |.
           :param aggregate: Aggregation operator for relation map list, & or |.
           :param new: Boolean if new temporary maps should be created.
           :param new: Boolean if new temporary maps should be created.
-          :param convert: Boolean if conditional values should be converted to 
+          :param convert: Boolean if conditional values should be converted to
                         r.mapcalc command strings.
                         r.mapcalc command strings.
-          :param overlay_cmd: Boolean for aggregate overlay operators implicitly 
+          :param overlay_cmd: Boolean for aggregate overlay operators implicitly
                         in command list values based on related map lists.
                         in command list values based on related map lists.
-                    
+
           :return: List of maps from maplistA that fulfil the topological relationships
           :return: List of maps from maplistA that fulfil the topological relationships
                   to maplistB specified in topolist.
                   to maplistB specified in topolist.
         """
         """
@@ -215,7 +215,7 @@ class TemporalVectorAlgebraParser(TemporalAlgebraParser):
                 self.compare_cmd_value(map_i,  tbrelations, compop, aggregate, topolist, convert)
                 self.compare_cmd_value(map_i,  tbrelations, compop, aggregate, topolist, convert)
             elif overlay_cmd:
             elif overlay_cmd:
                 self.overlay_cmd_value(map_i,  tbrelations, compop, topolist)
                 self.overlay_cmd_value(map_i,  tbrelations, compop, topolist)
-                
+
             for topo in topolist:
             for topo in topolist:
                 if topo.upper() in tbrelations.keys():
                 if topo.upper() in tbrelations.keys():
                     if count_map:
                     if count_map:
@@ -229,21 +229,21 @@ class TemporalVectorAlgebraParser(TemporalAlgebraParser):
                     # Use unique identifier, since map names may be equal
                     # Use unique identifier, since map names may be equal
                     resultdict[map_i.uid] = map_i
                     resultdict[map_i.uid] = map_i
         resultlist = resultdict.values()
         resultlist = resultdict.values()
-        
+
         # Sort list of maps chronological.
         # Sort list of maps chronological.
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
-        
+
         return(resultlist)
         return(resultlist)
 
 
     def overlay_cmd_value(self,  map_i, tbrelations, function, topolist = ["EQUAL"]):
     def overlay_cmd_value(self,  map_i, tbrelations, function, topolist = ["EQUAL"]):
         """ Function to evaluate two map lists by given overlay operator.
         """ Function to evaluate two map lists by given overlay operator.
-        
+
           :param map_i: Map object with temporal extent.
           :param map_i: Map object with temporal extent.
           :param tbrelations: List of temporal relation to map_i.
           :param tbrelations: List of temporal relation to map_i.
           :param topolist: List of strings for given temporal relations.
           :param topolist: List of strings for given temporal relations.
           :param function: Overlay operator, &|+^~.
           :param function: Overlay operator, &|+^~.
-          
-          :return: Map object with command list with  operators that has been 
+
+          :return: Map object with command list with  operators that has been
                         evaluated by implicit aggregration.
                         evaluated by implicit aggregration.
         """
         """
         # Build comandlist list with elements from related maps and given relation operator.
         # Build comandlist list with elements from related maps and given relation operator.
@@ -292,30 +292,30 @@ class TemporalVectorAlgebraParser(TemporalAlgebraParser):
                     mapainput = name
                     mapainput = name
         # Add command list to result map.
         # Add command list to result map.
         map_i.cmd_list = resultlist
         map_i.cmd_list = resultlist
-        
+
         return(resultlist)
         return(resultlist)
 
 
     def set_temporal_extent_list(self, maplist, topolist = ["EQUAL"], temporal = 'l' ):
     def set_temporal_extent_list(self, maplist, topolist = ["EQUAL"], temporal = 'l' ):
-        """ Change temporal extent of map list based on temporal relations to 
+        """ Change temporal extent of map list based on temporal relations to
                 other map list and given temporal operator.
                 other map list and given temporal operator.
 
 
-            :param maplist: List of map objects for which relations has been build 
+            :param maplist: List of map objects for which relations has been build
                                         correctely.
                                         correctely.
             :param topolist: List of strings of temporal relations.
             :param topolist: List of strings of temporal relations.
             :param temporal: The temporal operator specifying the temporal
             :param temporal: The temporal operator specifying the temporal
-                                            extent operation (intersection, union, disjoint 
+                                            extent operation (intersection, union, disjoint
                                             union, right reference, left reference).
                                             union, right reference, left reference).
 
 
             :return: Map list with specified temporal extent.
             :return: Map list with specified temporal extent.
         """
         """
         resultdict = {}
         resultdict = {}
-        
+
         for map_i in maplist:
         for map_i in maplist:
             # Loop over temporal related maps and create overlay modules.
             # Loop over temporal related maps and create overlay modules.
             tbrelations = map_i.get_temporal_relations()
             tbrelations = map_i.get_temporal_relations()
             # Generate an intermediate map for the result map list.
             # Generate an intermediate map for the result map list.
-            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', 
-                                                                        copy = True,  rename = False,  
+            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
+                                                                        copy = True,  rename = False,
                                                                         remove = True)
                                                                         remove = True)
             # Combine temporal and spatial extents of intermediate map with related maps.
             # Combine temporal and spatial extents of intermediate map with related maps.
             for topo in topolist:
             for topo in topolist:
@@ -323,8 +323,8 @@ class TemporalVectorAlgebraParser(TemporalAlgebraParser):
                     for map_j in (tbrelations[topo]):
                     for map_j in (tbrelations[topo]):
                         if temporal == 'r':
                         if temporal == 'r':
                             # Generate an intermediate map for the result map list.
                             # Generate an intermediate map for the result map list.
-                            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', 
-                                                                                        copy = True,  rename = False,  
+                            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
+                                                                                        copy = True,  rename = False,
                                                                                         remove = True)
                                                                                         remove = True)
                         # Create overlayed map extent.
                         # Create overlayed map extent.
                         returncode = self.overlay_map_extent(map_new, map_j, 'and', \
                         returncode = self.overlay_map_extent(map_new, map_j, 'and', \
@@ -344,9 +344,9 @@ class TemporalVectorAlgebraParser(TemporalAlgebraParser):
         # Get sorted map objects as values from result dictionoary.
         # Get sorted map objects as values from result dictionoary.
         resultlist = resultdict.values()
         resultlist = resultdict.values()
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
-        
+
         return(resultlist)
         return(resultlist)
-    
+
     ###########################################################################
     ###########################################################################
 
 
     def p_statement_assign(self, t):
     def p_statement_assign(self, t):
@@ -427,7 +427,7 @@ class TemporalVectorAlgebraParser(TemporalAlgebraParser):
                             count += 1
                             count += 1
                             register_list.append(map_i)
                             register_list.append(map_i)
                     else:
                     else:
-                        # Test if temporal extents have been changed by temporal 
+                        # Test if temporal extents have been changed by temporal
                         # relation operators (i|r). This is a code copy from temporal_algebra.py
                         # relation operators (i|r). This is a code copy from temporal_algebra.py
                         map_i_extent = map_i.get_temporal_extent_as_tuple()
                         map_i_extent = map_i.get_temporal_extent_as_tuple()
                         map_test = map_i.get_new_instance(map_i.get_id())
                         map_test = map_i.get_new_instance(map_i.get_id())
@@ -483,11 +483,11 @@ class TemporalVectorAlgebraParser(TemporalAlgebraParser):
                             # Map is original from an input STVDS
                             # Map is original from an input STVDS
                             map_i.load()
                             map_i.load()
                         # Register map in result space time dataset.
                         # Register map in result space time dataset.
-                        print map_i.get_temporal_extent_as_tuple()
+                        print(map_i.get_temporal_extent_as_tuple())
                         success = resultstds.register_map(map_i, dbif=dbif)
                         success = resultstds.register_map(map_i, dbif=dbif)
                     resultstds.update_from_registered_maps(dbif)
                     resultstds.update_from_registered_maps(dbif)
-                
-            # Remove intermediate maps    
+
+            # Remove intermediate maps
             self.remove_maps()
             self.remove_maps()
             if connected:
             if connected:
                 dbif.close()
                 dbif.close()
@@ -521,13 +521,13 @@ class TemporalVectorAlgebraParser(TemporalAlgebraParser):
             maplistA = self.check_stds(t[1])
             maplistA = self.check_stds(t[1])
             maplistB = self.check_stds(t[3])
             maplistB = self.check_stds(t[3])
             relations = ["EQUAL"]
             relations = ["EQUAL"]
-            temporal = 'l' 
-            function = t[2] 
+            temporal = 'l'
+            function = t[2]
             # Build commmand list for related maps.
             # Build commmand list for related maps.
             complist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations,
             complist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations,
                                                                     compop = function, overlay_cmd = True)
                                                                     compop = function, overlay_cmd = True)
             # Set temporal extent based on topological relationships.
             # Set temporal extent based on topological relationships.
-            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations,
                                 temporal = temporal)
                                 temporal = temporal)
 
 
             t[0] = resultlist
             t[0] = resultlist
@@ -550,9 +550,9 @@ class TemporalVectorAlgebraParser(TemporalAlgebraParser):
             complist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations,
             complist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations,
                                                                     compop = function, overlay_cmd = True)
                                                                     compop = function, overlay_cmd = True)
             # Set temporal extent based on topological relationships.
             # Set temporal extent based on topological relationships.
-            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations,
                                 temporal = temporal)
                                 temporal = temporal)
-          
+
             t[0] = resultlist
             t[0] = resultlist
         if self.debug:
         if self.debug:
             str(t[1]) + t[2] + str(t[3])
             str(t[1]) + t[2] + str(t[3])

+ 6 - 5
lib/python/temporal/univar_statistics.py

@@ -18,8 +18,9 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
+from __future__ import print_function
 
 
-from open_stds import *
+from .open_stds import *
 import grass.script as gscript
 import grass.script as gscript
 
 
 ###############################################################################
 ###############################################################################
@@ -71,7 +72,7 @@ def print_gridded_dataset_univar_statistics(type, input, output, where, extended
             string += "third_quartile" + fs + "percentile_90"
             string += "third_quartile" + fs + "percentile_90"
 
 
         if output is None:
         if output is None:
-            print string
+            print(string)
         else:
         else:
             out_file.write(string + "\n")
             out_file.write(string + "\n")
 
 
@@ -113,7 +114,7 @@ def print_gridded_dataset_univar_statistics(type, input, output, where, extended
             string += fs + str(stats["third_quartile"]) + fs + str(stats["percentile_90"])
             string += fs + str(stats["third_quartile"]) + fs + str(stats["percentile_90"])
 
 
         if output is None:
         if output is None:
-            print string
+            print(string)
         else:
         else:
             out_file.write(string + "\n")
             out_file.write(string + "\n")
 
 
@@ -191,7 +192,7 @@ def print_vector_dataset_univar_statistics(input, output, twhere, layer, type, c
                     "third_quartile" + fs + "percentile_90"
                     "third_quartile" + fs + "percentile_90"
 
 
         if output is None:
         if output is None:
-            print string
+            print(string)
         else:
         else:
             out_file.write(string + "\n")
             out_file.write(string + "\n")
 
 
@@ -254,7 +255,7 @@ def print_vector_dataset_univar_statistics(input, output, twhere, layer, type, c
                     string += fs + fs + fs + fs
                     string += fs + fs + fs + fs
 
 
         if output is None:
         if output is None:
-            print string
+            print(string)
         else:
         else:
             out_file.write(string + "\n")
             out_file.write(string + "\n")