[GRASS-SVN] r53575 - grass/trunk/lib/python/pygrass/modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Oct 26 23:59:19 PDT 2012
Author: zarch
Date: 2012-10-26 23:59:19 -0700 (Fri, 26 Oct 2012)
New Revision: 53575
Modified:
grass/trunk/lib/python/pygrass/modules/__init__.py
Log:
Use dictionary method: get, istead of if condition
Modified: grass/trunk/lib/python/pygrass/modules/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/__init__.py 2012-10-27 05:53:24 UTC (rev 53574)
+++ grass/trunk/lib/python/pygrass/modules/__init__.py 2012-10-27 06:59:19 UTC (rev 53575)
@@ -142,13 +142,13 @@
else:
raise TypeError('New type: %s, ignored' % diz['type'])
- self.description = diz['description']
- self.keydesc = diz['keydesc'] if 'keydesc' in diz else None
+ self.description = diz.get('description', None)
+ self.keydesc = diz.get('keydesc', None)
self.values = [self._type(
i) for i in diz['values']] if 'values' in diz else None
self.default = self._type(
diz['default']) if 'default' in diz else None
- self.guisection = diz['guisection'] if 'guisection' in diz else None
+ self.guisection = diz.get('guisection', None)
if 'gisprompt' in diz:
self.type = diz['gisprompt']['prompt']
self.input = False if diz['gisprompt']['age'] == 'new' else True
@@ -247,8 +247,8 @@
self.special = True if self.name in (
'verbose', 'overwrite', 'quiet', 'run') else False
self.description = diz['description']
- self.default = diz['default'] if 'default' in diz else None
- self.guisection = diz['guisection'] if 'guisection' in diz else None
+ self.default = diz.get('default', None)
+ self.guisection = diz.get('guisection', None)
def __str__(self):
if self.value:
More information about the grass-commit
mailing list