فهرست منبع

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.


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@69152 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 8 سال پیش
والد
کامیت
d06f6f9e77
1فایلهای تغییر یافته به همراه12 افزوده شده و 3 حذف شده
  1. 12 3
      scripts/g.search.modules/g.search.modules.py

+ 12 - 3
scripts/g.search.modules/g.search.modules.py

@@ -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 @@ def main():
     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 @@ def main():
     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 @@ def colorize(text, attrs=None, pattern=None):
         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 @@ def _search_module(keywords, logical_and=False, manpages=False):
                                            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': {