[GRASS-SVN] r46106 - in grass/trunk: lib/python vector/v.info

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Apr 25 20:37:21 EDT 2011


Author: martinl
Date: 2011-04-25 17:37:21 -0700 (Mon, 25 Apr 2011)
New Revision: 46106

Modified:
   grass/trunk/lib/python/vector.py
   grass/trunk/vector/v.info/local_proto.h
   grass/trunk/vector/v.info/main.c
   grass/trunk/vector/v.info/parse.c
   grass/trunk/vector/v.info/v.info.html
Log:
v.info: replace 'shell' option with seperate flags - g/e/t


Modified: grass/trunk/lib/python/vector.py
===================================================================
--- grass/trunk/lib/python/vector.py	2011-04-26 00:20:18 UTC (rev 46105)
+++ grass/trunk/lib/python/vector.py	2011-04-26 00:37:21 UTC (rev 46106)
@@ -143,7 +143,7 @@
     """
     run_command('v.support', map = map, cmdhist = os.environ['CMDLINE'])
 
-# run "v.info shell=topo" and parse output
+# run "v.info -t" and parse output
 
 def vector_info_topo(map):
     """!Return information about a vector map (interface to `v.info
@@ -160,7 +160,7 @@
 
     @return parsed output
     """
-    s = read_command('v.info', map = map, shell = 'topo')
+    s = read_command('v.info', flags = 't', map = map)
     ret = parse_key_val(s, val_type = int)
     if ret.has_key('map3d'):
         ret['map3d'] = bool(ret['map3d'])

Modified: grass/trunk/vector/v.info/local_proto.h
===================================================================
--- grass/trunk/vector/v.info/local_proto.h	2011-04-26 00:20:18 UTC (rev 46105)
+++ grass/trunk/vector/v.info/local_proto.h	2011-04-26 00:37:21 UTC (rev 46106)
@@ -1,9 +1,9 @@
 #include <grass/vector.h>
 
-#define NO_INFO     0x00
-#define BASIC_INFO  0x02
-#define REGION_INFO 0x04
-#define TOPO_INFO   0x08
+#define SHELL_NO     0x00
+#define SHELL_BASIC  0x02
+#define SHELL_REGION 0x04
+#define SHELL_TOPO   0x08
 
 /* level1.c */
 int level_one_info(struct Map_info *);

Modified: grass/trunk/vector/v.info/main.c
===================================================================
--- grass/trunk/vector/v.info/main.c	2011-04-26 00:20:18 UTC (rev 46105)
+++ grass/trunk/vector/v.info/main.c	2011-04-26 00:37:21 UTC (rev 46106)
@@ -36,6 +36,8 @@
     module = G_define_module();
     G_add_keyword(_("vector"));
     G_add_keyword(_("metadata"));
+    G_add_keyword(_("topology"));
+    G_add_keyword(_("extent"));
     G_add_keyword(_("history"));
     G_add_keyword(_("attribute columns"));
     
@@ -79,13 +81,13 @@
 	return (EXIT_SUCCESS);
     }
     
-    if (shell_flag & BASIC_INFO) {
+    if (shell_flag & SHELL_BASIC) {
 	print_shell(&Map);
     }
-    if (shell_flag & REGION_INFO) {
+    if (shell_flag & SHELL_REGION) {
 	print_region(&Map);
     }
-    if (shell_flag & TOPO_INFO) {
+    if (shell_flag & SHELL_TOPO) {
 	print_topo(&Map);
     }
     if (shell_flag == 0) {

Modified: grass/trunk/vector/v.info/parse.c
===================================================================
--- grass/trunk/vector/v.info/parse.c	2011-04-26 00:20:18 UTC (rev 46105)
+++ grass/trunk/vector/v.info/parse.c	2011-04-26 00:37:21 UTC (rev 46106)
@@ -12,23 +12,12 @@
     int i;
     const char *answer;
     
-    struct Option *input_opt, *field_opt, *print_opt;
-    struct Flag *hist_flag, *col_flag;
+    struct Option *input_opt, *field_opt;
+    struct Flag *hist_flag, *col_flag, *shell_flag, *region_flag, *topo_flag;
     
     input_opt = G_define_standard_option(G_OPT_V_MAP);
 
     field_opt = G_define_standard_option(G_OPT_V_FIELD);
-
-    print_opt = G_define_option();
-    print_opt->key = "shell";
-    print_opt->multiple = YES;
-    print_opt->options = "basic,region,topo";
-    print_opt->label = _("Print info in shell script style");
-    print_opt->description = _("Ignored if -h or -c flags are given");
-    print_opt->descriptions = _("basic;basic info only;"
-				"region;map region;"
-				"topo;topology information");
-    print_opt->guisection = _("Print");
     
     hist_flag = G_define_flag();
     hist_flag->key = 'h';
@@ -41,6 +30,21 @@
 	_("Print types/names of table columns for specified layer instead of info and exit");
     col_flag->guisection = _("Print");
 
+    shell_flag = G_define_flag();
+    shell_flag->key = 'g';
+    shell_flag->description = _("Print basic info in shell script style");
+    shell_flag->guisection = _("Print");
+
+    region_flag = G_define_flag();
+    region_flag->key = 'e';
+    region_flag->description = _("Print also region info in shell script style");
+    region_flag->guisection = _("Print");
+
+    topo_flag = G_define_flag();
+    topo_flag->key = 't';
+    topo_flag->description = _("Print also topology info in shell script style");
+    topo_flag->guisection = _("Print");
+
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
@@ -49,16 +53,11 @@
     *history = hist_flag->answer ? TRUE : FALSE;
     *columns = col_flag->answer  ? TRUE : FALSE;
     i = 0;
-    *shell = NO_INFO;
-    if (print_opt->answer) {
-	while(print_opt->answers[i]) {
-	    answer = print_opt->answers[i++];
-	    if (strcmp(answer, "basic") == 0)
-		*shell |= BASIC_INFO;
-	    else if (strcmp(answer, "region") == 0)
-		*shell |= REGION_INFO;
-	    else if (strcmp(answer, "topo") == 0)
-		*shell |= TOPO_INFO;
-	}
-    }
+    *shell = SHELL_NO;
+    if (shell_flag->answer)
+	*shell |= SHELL_BASIC;
+    if (region_flag->answer)
+	*shell |= SHELL_REGION;
+    if (topo_flag->answer)
+	*shell |= SHELL_TOPO;
 }

Modified: grass/trunk/vector/v.info/v.info.html
===================================================================
--- grass/trunk/vector/v.info/v.info.html	2011-04-26 00:20:18 UTC (rev 46105)
+++ grass/trunk/vector/v.info/v.info.html	2011-04-26 00:37:21 UTC (rev 46106)
@@ -82,7 +82,7 @@
 <h3>Basic info in shell script style</h3>
 
 <div class="code"><pre>
-v.info map=geology shell=basic,region,topo
+v.info -get map=geology 
 
 name=geology
 mapset=PERMANENT
@@ -117,7 +117,7 @@
 </pre></div>
 
 <div class="code"><pre>
-v.info map=geology shell=region
+v.info -e map=geology
 
 north=318117.43741634
 south=10875.82723209



More information about the grass-commit mailing list