[GRASS-SVN] r62908 - sandbox/martinl

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Nov 25 01:01:50 PST 2014


Author: martinl
Date: 2014-11-25 01:01:50 -0800 (Tue, 25 Nov 2014)
New Revision: 62908

Added:
   sandbox/martinl/d.frame/
Modified:
   sandbox/martinl/print_module_parameters.py
   sandbox/martinl/print_module_parameters_csv.py
Log:
print_module_parameters: fix getting labels

Modified: sandbox/martinl/print_module_parameters.py
===================================================================
--- sandbox/martinl/print_module_parameters.py	2014-11-25 08:54:03 UTC (rev 62907)
+++ sandbox/martinl/print_module_parameters.py	2014-11-25 09:01:50 UTC (rev 62908)
@@ -5,6 +5,12 @@
 from grass.script import task as gtask
 from grass.script.core import get_commands
 
+def get_label(p):
+    label = p.get('label')
+    if label:
+        return label
+    return p.get('description')
+    
 def main():
     print '-' * 80
     for cmd in sorted(get_commands()[0]):
@@ -13,9 +19,9 @@
         for f in task.get_options()['flags']:
             if len(f.get('name')) > 1: # skip overwrite, ...
                 continue
-            print '\t' + f.get('name') + ': ' + f.get('description')
+            print '\t' + f.get('name') + ': ' + get_label(f)
         for p in task.get_options()['params']:
-            print '\t' + p.get('name') + ': ' + p.get('description')
+            print '\t' + p.get('name') + ': ' + get_label(p)
         print '-' * 80
 
 if __name__ == "__main__":

Modified: sandbox/martinl/print_module_parameters_csv.py
===================================================================
--- sandbox/martinl/print_module_parameters_csv.py	2014-11-25 08:54:03 UTC (rev 62907)
+++ sandbox/martinl/print_module_parameters_csv.py	2014-11-25 09:01:50 UTC (rev 62908)
@@ -7,6 +7,12 @@
 from grass.script.core import get_commands
 from grass.exceptions import ScriptError
 
+def get_label(p):
+    label = p.get('label')
+    if label:
+        return label
+    return p.get('description')
+
 def main():
 #    print '-' * 80
     for cmd in sorted(get_commands()[0]):
@@ -20,9 +26,9 @@
         for f in task.get_options()['flags']:
             if len(f.get('name')) > 1: # skip --overwrite, ...
                 continue
-            print task.get_name() + '€' + f.get('name') + '€' + f.get('description')
+            print task.get_name() + '€' + f.get('name') + '€' + get_label(f)
         for p in task.get_options()['params']:
-            print task.get_name() + '€' + p.get('name') + '€' + p.get('description')
+            print task.get_name() + '€' + p.get('name') + '€' + get_label(p)
 
 if __name__ == "__main__":
     main()



More information about the grass-commit mailing list