[GRASS-SVN] r54812 - grass/trunk/lib/python/pygrass/modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jan 28 05:23:18 PST 2013
Author: zarch
Date: 2013-01-28 05:23:18 -0800 (Mon, 28 Jan 2013)
New Revision: 54812
Modified:
grass/trunk/lib/python/pygrass/modules/__init__.py
Log:
Make it easier to get/set inputs and outputs values of the Module class
Modified: grass/trunk/lib/python/pygrass/modules/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/__init__.py 2013-01-28 11:25:44 UTC (rev 54811)
+++ grass/trunk/lib/python/pygrass/modules/__init__.py 2013-01-28 13:23:18 UTC (rev 54812)
@@ -254,6 +254,20 @@
self.type = dict_type
super(TypeDict, self).__init__(*args, **kargs)
+ def __getattr__(self, key):
+ if key in self:
+ return self[key].value
+ return OrderedDict.__getattr__(self, key)
+
+ def __setattr__(self, key, value):
+ if key in self:
+ self[key].value = value
+ else:
+ OrderedDict.__setattr__(self, key, value)
+
+ def __dir__(self):
+ return self.keys()
+
def __setitem__(self, key, value):
if isinstance(value, self.type):
super(TypeDict, self).__setitem__(key, value)
More information about the grass-commit
mailing list