[GRASS-SVN] r60529 - grass/trunk/general/g.mlist

svn_grass at osgeo.org svn_grass at osgeo.org
Wed May 28 01:20:16 PDT 2014


Author: martinl
Date: 2014-05-28 01:20:16 -0700 (Wed, 28 May 2014)
New Revision: 60529

Modified:
   grass/trunk/general/g.mlist/g.mlist.html
   grass/trunk/general/g.mlist/main.c
Log:
g.mlist: mapset=.. prints data files from all available mapsets

Modified: grass/trunk/general/g.mlist/g.mlist.html
===================================================================
--- grass/trunk/general/g.mlist/g.mlist.html	2014-05-28 07:58:10 UTC (rev 60528)
+++ grass/trunk/general/g.mlist/g.mlist.html	2014-05-28 08:20:16 UTC (rev 60529)
@@ -5,8 +5,8 @@
 version of <em><a href="g.list.html">g.list</a></em>.
 
 <p>
-See also the <em>g.list</em> help page for discussion of some module
-options.
+See also the <em><a href="g.list.html">g.list</a></em> help page for
+discussion of some module options.
 
 <h2>NOTES</h2>
 
@@ -26,8 +26,53 @@
 g.mlist type=rast,vect
 </pre></div>
 
-<h3>Wildcards:</h3>
+<h3>Mapset search path</h3>
 
+If <b>mapset</b> is not specified than <em>g.mlist</em> searches for
+data files in the mapsets which are included in the search path
+(defined by <em><a href="g.mapsets.html">g.mapsets</a></em>),
+see <tt>g.mapsets -p</tt>.
+
+<div class="code"><pre>
+g.mlist rast
+
+raster map(s) available in mapset <user1>:
+dmt
+...
+raster map(s) available in mapset <PERMANENT>:
+aspect
+...
+</pre></div>
+
+By option <b>mapset</b>=. (one dot) can be listed only data files from
+the current mapset:
+
+<div class="code"><pre>
+g.mlist rast mapset=.
+raster map(s) available in mapset <user1>:
+dmt
+</pre></div>
+
+Similarly <b>mapset</b>=.. (two dots) prints data files from all
+available mapsets also including those which are not listed in the
+current search path (see <tt>g.mapsets -l</tt>).
+
+<div class="code"><pre>
+g.mlist rast mapset=..
+
+raster map(s) available in mapset <landsat>:
+lsat5_1987_10
+...
+raster map(s) available in mapset <user1>:
+dmt
+...
+raster map(s) available in mapset <PERMANENT>:
+aspect
+...
+</pre></div>
+
+<h3>Wildcards</h3>
+
 List all vector maps starting with letter "r":
 <div class="code"><pre>
 g.mlist type=vect pattern="r*"
@@ -38,7 +83,7 @@
 g.mlist type=rast pattern="N45E00?.meters"
 </pre></div>
 
-Use of <em>exclude</em> parameter:
+Use of <b>exclude</b> parameter:
 <div class="code"><pre>
 # without exclude:
   g.mlist rast pat="r*" mapset=PERMANENT
@@ -59,31 +104,30 @@
   rushmore
 </pre></div>
 
-<h3>Regular expressions:</h3>
+<h3>Regular expressions</h3>
 
-List all soil maps starting with "soils" in their name:
+List all soil maps starting with "soils" in their name:
 <div class="code"><pre>
 g.mlist -r type=rast pattern='^soils'
 </pre></div>
 
-List "tmp" if "tmp" raster map exists:
+List "tmp" if "tmp" raster map exists:
 <div class="code"><pre>
 g.mlist -r pattern='^tmp$'
 </pre></div>
 
-List "tmp0" ..."tmp9" if corresponding vector map exists (each map name linewise):
+List "tmp0" ..."tmp9" if corresponding vector map exists (each map name linewise):
 <div class="code"><pre>
 g.mlist -r type=vect pattern='^tmp[0-9]$'
 </pre></div>
 
-List "tmp0" ..."tmp9" if corresponding vector map exists (each map name comma separated):
+List "tmp0"..."tmp9" if corresponding vector map exists (each map name comma separated):
 <div class="code"><pre>
 g.mlist -r type=vect separator=comma pattern='^tmp[0-9]$'
 </pre></div>
 
+<h3>Extended regular expressions</h3>
 
-<h3>Extended regular expressions:</h3>
-
 List all precipitation maps for the years 1997-2012, comma separated:
 <div class="code"><pre>
 g.mlist -e type=rast separator=comma pattern="precip_total.(199[7-9]|200[0-9]|201[0-2]).sum"

Modified: grass/trunk/general/g.mlist/main.c
===================================================================
--- grass/trunk/general/g.mlist/main.c	2014-05-28 07:58:10 UTC (rev 60528)
+++ grass/trunk/general/g.mlist/main.c	2014-05-28 08:20:16 UTC (rev 60529)
@@ -93,7 +93,7 @@
     opt.mapset = G_define_standard_option(G_OPT_M_MAPSET);
     opt.mapset->label =
 	_("Name of mapset to list (default: current search path)");
-
+    opt.mapset->description = _("'.' for current mapset; '..' for all mapsets in location");
     opt.separator = G_define_standard_option(G_OPT_F_SEP);
     opt.separator->answer = "newline";
 
@@ -175,7 +175,13 @@
     if ((mapset = opt.mapset->answer) == NULL)
 	mapset = "";
     else if (strcmp(mapset, ".") == 0)
-	mapset = G_mapset();
+	mapset = G_mapset();   /* current mapset */
+    else if (strcmp(mapset, "..") == 0) {
+        if (flag.pretty->answer || flag.full->answer)
+            G_fatal_error(_("-%c/-%c and %s=.. are mutually exclusive"),
+                          flag.pretty->key, flag.full->key, opt.mapset->key);
+        mapset = NULL;         /* all mapsets */
+    }
 
     for (i = 0; opt.type->answers[i]; i++) {
 	if (strcmp(opt.type->answers[i], "all") == 0)
@@ -241,7 +247,19 @@
     int count;
     int i;
 
-    if (!mapset || !*mapset) {
+    if (!mapset) {
+        /* all mapsets from current location */
+        int n;
+        char **ms;
+        ms = G_get_available_mapsets();
+        for (n = 0; ms[n]; n++) {
+            make_list(fp, elem, ms[n], separator, add_type, add_mapset,
+		      n == 0);
+        }
+        return;
+    }
+    else if (!*mapset) {
+        /* mapsets from search path only */
 	int n;
 	for (n = 0; mapset = G_get_mapset_name(n), mapset; n++)
 	    make_list(fp, elem, mapset, separator, add_type, add_mapset,



More information about the grass-commit mailing list