Pārlūkot izejas kodu

Read the cats and the history when opening an existing maps

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54915 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 12 gadi atpakaļ
vecāks
revīzija
ed706cbae3

+ 4 - 0
lib/python/pygrass/raster/__init__.py

@@ -167,6 +167,8 @@ class RasterRow(RasterAbstractBase):
                 self._fd = libraster.Rast_open_old(self.name, self.mapset)
                 self._gtype = libraster.Rast_get_map_type(self._fd)
                 self.mtype = RTYPE_STR[self._gtype]
+                self.cats.read(self)
+                self.hist.read(self.name)
             elif self.overwrite:
                 if self._gtype is None:
                     raise OpenError(_("Raster type not defined"))
@@ -401,6 +403,8 @@ class RasterSegment(RasterAbstractBase):
                 self.segment.open(self)
                 self.map2segment()
                 self.segment.flush()
+                self.cats.read(self)
+                self.hist.read(self.name)
 
                 if self.mode == "rw":
                     warning(_(WARN_OVERWRITE.format(self)))

+ 5 - 3
lib/python/pygrass/raster/abstract.py

@@ -32,6 +32,7 @@ from grass.pygrass.gis import Mapset
 #
 from raster_type import TYPE as RTYPE
 from category import Category
+from history import History
 
 
 ## Define global variables to not exceed the 80 columns
@@ -67,9 +68,6 @@ class RasterAbstractBase(object):
         ..
         """
         self.mapset = mapset
-        #self.region = Region()
-        self.cats = Category()
-
         self._name = name
         ## Private attribute `_fd` that return the file descriptor of the map
         self._fd = None
@@ -81,6 +79,10 @@ class RasterAbstractBase(object):
         # in active window, When the class is instanced is empty and it is set
         # when you open the file, using Rast_window_cols()
         self._cols = None
+        #self.region = Region()
+        self.cats = Category()
+        self.hist = History()
+
 
     def _get_mtype(self):
         return self._mtype