[GRASS-SVN] r69152 - grass/trunk/scripts/g.search.modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Aug 18 07:27:36 PDT 2016


Author: wenzeslaus
Date: 2016-08-18 07:27:36 -0700 (Thu, 18 Aug 2016)
New Revision: 69152

Modified:
   grass/trunk/scripts/g.search.modules/g.search.modules.py
Log:
g.search.modules: flag to negate/invert selection

Useful for reviewing info or manual pages.
Alternativeky it could be -i (for invert) but -n (for NOT) used.


Modified: grass/trunk/scripts/g.search.modules/g.search.modules.py
===================================================================
--- grass/trunk/scripts/g.search.modules/g.search.modules.py	2016-08-18 06:50:38 UTC (rev 69151)
+++ grass/trunk/scripts/g.search.modules/g.search.modules.py	2016-08-18 14:27:36 UTC (rev 69152)
@@ -31,6 +31,11 @@
 #% guisection: Output
 #%end
 #%flag
+#% key: n
+#% description: Invert selection (logical NOT)
+#% guisection: Output
+#%end
+#%flag
 #% key: m
 #% description: Search in manual pages too (can be slow)
 #% guisection: Output
@@ -69,6 +74,7 @@
     global COLORIZE
     keywords = options['keyword'].lower().split(',')
     AND = flags['a']
+    NOT = flags['n']
     manpages = flags['m']
     out_format = None
     if flags['g']:
@@ -78,7 +84,7 @@
     else:
         COLORIZE = flags['c']
 
-    modules = _search_module(keywords, AND, manpages)
+    modules = _search_module(keywords, AND, NOT, manpages)
 
     print_results(modules, out_format)
 
@@ -162,7 +168,7 @@
         return colored(text, attrs=attrs)
 
 
-def _search_module(keywords, logical_and=False, manpages=False):
+def _search_module(keywords, logical_and=False, invert=False, manpages=False):
     """Search modules by given keywords
 
     :param list.<str> keywords: list of keywords
@@ -212,7 +218,10 @@
                                            attrs=['underline'],
                                            pattern=keyword)
 
-        if False not in found:
+        add = False not in found
+        if invert:
+            add = not add
+        if add:
             found_modules.append({
                 'name': name,
                 'attributes': {



More information about the grass-commit mailing list