[GRASS-SVN] r54673 - in grass-addons/grass7/raster/r.agent: libagent tests
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jan 16 07:59:35 PST 2013
Author: mic
Date: 2013-01-16 07:59:33 -0800 (Wed, 16 Jan 2013)
New Revision: 54673
Modified:
grass-addons/grass7/raster/r.agent/libagent/grassland.py
grass-addons/grass7/raster/r.agent/libagent/playground.py
grass-addons/grass7/raster/r.agent/tests/test_grassland.py
grass-addons/grass7/raster/r.agent/tests/test_playground.py
Log:
add tests and move methods to upper class
Modified: grass-addons/grass7/raster/r.agent/libagent/grassland.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/grassland.py 2013-01-16 14:13:16 UTC (rev 54672)
+++ grass-addons/grass7/raster/r.agent/libagent/grassland.py 2013-01-16 15:59:33 UTC (rev 54673)
@@ -50,15 +50,27 @@
self.grassmapnames[layername] = grassmapname
self.setlayer(layername, layer)
- def writelayer(self, layername, force=False):
+ def removelayer(self, layername):
+ """
+ Remove (forget about) the layer named from the layer collection
+ @param string name of the layer
+ """
+ if self.layers.has_key(layername):
+ self.layers.pop(layername)
+ if self.grassmapnames.has_key(layername):
+ self.grassmapnames.pop(layername)
+
+ def writelayer(self, layername, grassmapname=False, force=False):
+ """
+ Write out a given layer to a GRASS map file
+ @param string name of the layer to be exported
+ @param string optional name of the GRASS map file to be created
+ @param boolean whether an existing file may be overwritten
+ """
+ #TODO implement
if self.layers.has_key(layername) and \
self.grassmapnames.has_key(layername):
grassmapname = self.grassmapnames[layername]
layer = self.layers[layername]
layer.write(grassmapname, overwrite=force)
- def writelayerasnew(self, layername, grassmapname):
- if self.layers.has_key(layername):
- layer = self.layers[layername]
- layer.write(grassmapname)
-
Modified: grass-addons/grass7/raster/r.agent/libagent/playground.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/playground.py 2013-01-16 14:13:16 UTC (rev 54672)
+++ grass-addons/grass7/raster/r.agent/libagent/playground.py 2013-01-16 15:59:33 UTC (rev 54673)
@@ -48,13 +48,15 @@
"May not overwrite existing layer.")
self.layers[layername] = layer
- def createlayer(self, layername, force=False):
+ def createlayer(self, layername, filename=False, force=False):
"""
Create a new layer and add it to the layer collection
@param string name of the layer
+ @param string file name if it is to be created from an existing file
@param boolean whether to overwrite an existing layer
"""
#TODO rows vs. cols
+ #TODO import from file
layer = []
for i in range(self.region["rows"]):
l.append( [[] for j in range(self.region["cols"])])
@@ -79,6 +81,14 @@
if self.layers.has_key(layername):
self.layers.pop(layername)
- def writelayer(self, layername):
+ def writelayer(self, layername, filename, force=False):
+ """
+ Write out a given layer to a certain file
+ @param string name of the layer to be exported
+ @param string name of the file to be written to
+ @param boolean whether an existing file may be overwritten
+ """
+ #TODO export to file
+ #TODO overwrite policy: to increment or to fail?
pass
Modified: grass-addons/grass7/raster/r.agent/tests/test_grassland.py
===================================================================
--- grass-addons/grass7/raster/r.agent/tests/test_grassland.py 2013-01-16 14:13:16 UTC (rev 54672)
+++ grass-addons/grass7/raster/r.agent/tests/test_grassland.py 2013-01-16 15:59:33 UTC (rev 54673)
@@ -31,10 +31,15 @@
def test_removelayer(self):
self.pg.layers["foo"] = [0]
+ self.pg.grassmapnames["foo"] = "foo"
self.assertTrue(self.pg.layers.has_key("foo"))
self.pg.removelayer("foo")
self.assertFalse(self.pg.layers.has_key("foo"))
+ self.assertFalse(self.pg.grassmapnames.has_key("foo"))
+ def test_writelayer(self):
+ pass
+
# def tearDown(self):
Modified: grass-addons/grass7/raster/r.agent/tests/test_playground.py
===================================================================
--- grass-addons/grass7/raster/r.agent/tests/test_playground.py 2013-01-16 14:13:16 UTC (rev 54672)
+++ grass-addons/grass7/raster/r.agent/tests/test_playground.py 2013-01-16 15:59:33 UTC (rev 54673)
@@ -43,5 +43,8 @@
self.pg.removelayer("foo")
self.assertFalse(self.pg.layers.has_key("foo"))
+ def test_writelayer(self):
+ pass
+
# def tearDown(self):
More information about the grass-commit
mailing list