[GRASS-SVN] r44422 - in grass/trunk: general/g.mapset gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 25 16:02:20 EST 2010


Author: martinl
Date: 2010-11-25 13:02:20 -0800 (Thu, 25 Nov 2010)
New Revision: 44422

Modified:
   grass/trunk/general/g.mapset/main.c
   grass/trunk/gui/wxpython/gui_modules/menuform.py
Log:
continue in r44421


Modified: grass/trunk/general/g.mapset/main.c
===================================================================
--- grass/trunk/general/g.mapset/main.c	2010-11-25 17:40:48 UTC (rev 44421)
+++ grass/trunk/general/g.mapset/main.c	2010-11-25 21:02:20 UTC (rev 44422)
@@ -50,8 +50,9 @@
     mapset_opt = G_define_option();
     mapset_opt->key = "mapset";
     mapset_opt->type = TYPE_STRING;
-    mapset_opt->required = NO;
+    mapset_opt->required = YES;
     mapset_opt->multiple = NO;
+    mapset_opt->key_desc = "name";
     mapset_opt->description = _("Name of mapset where to switch");
     mapset_opt->guisection = _("Settings");
 
@@ -60,6 +61,7 @@
     location_opt->type = TYPE_STRING;
     location_opt->required = NO;
     location_opt->multiple = NO;
+    location_opt->key_desc = "name";
     location_opt->description = _("Location name (not location path)");
     location_opt->guisection = _("Settings");
 
@@ -69,8 +71,8 @@
     gisdbase_opt->required = NO;
     gisdbase_opt->multiple = NO;
     gisdbase_opt->key_desc = "path";
-    gisdbase_opt->description =
-	_("GIS data directory (full path to the directory where the new location is)");
+    gisdbase_opt->label = _("GIS data directory");
+    gisdbase_opt->description = _("Full path to the directory where the new location is");
     gisdbase_opt->guisection = _("Settings");
 
     f_add = G_define_flag();

Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-11-25 17:40:48 UTC (rev 44421)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-11-25 21:02:20 UTC (rev 44422)
@@ -388,7 +388,7 @@
         self.flags = list()
         self.keywords = list()
         self.errorMsg = ''
-
+        
         if grassModule is not None:
             try:
                 processTask(tree = etree.fromstring(getInterfaceDescription(grassModule)),
@@ -478,14 +478,18 @@
         
     def getCmdError(self):
         """!Get error string produced by getCmd(ignoreErrors = False)
-
+        
         @return list of errors
         """
         errorList = list()
+        # determine if suppress_required flag is given
+        for f in self.flags:
+            if f['value'] and f['suppress_required']:
+                return errorList
         
         for p in self.params:
-            if p.get('value', '') == '' and p.get('required', 'no') != 'no':
-                if p.get('default', '') == '':
+            if not p.get('value', '') and p.get('required', 'no') != 'no':
+                if not p.get('default', ''):
                     desc = p.get('label', '')
                     if not desc:
                         desc = p['description']
@@ -505,7 +509,7 @@
         cmd = [self.name]
         
         for flag in self.flags:
-            if 'value' in flag and flag['value']:
+            if flag['value']:
                 if len(flag['name']) > 1: # e.g. overwrite
                     cmd += [ '--' + flag['name'] ]
                 else:
@@ -576,14 +580,14 @@
         self.task.name = self.root.get('name', default = 'unknown')
         
         # keywords
-        for keyword in self.__getNodeText(self.root, 'keywords').split(','):
+        for keyword in self._getNodeText(self.root, 'keywords').split(','):
             self.task.keywords.append(keyword.strip())
         
-        self.task.label       = self.__getNodeText(self.root, 'label')
-        self.task.description = self.__getNodeText(self.root, 'description')
+        self.task.label       = self._getNodeText(self.root, 'label')
+        self.task.description = self._getNodeText(self.root, 'description')
         
     def __processParams(self):
-        """!Process parameters description"""
+        """!Process parameters"""
         for p in self.root.findall('parameter'):
             # gisprompt
             node_gisprompt = p.find('gisprompt')
@@ -601,8 +605,8 @@
             node_values = p.find('values')
             if node_values is not None:
                 for pv in node_values.findall('value'):
-                    values.append(self.__getNodeText(pv, 'name'))
-                    desc = self.__getNodeText(pv, 'description')
+                    values.append(self._getNodeText(pv, 'name'))
+                    desc = self._getNodeText(pv, 'description')
                     if desc:
                         values_desc.append(desc)
             
@@ -618,30 +622,37 @@
                 "type"           : p.get('type'),
                 "required"       : p.get('required'),
                 "multiple"       : p.get('multiple'),
-                "label"          : self.__getNodeText(p, 'label'),
-                "description"    : self.__getNodeText(p, 'description'),
+                "label"          : self._getNodeText(p, 'label'),
+                "description"    : self._getNodeText(p, 'description'),
                 'gisprompt'      : gisprompt,
                 'age'            : age,
                 'element'        : element,
                 'prompt'         : prompt,
-                "guisection"     : self.__getNodeText(p, 'guisection'),
-                "guidependency"  : self.__getNodeText(p, 'guidependency'),
-                "default"        : self.__getNodeText(p, 'default'),
+                "guisection"     : self._getNodeText(p, 'guisection'),
+                "guidependency"  : self._getNodeText(p, 'guidependency'),
+                "default"        : self._getNodeText(p, 'default'),
                 "values"         : values,
                 "values_desc"    : values_desc,
                 "value"          : '',
                 "key_desc"       : key_desc } )
             
     def __processFlags(self):
-        """!Process flags description"""
+        """!Process flags"""
         for p in self.root.findall('flag'):
+            if p.find('suppress_required') is not None:
+                suppress_required = True
+            else:
+                suppress_required = False
+            
             self.task.flags.append( {
-                    "name"        : p.get('name'),
-                    "label"       : self.__getNodeText(p, 'label'),
-                    "description" : self.__getNodeText(p, 'description'),
-                    "guisection"  : self.__getNodeText(p, 'guisection') } )
-        
-    def __getNodeText(self, node, tag, default = ''):
+                    "name"              : p.get('name'),
+                    "label"             : self._getNodeText(p, 'label'),
+                    "description"       : self._getNodeText(p, 'description'),
+                    "guisection"        : self._getNodeText(p, 'guisection'),
+                    "suppress_required" : suppress_required,
+                    "value"             : False } )
+            
+    def _getNodeText(self, node, tag, default = ''):
         """!Get node text"""
         p = node.find(tag)
         if p is not None:



More information about the grass-commit mailing list