[GRASS-SVN] r65596 - grass/trunk/lib/python/pygrass/modules/interface

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 16 02:38:53 PDT 2015


Author: zarch
Date: 2015-07-16 02:38:53 -0700 (Thu, 16 Jul 2015)
New Revision: 65596

Modified:
   grass/trunk/lib/python/pygrass/modules/interface/flag.py
   grass/trunk/lib/python/pygrass/modules/interface/read.py
Log:
Add suppress_required attribute to the Flag object

Modified: grass/trunk/lib/python/pygrass/modules/interface/flag.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/interface/flag.py	2015-07-15 17:27:37 UTC (rev 65595)
+++ grass/trunk/lib/python/pygrass/modules/interface/flag.py	2015-07-16 09:38:53 UTC (rev 65596)
@@ -33,6 +33,7 @@
         self.description = diz.get('description', None)
         self.default = diz.get('default', None)
         self.guisection = diz.get('guisection', None)
+        self.suppress_required = True if 'suppress_required' in diz else False
 
     def get_bash(self):
         """Return the BASH representation of a flag.
@@ -88,11 +89,18 @@
         """Return a string with the python representation of the instance."""
         return "Flag <%s> (%s)" % (self.name, self.description)
 
+    def __bool__(self):
+        """Return a boolean value"""
+        return self.value
+
+    def __nonzero__(self):
+        return self.__bool__()
+
     @docstring_property(__doc__)
     def __doc__(self):
         """Return a documentation string, something like:
 
-        {name}: {default}
+        {name}: {default}, suppress required {supress}
             {description}
 
         >>>  flag = Flag(diz=dict(name='a', description='Flag description',
@@ -109,4 +117,7 @@
         """
         return read.DOC['flag'].format(name=self.name,
                                        default=repr(self.default),
-                                       description=self.description)
+                                       description=self.description,
+                                       supress=('suppress required'
+                                                if self.suppress_required
+                                                else ''))

Modified: grass/trunk/lib/python/pygrass/modules/interface/read.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/interface/read.py	2015-07-15 17:27:37 UTC (rev 65595)
+++ grass/trunk/lib/python/pygrass/modules/interface/read.py	2015-07-16 09:38:53 UTC (rev 65596)
@@ -91,7 +91,7 @@
 """,
     #------------------------------------------------------------
     # flag
-    'flag': """{name}: {default}
+    'flag': """{name}: {default}, {supress}
     {description}""",
     #------------------------------------------------------------
     # foot



More information about the grass-commit mailing list