Переглянути джерело

Before closing the RasterNumpy class check if is open or not and add an additional parameter to set the name of the raster map.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@59192 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 11 роки тому
батько
коміт
d0bd04a250
1 змінених файлів з 9 додано та 4 видалено
  1. 9 4
      lib/python/pygrass/raster/__init__.py

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

@@ -640,10 +640,15 @@ class RasterNumpy(np.memmap, RasterAbstractBase):
         # if the map is open or not
         self._fd = 1
 
-    def close(self):
-        self._write()
-        os.remove(self.filename)
-        self._fd = None
+    def close(self, name=''):
+        if self.is_open():
+            name = name if name else self.name
+            if not name:
+                raise RuntimeError('Raster name not set neither '
+                                   'given as parameter.')
+            self._write()
+            os.remove(self.filename)
+            self._fd = None
 
     def get_value(self, point, region=None):
         """This method returns the pixel value of a given pair of coordinates: