[GRASS-SVN] r70185 - grass/branches/releasebranch_7_2/scripts/g.search.modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jan 1 12:26:13 PST 2017
Author: neteler
Date: 2017-01-01 12:26:13 -0800 (Sun, 01 Jan 2017)
New Revision: 70185
Modified:
grass/branches/releasebranch_7_2/scripts/g.search.modules/g.search.modules.py
Log:
g.search.modules: flag to negate/invert selection (trunk, r69152)
Modified: grass/branches/releasebranch_7_2/scripts/g.search.modules/g.search.modules.py
===================================================================
--- grass/branches/releasebranch_7_2/scripts/g.search.modules/g.search.modules.py 2017-01-01 20:06:20 UTC (rev 70184)
+++ grass/branches/releasebranch_7_2/scripts/g.search.modules/g.search.modules.py 2017-01-01 20:26:13 UTC (rev 70185)
@@ -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