瀏覽代碼

temporal framework: Better Python module import handling

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@69673 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 8 年之前
父節點
當前提交
898c8f1f00
共有 31 個文件被更改,包括 240 次插入84 次删除
  1. 3 5
      lib/python/temporal/abstract_dataset.py
  2. 21 4
      lib/python/temporal/abstract_map_dataset.py
  3. 14 4
      lib/python/temporal/abstract_space_time_dataset.py
  4. 7 4
      lib/python/temporal/aggregation.py
  5. 4 3
      lib/python/temporal/base.py
  6. 2 3
      lib/python/temporal/c_libraries_interface.py
  7. 1 2
      lib/python/temporal/core.py
  8. 1 1
      lib/python/temporal/datetime_math.py
  9. 5 4
      lib/python/temporal/extract.py
  10. 5 1
      lib/python/temporal/factory.py
  11. 5 3
      lib/python/temporal/gui_support.py
  12. 13 8
      lib/python/temporal/list_stds.py
  13. 7 3
      lib/python/temporal/mapcalc.py
  14. 4 1
      lib/python/temporal/metadata.py
  15. 5 2
      lib/python/temporal/open_stds.py
  16. 8 2
      lib/python/temporal/register.py
  17. 5 1
      lib/python/temporal/sampling.py
  18. 18 3
      lib/python/temporal/space_time_datasets.py
  19. 5 1
      lib/python/temporal/spatial_extent.py
  20. 6 4
      lib/python/temporal/spatio_temporal_relationships.py
  21. 3 3
      lib/python/temporal/stds_export.py
  22. 8 7
      lib/python/temporal/stds_import.py
  23. 16 4
      lib/python/temporal/temporal_algebra.py
  24. 5 1
      lib/python/temporal/temporal_extent.py
  25. 3 1
      lib/python/temporal/temporal_granularity.py
  26. 15 1
      lib/python/temporal/temporal_raster3d_algebra.py
  27. 14 2
      lib/python/temporal/temporal_raster_algebra.py
  28. 17 2
      lib/python/temporal/temporal_raster_base_algebra.py
  29. 16 2
      lib/python/temporal/temporal_vector_algebra.py
  30. 1 1
      lib/python/temporal/testsuite/test_doctests.py
  31. 3 1
      lib/python/temporal/univar_statistics.py

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

@@ -11,11 +11,9 @@ 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 .core import get_tgis_message_interface, init_dbif, get_enable_mapset_check, get_current_mapset
+from .temporal_topology_dataset_connector import TemporalTopologyDatasetConnector
+from .spatial_topology_dataset_connector import SpatialTopologyDatasetConnector
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 21 - 4
lib/python/temporal/abstract_map_dataset.py

@@ -11,8 +11,16 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 from __future__ import print_function
 from __future__ import print_function
-from .abstract_dataset import *
-from .datetime_math import *
+import gettext
+from grass.exceptions import ImplementationError
+from datetime import datetime
+from abc import ABCMeta, abstractmethod
+from .core import get_tgis_c_library_interface, get_enable_timestamp_write, \
+    get_enable_mapset_check, get_current_mapset, init_dbif
+from .abstract_dataset import AbstractDataset
+from .temporal_extent import RelativeTemporalExtent, AbsoluteTemporalExtent
+from .datetime_math import datetime_to_grass_datetime_string, \
+    increment_datetime_by_string, decrement_datetime_by_string
 
 
 
 
 class AbstractMapDataset(AbstractDataset):
 class AbstractMapDataset(AbstractDataset):
@@ -530,7 +538,7 @@ class AbstractMapDataset(AbstractDataset):
         """Convenient method to set the temporal extent from a temporal extent
         """Convenient method to set the temporal extent from a temporal extent
            object
            object
 
 
-           :param temporal_extent: The temporal extent that should be set for
+           :param extent: The temporal extent that should be set for
                                    this object
                                    this object
 
 
            .. code-block: : python
            .. code-block: : python
@@ -722,6 +730,9 @@ class AbstractMapDataset(AbstractDataset):
            spatial directions.
            spatial directions.
 
 
            :param size: The buffer size, using the unit of the grass region
            :param size: The buffer size, using the unit of the grass region
+           :param update: If True perform an immediate database update, otherwise only the
+                          internal variables are set
+           :param dbif: The database interface to be used
 
 
            .. code-block: : python
            .. code-block: : python
 
 
@@ -749,6 +760,9 @@ class AbstractMapDataset(AbstractDataset):
            spatial directions.
            spatial directions.
 
 
            :param size: The buffer size, using the unit of the grass region
            :param size: The buffer size, using the unit of the grass region
+           :param update: If True perform an immediate database update, otherwise only the
+                          internal variables are set
+           :param dbif: The database interface to be used
 
 
            .. code-block: : python
            .. code-block: : python
 
 
@@ -770,7 +784,10 @@ class AbstractMapDataset(AbstractDataset):
             self.spatial_extent.update(dbif)
             self.spatial_extent.update(dbif)
 
 
     def check_for_correct_time(self):
     def check_for_correct_time(self):
-        """Check for correct time"""
+        """Check for correct time
+
+           :return: True in case of success, False otherwise
+        """
         if self.is_time_absolute():
         if self.is_time_absolute():
             start, end = self.get_absolute_time()
             start, end = self.get_absolute_time()
         else:
         else:

+ 14 - 4
lib/python/temporal/abstract_space_time_dataset.py

@@ -13,9 +13,20 @@ for details.
 from __future__ import print_function
 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 *
+import os
+import copy
+from datetime import datetime
+import gettext
+from abc import ABCMeta, abstractmethod
+from .core import init_dbif, get_sql_template_path, get_tgis_metadata, get_current_mapset, \
+    get_enable_mapset_check
+from .abstract_dataset import AbstractDataset, AbstractDatasetComparisonKeyStartTime
+from .temporal_granularity import check_granularity_string, compute_absolute_time_granularity,\
+    compute_relative_time_granularity
+from .spatio_temporal_relationships import count_temporal_topology_relationships, \
+    print_spatio_temporal_topology_relationships, SpatioTemporalTopologyBuilder, \
+    create_temporal_relation_sql_where_statement
+from .datetime_math import increment_datetime_by_string
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -1567,7 +1578,6 @@ class AbstractSpaceTimeDataset(AbstractDataset):
             return None
             return None
 
 
         if not check_granularity_string(gran, maps[-1].get_temporal_type()):
         if not check_granularity_string(gran, maps[-1].get_temporal_type()):
-            self.msgr.error(_("Wrong granularity format: %s" % (gran)))
             return None
             return None
 
 
         for map in maps:
         for map in maps:

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

@@ -17,13 +17,16 @@ for details.
 :author: Soeren Gebbert
 :author: Soeren Gebbert
 """
 """
 
 
-from .space_time_datasets import *
+import gettext
+import grass.script as gscript
+from grass.exceptions import CalledModuleError
+from .space_time_datasets import RasterDataset
 from .datetime_math import create_suffix_from_datetime
 from .datetime_math import create_suffix_from_datetime
 from .datetime_math import create_time_suffix
 from .datetime_math import create_time_suffix
 from .datetime_math import create_numeric_suffic
 from .datetime_math import create_numeric_suffic
-import grass.script as gscript
-from grass.exceptions import CalledModuleError
-
+from .core import get_current_mapset, get_tgis_message_interface, init_dbif
+from .spatio_temporal_relationships import SpatioTemporalTopologyBuilder, \
+    create_temporal_relation_sql_where_statement
 ###############################################################################
 ###############################################################################
 
 
 
 

+ 4 - 3
lib/python/temporal/base.py

@@ -26,7 +26,8 @@ for details.
 """
 """
 from __future__ import print_function
 from __future__ import print_function
 from datetime import datetime
 from datetime import datetime
-from .core import *
+from .core import get_tgis_message_interface, get_tgis_dbmi_paramstyle, \
+    SQLDatabaseInterfaceConnection, init, get_current_mapset
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -376,8 +377,7 @@ class SQLDatabaseInterface(DictSQLSerializer):
         if len(row) > 0:
         if len(row) > 0:
             self.deserialize(row)
             self.deserialize(row)
         else:
         else:
-            self.msgr.fatal(_("Object <%s> not found in the temporal database")
-                            % self.get_id())
+            self.msgr.fatal(_("Object not found in the temporal database"))
 
 
         return True
         return True
 
 
@@ -610,6 +610,7 @@ class DatasetBase(SQLDatabaseInterface):
         """
         """
         self.ident = ident
         self.ident = ident
         self.D["id"] = ident
         self.D["id"] = ident
+        name = ""
 
 
         if ident is not None:
         if ident is not None:
             if ident.find("@") >= 0:
             if ident.find("@") >= 0:

+ 2 - 3
lib/python/temporal/c_libraries_interface.py

@@ -12,13 +12,12 @@ for details.
 """
 """
 
 
 from grass.exceptions import FatalError
 from grass.exceptions import FatalError
-import time
-import threading
+import gettext
 import sys
 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 datetime import datetime
 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

+ 1 - 2
lib/python/temporal/core.py

@@ -30,6 +30,7 @@ for details.
 """
 """
 #import traceback
 #import traceback
 import os
 import os
+import grass.script as gscript
 # i18N
 # i18N
 import gettext
 import gettext
 gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'))
 gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'))
@@ -40,8 +41,6 @@ except ImportError:
     # python3
     # python3
     long = int
     long = int
 
 
-import grass.script as gscript
-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

+ 1 - 1
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 get_tgis_message_interface
 import copy
 import copy
 
 
 try:
 try:

+ 5 - 4
lib/python/temporal/extract.py

@@ -8,10 +8,11 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-
-from grass.script.utils import get_num_suffix
-from .space_time_datasets import *
-from .open_stds import *
+# i18N
+import gettext
+from .core import get_tgis_message_interface, get_current_mapset, SQLDatabaseInterfaceConnection
+from .abstract_map_dataset import AbstractMapDataset
+from .open_stds import open_old_stds, check_new_stds, open_new_stds
 from .datetime_math import create_suffix_from_datetime
 from .datetime_math import create_suffix_from_datetime
 from .datetime_math import create_time_suffix
 from .datetime_math import create_time_suffix
 from .datetime_math import create_numeric_suffic
 from .datetime_math import create_numeric_suffic

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

@@ -17,8 +17,12 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
+# i18N
+import gettext
+from .core import get_tgis_message_interface
+from .space_time_datasets import SpaceTimeRaster3DDataset, SpaceTimeRasterDataset, \
+    SpaceTimeVectorDataset, Raster3DDataset, RasterDataset, VectorDataset
 
 
-from .space_time_datasets import *
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 5 - 3
lib/python/temporal/gui_support.py

@@ -9,9 +9,10 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-
-from .space_time_datasets import *
-from .factory import *
+# i18N
+import gettext
+from .core import get_available_temporal_mapsets, init_dbif
+from .factory import dataset_factory
 import grass.script as gscript
 import grass.script as gscript
 
 
 ###############################################################################
 ###############################################################################
@@ -26,6 +27,7 @@ def tlist_grouped(type, group_type=False, dbif=None):
 
 
     .. code-block:: python
     .. code-block:: python
 
 
+        >>> import grass.temporalas tgis
         >>> tgis.tlist_grouped('strds')['PERMANENT']
         >>> tgis.tlist_grouped('strds')['PERMANENT']
         ['precipitation', 'temperature']
         ['precipitation', 'temperature']
 
 

+ 13 - 8
lib/python/temporal/list_stds.py

@@ -18,9 +18,13 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 from __future__ import print_function
 from __future__ import print_function
-from .space_time_datasets import *
-from .factory import *
-from .open_stds import *
+# i18N
+import gettext
+from .core import get_tgis_message_interface, get_available_temporal_mapsets, init_dbif
+from .datetime_math import time_delta_to_relative_time
+from .space_time_datasets import RasterDataset
+from .factory import dataset_factory
+from .open_stds import open_old_stds
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -49,18 +53,19 @@ def get_dataset_list(type, temporal_type, columns=None, where=None,
         .. code-block:: python
         .. code-block:: python
 
 
             >>> import grass.temporal as tgis
             >>> import grass.temporal as tgis
-            >>> tgis.init()
+            >>> tgis.core.init()
             >>> name = "list_stds_test"
             >>> name = "list_stds_test"
-            >>> sp = tgis.open_new_stds(name=name, type="strds",
-            ... temporaltype="absolute", title="title", descr="descr", semantic="mean", dbif=None, overwrite=True)
+            >>> sp = tgis.open_stds.open_new_stds(name=name, type="strds",
+            ... temporaltype="absolute", title="title", descr="descr",
+            ... semantic="mean", dbif=None, overwrite=True)
             >>> mapset = tgis.get_current_mapset()
             >>> mapset = tgis.get_current_mapset()
-            >>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name")
+            >>> stds_list = tgis.list_stds.get_dataset_list("strds", "absolute", columns="name")
             >>> 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.list_stds.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:

+ 7 - 3
lib/python/temporal/mapcalc.py

@@ -8,12 +8,16 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-
-from .space_time_datasets import *
-from .open_stds import *
+# i18N
+import gettext
+import copy
+from datetime import datetime
 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
+from .core import SQLDatabaseInterfaceConnection, get_current_mapset, get_tgis_message_interface
+from .open_stds import open_new_stds, open_old_stds, check_new_stds
+from .datetime_math import time_delta_to_relative_time
 
 
 ############################################################################
 ############################################################################
 
 

+ 4 - 1
lib/python/temporal/metadata.py

@@ -22,7 +22,10 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 from __future__ import print_function
 from __future__ import print_function
-from .base import *
+# i18N
+import gettext
+from .base import SQLDatabaseInterface
+from .core import init
 
 
 ###############################################################################
 ###############################################################################
 
 

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

@@ -17,8 +17,11 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-
-from .factory import *
+# i18N
+import gettext
+from .core import init_dbif, get_current_mapset, get_tgis_message_interface
+from .factory import dataset_factory
+from .abstract_map_dataset import AbstractMapDataset
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 8 - 2
lib/python/temporal/register.py

@@ -16,9 +16,15 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-
-from .open_stds import *
+# i18N
+import gettext
+from datetime import datetime
 import grass.script as gscript
 import grass.script as gscript
+from .core import get_tgis_message_interface, init_dbif, get_current_mapset
+from .open_stds import open_old_stds
+from .abstract_map_dataset import AbstractMapDataset
+from .factory import dataset_factory
+from .datetime_math import check_datetime_string, increment_datetime_by_string, string_to_datetime
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 5 - 1
lib/python/temporal/sampling.py

@@ -17,7 +17,11 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 from __future__ import print_function
 from __future__ import print_function
-from .factory import *
+# i18N
+import gettext
+from .core import get_current_mapset, get_tgis_message_interface, SQLDatabaseInterfaceConnection
+from .datetime_math import time_delta_to_relative_time
+from .factory import dataset_factory
 
 
 
 
 def sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header,
 def sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header,

+ 18 - 3
lib/python/temporal/space_time_datasets.py

@@ -8,10 +8,25 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
+# i18N
+import gettext
 import getpass
 import getpass
-from .abstract_map_dataset import *
-from .abstract_space_time_dataset import *
+from datetime import datetime
+from .core import get_current_mapset
+from .abstract_map_dataset import AbstractMapDataset
+from .abstract_space_time_dataset import AbstractSpaceTimeDataset
+from .base import Raster3DBase, RasterBase, VectorBase, STR3DSBase, STVDSBase, STRDSBase,\
+    VectorSTDSRegister, Raster3DSTDSRegister, RasterSTDSRegister
+from .metadata import Raster3DMetadata, RasterMetadata, VectorMetadata, STRDSMetadata,\
+    STR3DSMetadata, STVDSMetadata
+from .spatial_extent import RasterSpatialExtent, Raster3DSpatialExtent, VectorSpatialExtent,\
+    STRDSSpatialExtent, STR3DSSpatialExtent, STVDSSpatialExtent
+from .temporal_extent import RasterAbsoluteTime, RasterRelativeTime, Raster3DAbsoluteTime, \
+    Raster3DRelativeTime, VectorAbsoluteTime, VectorRelativeTime, STRDSAbsoluteTime,\
+    STRDSRelativeTime, STR3DSAbsoluteTime, STR3DSRelativeTime, STVDSAbsoluteTime, STVDSRelativeTime
 import grass.script.array as garray
 import grass.script.array as garray
+from .core import init
+from datetime import datetime
 
 
 ###############################################################################
 ###############################################################################
 
 
@@ -205,7 +220,7 @@ class RasterDataset(AbstractMapDataset):
         self.stds_register = RasterSTDSRegister(ident=ident)
         self.stds_register = RasterSTDSRegister(ident=ident)
 
 
     def has_grass_timestamp(self):
     def has_grass_timestamp(self):
-        """Check if a grass file bsased time stamp exists for this map.
+        """Check if a grass file based time stamp exists for this map.
 
 
            :return: True if success, False on error
            :return: True if success, False on error
         """
         """

+ 5 - 1
lib/python/temporal/spatial_extent.py

@@ -34,7 +34,11 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 from __future__ import print_function
 from __future__ import print_function
-from .base import *
+# i18N
+import gettext
+from .base import SQLDatabaseInterface
+from .core import init
+from datetime import datetime
 
 
 
 
 class SpatialExtent(SQLDatabaseInterface):
 class SpatialExtent(SQLDatabaseInterface):

+ 6 - 4
lib/python/temporal/spatio_temporal_relationships.py

@@ -18,13 +18,15 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 from __future__ import print_function
 from __future__ import print_function
-
-from .abstract_dataset import *
-from .datetime_math import *
+# i18N
+import gettext
+from datetime import datetime
+from .core import init_dbif
+from .abstract_dataset import AbstractDatasetComparisonKeyStartTime
+from .datetime_math import time_delta_to_relative_time_seconds
 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
-from ctypes import *
 
 
 ###############################################################################
 ###############################################################################
 
 

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

@@ -25,16 +25,16 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 
 
+# i18N
+import gettext
 import shutil
 import shutil
 import os
 import os
 import tarfile
 import tarfile
 import tempfile
 import tempfile
 
 
-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
+from .open_stds import open_old_stds
 
 
 
 
 proj_file_name = "proj.txt"
 proj_file_name = "proj.txt"

+ 8 - 7
lib/python/temporal/stds_import.py

@@ -29,14 +29,15 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 
 
+# i18N
+import gettext
 import os
 import os
 import os.path
 import os.path
 import tarfile
 import tarfile
 
 
-from .space_time_datasets import *
-from .register import *
-from . import factory
-from .factory import *
+from .core import get_current_mapset, get_tgis_message_interface
+from .register import register_maps_in_space_time_dataset
+from .factory import dataset_factory
 import grass.script as gscript
 import grass.script as gscript
 from grass.exceptions import CalledModuleError
 from grass.exceptions import CalledModuleError
 
 
@@ -198,7 +199,6 @@ def import_stds(input, output, directory, title=None, descr=None, location=None,
         :param memory: Cache size for raster rows, used in r.in.gdal
         :param memory: Cache size for raster rows, used in r.in.gdal
     """
     """
 
 
-    global raise_on_error
     old_state = gscript.raise_on_error
     old_state = gscript.raise_on_error
     gscript.set_raise_on_error(True)
     gscript.set_raise_on_error(True)
 
 
@@ -308,7 +308,8 @@ def import_stds(input, output, directory, title=None, descr=None, location=None,
 
 
     try:
     try:
         # Make sure the temporal database exists
         # Make sure the temporal database exists
-        factory.init()
+        from .core import init
+        init()
 
 
         fs = "|"
         fs = "|"
         maplist = []
         maplist = []
@@ -498,6 +499,6 @@ def import_stds(input, output, directory, title=None, descr=None, location=None,
                                     location=old_env["LOCATION_NAME"],
                                     location=old_env["LOCATION_NAME"],
                                     gisdbase=old_env["GISDBASE"])
                                     gisdbase=old_env["GISDBASE"])
             except CalledModuleError:
             except CalledModuleError:
-                grass.warning(_("Switching to original location failed"))
+                gscript.warning(_("Switching to original location failed"))
 
 
         gscript.set_raise_on_error(old_state)
         gscript.set_raise_on_error(old_state)

+ 16 - 4
lib/python/temporal/temporal_algebra.py

@@ -446,13 +446,25 @@ try:
 except:
 except:
     pass
     pass
 
 
+# i18N
+import gettext
 import os
 import os
 import copy
 import copy
+from datetime import datetime
 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 .core import init_dbif, get_tgis_message_interface, get_current_mapset,\
+    SQLDatabaseInterfaceConnection
+from .temporal_granularity import compute_common_absolute_time_granularity, \
+    compute_common_relative_time_granularity
+from .abstract_dataset import AbstractDatasetComparisonKeyStartTime
+from .abstract_map_dataset import AbstractMapDataset
+from .space_time_datasets import RasterDataset
+from .factory import dataset_factory
+from .open_stds import open_new_stds, open_old_stds
+from .temporal_operator import TemporalOperatorParser
+from spatio_temporal_relationships import SpatioTemporalTopologyBuilder
+from .datetime_math import time_delta_to_relative_time
+from abstract_space_time_dataset import AbstractSpaceTimeDataset
 
 
 ##############################################################################
 ##############################################################################
 
 

+ 5 - 1
lib/python/temporal/temporal_extent.py

@@ -20,7 +20,11 @@ for details.
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
 from __future__ import print_function
 from __future__ import print_function
-from .base import *
+# i18N
+import gettext
+from .base import SQLDatabaseInterface
+from .core import init
+from datetime import datetime
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 3 - 1
lib/python/temporal/temporal_granularity.py

@@ -17,7 +17,9 @@ for details.
 
 
 :authors: Soeren Gebbert
 :authors: Soeren Gebbert
 """
 """
-from .abstract_dataset import *
+from __future__ import print_function
+# i18N
+import gettext
 from .datetime_math import *
 from .datetime_math import *
 from functools import reduce
 from functools import reduce
 
 

+ 15 - 1
lib/python/temporal/temporal_raster3d_algebra.py

@@ -10,7 +10,21 @@ for details.
 :authors: Thomas Leppelt and Soeren Gebbert
 :authors: Thomas Leppelt and Soeren Gebbert
 
 
 """
 """
-from .temporal_raster_base_algebra import *
+from __future__ import print_function
+
+try:
+    import ply.lex as lex
+    import ply.yacc as yacc
+except:
+    pass
+
+# i18N
+import gettext
+from .temporal_raster_base_algebra import TemporalRasterBaseAlgebraParser,\
+    TemporalRasterAlgebraLexer
+import grass.pygrass.modules as pymod
+from .space_time_datasets import Raster3DDataset
+
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 14 - 2
lib/python/temporal/temporal_raster_algebra.py

@@ -51,8 +51,20 @@ for details.
     LexToken(FLOAT,2.45,1,42)
     LexToken(FLOAT,2.45,1,42)
 
 
 """
 """
-
-from .temporal_raster_base_algebra import *
+from __future__ import print_function
+
+try:
+    import ply.lex as lex
+    import ply.yacc as yacc
+except:
+    pass
+
+# i18N
+import gettext
+from .temporal_raster_base_algebra import TemporalRasterBaseAlgebraParser,\
+    TemporalRasterAlgebraLexer
+import grass.pygrass.modules as pymod
+from .space_time_datasets import RasterDataset
 
 
 ###############################################################################
 ###############################################################################
 
 

+ 17 - 2
lib/python/temporal/temporal_raster_base_algebra.py

@@ -41,9 +41,24 @@ for details.
 
 
 """
 """
 from __future__ import print_function
 from __future__ import print_function
+
+try:
+    import ply.lex as lex
+    import ply.yacc as yacc
+except:
+    pass
+
+import copy
 import grass.pygrass.modules as pymod
 import grass.pygrass.modules as pymod
-from .temporal_operator import *
-from .temporal_algebra import *
+from grass.exceptions import FatalError
+from .temporal_algebra import TemporalAlgebraLexer, TemporalAlgebraParser, GlobalTemporalVar
+from .core import init_dbif
+from .abstract_dataset import AbstractDatasetComparisonKeyStartTime
+from .factory import dataset_factory
+from .open_stds import open_new_stds
+from spatio_temporal_relationships import SpatioTemporalTopologyBuilder
+from .space_time_datasets import Raster3DDataset, RasterDataset
+
 
 
 ##############################################################################
 ##############################################################################
 
 

+ 16 - 2
lib/python/temporal/temporal_vector_algebra.py

@@ -42,9 +42,23 @@ for details.
 
 
 """
 """
 from __future__ import print_function
 from __future__ import print_function
+
+try:
+    import ply.lex as lex
+    import ply.yacc as yacc
+except:
+    pass
+
 import grass.pygrass.modules as pygrass
 import grass.pygrass.modules as pygrass
-from .temporal_operator import *
-from .temporal_algebra import *
+
+import copy
+from .temporal_algebra import TemporalAlgebraLexer, TemporalAlgebraParser, GlobalTemporalVar
+from .core import init_dbif, get_current_mapset
+from .abstract_dataset import AbstractDatasetComparisonKeyStartTime
+from .open_stds import open_new_stds
+from spatio_temporal_relationships import SpatioTemporalTopologyBuilder
+from .space_time_datasets import VectorDataset
+
 
 
 ##############################################################################
 ##############################################################################
 
 

+ 1 - 1
lib/python/temporal/testsuite/test_doctests.py

@@ -25,7 +25,7 @@ def load_tests(loader, tests, ignore):
     tests.addTests(doctest.DocTestSuite(grass.temporal.abstract_space_time_dataset))
     tests.addTests(doctest.DocTestSuite(grass.temporal.abstract_space_time_dataset))
     tests.addTests(doctest.DocTestSuite(grass.temporal.base))
     tests.addTests(doctest.DocTestSuite(grass.temporal.base))
     # Unexpected error here
     # Unexpected error here
-    ##tests.addTests(doctest.DocTestSuite(grass.temporal.core))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.core))
     tests.addTests(doctest.DocTestSuite(grass.temporal.datetime_math))
     tests.addTests(doctest.DocTestSuite(grass.temporal.datetime_math))
     # Unexpected error here
     # Unexpected error here
     ##tests.addTests(doctest.DocTestSuite(grass.temporal.list_stds))
     ##tests.addTests(doctest.DocTestSuite(grass.temporal.list_stds))

+ 3 - 1
lib/python/temporal/univar_statistics.py

@@ -20,7 +20,9 @@ for details.
 """
 """
 from __future__ import print_function
 from __future__ import print_function
 
 
-from .open_stds import *
+from .core import SQLDatabaseInterfaceConnection, get_current_mapset
+from .factory import dataset_factory
+from .open_stds import open_old_stds
 import grass.script as gscript
 import grass.script as gscript
 
 
 ###############################################################################
 ###############################################################################