[GRASS-SVN] r54915 - grass/trunk/lib/python/pygrass/raster

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 5 00:19:55 PST 2013


Author: zarch
Date: 2013-02-05 00:19:54 -0800 (Tue, 05 Feb 2013)
New Revision: 54915

Modified:
   grass/trunk/lib/python/pygrass/raster/__init__.py
   grass/trunk/lib/python/pygrass/raster/abstract.py
Log:
Read the cats and the history when opening an existing maps

Modified: grass/trunk/lib/python/pygrass/raster/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/__init__.py	2013-02-05 08:19:46 UTC (rev 54914)
+++ grass/trunk/lib/python/pygrass/raster/__init__.py	2013-02-05 08:19:54 UTC (rev 54915)
@@ -167,6 +167,8 @@
                 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 @@
                 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)))

Modified: grass/trunk/lib/python/pygrass/raster/abstract.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/abstract.py	2013-02-05 08:19:46 UTC (rev 54914)
+++ grass/trunk/lib/python/pygrass/raster/abstract.py	2013-02-05 08:19:54 UTC (rev 54915)
@@ -32,6 +32,7 @@
 #
 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 @@
         ..
         """
         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,7 +79,11 @@
         # 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
 



More information about the grass-commit mailing list