浏览代码

Remove g.list/g.remove

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@62009 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho 10 年之前
父节点
当前提交
e1fe51f49c

+ 0 - 12
general/g.list/Makefile

@@ -1,12 +0,0 @@
-
-MODULE_TOPDIR = ../..
-
-PGM = g.list
-
-include $(MODULE_TOPDIR)/include/Make/Module.make
-
-LIBES = $(MANAGELIB) $(GISLIB)
-DEPENDENCIES = $(MANAGEDEP) $(GISDEP)
-
-default: cmd
-

+ 0 - 62
general/g.list/g.list.html

@@ -1,62 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>g.list</em> allows the user to list user-specified, available and
-accessible files from <em>mapsets</em> under the user's current
-location.
-
-
-<h2>NOTES</h2>
-
-If unspecified, files of the specified <b>type</b> from all mapsets in
-the user's current search path will be listed to standard output. To
-find out which mapsets are in the current search path, use
-<em><a href="g.mapsets.html">g.mapsets</a></em> with the <b>-p</b>
-flag.
-
-<p>
-If the <b>mapset</b> option is set to &quot;.&quot; then only files
-from the current mapset will be displayed.
-
-<p>
-If the user requests that files from a mapset to which access has been
-restricted (see <em><a href="g.access.html">g.access</a></em>) be
-listed, no files from this mapset will be listed.
-
-
-<h2>EXAMPLES</h2>
-
-List all raster maps:
-
-<div class="code"><pre>
-   g.list type=rast
-</pre></div>
-
-<p>
-List all raster and vector maps from mapset &quot;user&quot;:
-
-<div class="code"><pre>
-   g.list type=rast,vect mapset=user
-</pre></div>
-
-
-<h2>SEE ALSO</h2>
-
-<em>
-<a href="g.access.html">g.access</a>,
-<a href="g.mapsets.html">g.mapsets</a>,
-<a href="g.mlist.html">g.mlist</a>,
-<a href="i.group.html">i.group</a>,
-<a href="t.list.html">t.list</a>,
-<a href="t.rast.list.html">t.rast.list</a>,
-<a href="t.vect.list.html">t.vect.list</a>
-</em>
-
-
-<h2>AUTHOR</h2>
-
-Michael Shapiro,
-U.S.Army Construction Engineering 
-Research Laboratory
-
-<p>
-<i>Last changed: $Date$</i>

+ 0 - 96
general/g.list/main.c

@@ -1,96 +0,0 @@
-
-/****************************************************************************
- *
- * MODULE:       g.list
- *               
- * AUTHOR(S):    Michael Shapiro,
- *               U.S.Army Construction Engineering Research Laboratory
- *               Some updates by various authors from GRASS Development Team
- *               
- * PURPOSE:      Lists available GRASS data base elements of the user-specified data type to
- *               standard output
- *
- * COPYRIGHT:    (C) 1999-2009, 2011 by the GRASS Development Team
- *
- *               This program is free software under the GNU General
- *               Public License (>=v2). Read the file COPYING that
- *               comes with GRASS for details.
- *
- *****************************************************************************/
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <grass/gis.h>
-#include <grass/spawn.h>
-#include <grass/glocale.h>
-#include <grass/manage.h>
-
-struct Option *element;
-
-int main(int argc, char *argv[])
-{
-    int i, n, nlist;
-    struct GModule *module;
-    struct Option *mapset_opt;
-    struct Flag *full;
-    const char *mapset;
-
-    G_gisinit(argv[0]);
-
-    M_read_list(0, &nlist);
-
-    module = G_define_module();
-    G_add_keyword(_("general"));
-    G_add_keyword(_("map management"));
-    G_add_keyword(_("list"));
-    module->description =
-	_("Lists available GRASS data base files "
-	  "of the user-specified data type.");
-
-    element = G_define_standard_option(G_OPT_M_DATATYPE);
-    element->options = M_get_options(TRUE);
-    element->descriptions = M_get_option_desc(TRUE);
-    
-    mapset_opt = G_define_standard_option(G_OPT_M_MAPSET);
-    
-    full = G_define_flag();
-    full->key = 'f';
-    full->description = _("Verbose listing (also list map titles)");
-
-    if (G_parser(argc, argv))
-	exit(EXIT_FAILURE);
-
-    mapset = mapset_opt->answer;
-    if (!mapset)
-	mapset = "";
-
-    if (strcmp(mapset, ".") == 0)
-	mapset = G_mapset();
-
-    i = 0;
-    while (element->answers[i]) {
-	n = M_get_element(element->answers[i]);
-
-	if (full->answer) {
-	    char lister[GPATH_MAX];
-	    
-	    if (n > -1) {
-		sprintf(lister, "%s/etc/lister/%s", G_gisbase(),
-			M_get_list(n)->element[0]);
-		G_debug(3, "lister CMD: %s", lister);
-	    }
-	    if (n > -1 && access(lister, X_OK) == 0) /* execute permission */
-		G_spawn(lister, lister, mapset, NULL);
-	    else
-		M_do_list(n, mapset);
-	}
-	else {
-	    M_do_list(n, mapset);
-	}
-
-	i++;
-    }
-
-    exit(EXIT_SUCCESS);
-}

+ 0 - 183
general/g.list/testsuite/test_g_list.py

@@ -1,183 +0,0 @@
-
-import grass.gunittest
-from grass.script import read_command
-
-LIST_RASTERS = """----------------------------------------------
-
-raster files available in mapset <PERMANENT>:
-aspect                    elevation_shade           lsat7_2002_70
-basin_50K                 facility                  lsat7_2002_80
-boundary_county_500m      geology_30m               ncmask_500m
-cfactorbare_1m            lakes                     ortho_2001_t792_1m
-cfactorgrow_1m            landclass96               roadsmajor
-el_D782_6m                landcover_1m              slope
-el_D783_6m                landuse96_28m             soilsID
-el_D792_6m                lsat7_2002_10             soils_Kfactor
-el_D793_6m                lsat7_2002_20             streams_derived
-elev_lid792_1m            lsat7_2002_30             towns
-elev_ned_30m              lsat7_2002_40             urban
-elev_srtm_30m             lsat7_2002_50             zipcodes
-elev_state_500m           lsat7_2002_61             zipcodes_dbl
-elevation                 lsat7_2002_62
-
-"""
-
-LIST_VECTORS = """----------------------------------------------
-
-vector files available in mapset <PERMANENT>:
-P079214                   elev_lid792_bepts         poi_names_wake
-P079215                   elev_lid792_cont1m        precip_30ynormals
-P079218                   elev_lid792_randpts       precip_30ynormals_3d
-P079219                   elev_lidrural_mrpts       railroads
-boundary_county           elev_lidrural_mrptsft     roadsmajor
-boundary_municp           elev_ned10m_cont10m       schools_wake
-bridges                   firestations              soils_general
-busroute1                 geodetic_pts              soils_wake
-busroute11                geodetic_swwake_pts       streams
-busroute6                 geology                   streets_wake
-busroute_a                geonames_NC               swwake_10m
-busroutesall              geonames_wake             urbanarea
-busstopsall               hospitals                 usgsgages
-census_wake2000           lakes                     zipcodes_wake
-censusblk_swwake          nc_state
-comm_colleges             overpasses
-
-"""
-
-LIST_GROUPS = """----------------------------------------------
-imagery group files available in mapset <landsat>:
-lsat7_2000
-
-"""
-
-LIST_RASTERS_MAPSET = """----------------------------------------------
-raster files available in mapset <landsat>:
-lsat5_1987_10   lsat5_1987_40   lsat5_1987_70   lsat7_2000_30   lsat7_2000_61
-lsat5_1987_20   lsat5_1987_50   lsat7_2000_10   lsat7_2000_40   lsat7_2000_70
-lsat5_1987_30   lsat5_1987_60   lsat7_2000_20   lsat7_2000_50   lsat7_2000_80
-
-"""
-
-LIST_RASTERS_TITLES = """----------------------------------------------
-
-raster files available in mapset <PERMANENT>:
-aspect             South-West Wake county: Aspect [degrees from east]
-basin_50K          South-West Wake county: Watersheds derived from 30m NED
-boundary_county_500m North Carolina county boundaries
-cfactorbare_1m     Rural area: C-factor with fields bare
-cfactorgrow_1m     Rural area: C-factor for growing season
-el_D782_6m         NC Flood lidar-based 6m(20ft) DEM
-el_D783_6m         NC Flood lidar-based 6m(20ft) DEM
-el_D792_6m         NC Flood lidar-based 6m(20ft) DEM
-el_D793_6m         NC Flood lidar-based 6m(20ft) DEM
-elev_lid792_1m     Rural area: Lidar-based 1m DEM
-elev_ned_30m       South-West Wake county: National Elevation Data 30m
-elev_srtm_30m      South-West Wake county: SRTM-V1 30m terrain surface model
-elev_state_500m    North Carolina DEM 500m
-elevation          South-West Wake county: Elevation NED 10m
-elevation_shade    South-West Wake county: Shaded relief
-facility           Rural area: Footprint of planned facility
-geology_30m        South-West Wake county: geology derived from vector map
-lakes              South-West Wake county: Wake county lakes
-landclass96        South-West Wake county: Simplified landuse classes
-landcover_1m       Rural area: Landcover
-landuse96_28m      South-West Wake county: NC Land Use 1996 clipped
-lsat7_2002_10      LANDSAT-TM7 Band 1 Visible (0.45-0.52um) 30m
-lsat7_2002_20      LANDSAT-TM7 Band 2 Visible (0.52-0.60um) 30m
-lsat7_2002_30      LANDSAT-TM7 Band 3 Visible (0.63-0.69um) 30m
-lsat7_2002_40      LANDSAT-TM7 Band 4 Near Infrared (NIR) (0.76-0.90um) 30m
-lsat7_2002_50      LANDSAT-TM7 Band 5 Near Infrared (NIR) (1.55-1.75um) 30m
-lsat7_2002_61      LANDSAT-TM7 Band 6 Thermal (10.40-12.50um) 60m Low Gain
-lsat7_2002_62      LANDSAT-TM7 Band 6 Thermal (10.40-12.50um) 60m High Gain
-lsat7_2002_70      LANDSAT-TM7 Band 7 Mid Infrared (MIR) (2.08-2.35um) 30m
-lsat7_2002_80      LANDSAT-TM7 Band 8 Panchromatic (PAN) (0.52-0.90um (15m)
-ncmask_500m        North Carolina boundary MASK
-ortho_2001_t792_1m Rural area (792 tile) NC Flood Orthophoto 2001
-roadsmajor         South-West Wake county: roadsmajor
-slope              South-West Wake county: slope in degrees
-soilsID            South-West Wake county: Soils: ID
-soils_Kfactor      Rural area: Soils: K-factor
-streams_derived    South-West Wake county: Streams derived from 10m DEM
-towns              South West Wake: Cities and towns derived from zipcodes
-urban              South West Wake: Urban areas derived from vector map
-zipcodes           South West Wake: Zipcode areas derived from vector map
-zipcodes_dbl       South West Wake: Zipcode areas from vector map, fp
-
-"""
-
-LIST_RASTERS_TITLES_MAPSET = """----------------------------------------------
-raster files available in mapset <landsat>:
-lsat5_1987_10      LANDSAT-TM5 Band 1 Visible (0.45-0.52um) 30m
-lsat5_1987_20      LANDSAT-TM5 Band 2 Visible (0.52-0.60um) 30m
-lsat5_1987_30      LANDSAT-TM5 Band 3 Visible (0.63-0.69um) 30m
-lsat5_1987_40      LANDSAT-TM5 Band 4 Near Infrared (NIR) (0.76-0.90um) 30m
-lsat5_1987_50      LANDSAT-TM5 Band 5 Near Infrared (NIR) (1.55-1.75um) 30m
-lsat5_1987_60      LANDSAT-TM5 Band 6 Thermal (10.40-12.50um) 120m
-lsat5_1987_70      LANDSAT-TM5 Band 7 Mid Infrared (MIR) (2.08-2.35um) 30m
-lsat7_2000_10      LANDSAT-TM7 Band 1 Visible (0.45-0.52um) 30m
-lsat7_2000_20      LANDSAT-TM7 Band 2 Visible (0.52-0.60um) 30m
-lsat7_2000_30      LANDSAT-TM7 Band 3 Visible (0.63-0.69um) 30m
-lsat7_2000_40      LANDSAT-TM7 Band 4 Near Infrared (NIR) (0.76-0.90um) 30m
-lsat7_2000_50      LANDSAT-TM7 Band 5 Near Infrared (NIR) (1.55-1.75um) 30m
-lsat7_2000_61      LANDSAT-TM7 Band 6 Thermal (10.40-12.50um) 60m Low Gain
-lsat7_2000_70      LANDSAT-TM7 Band 7 Mid Infrared (MIR) (2.08-2.35um) 30m
-lsat7_2000_80      LANDSAT-TM7 Band 8 Panchromatic (PAN) (0.52-0.90um (15m)
-
-"""
-
-
-class GListTest(grass.gunittest.TestCase):
-
-    def test_list_rasters(self):
-        """Test human readable list of rasters.
-
-        Supposing we are in user1 of NC and have access
-           to landsat (besides PERMANENT).
-        """
-        stdout = read_command('g.list', type='rast')
-        self.assertMultiLineEqual(stdout, LIST_RASTERS)
-
-    def test_list_vectors(self):
-        """Test human readable list of vectors.
-
-        Supposing we are in user1 of NC and have access
-           to landsat (besides PERMANENT).
-        """
-        stdout = read_command('g.list', type='vect')
-        self.assertMultiLineEqual(stdout, LIST_VECTORS)
-
-    def test_list_groups_in_mapset(self):
-        """Test human readable list of imagery groups in a specific mapset.
-
-        Supposing we are in user1 of NC and have access
-        to landsat (besides PERMANENT).
-        """
-        stdout = read_command('g.list', type='group', mapset='landsat')
-        self.assertMultiLineEqual(stdout, LIST_GROUPS)
-
-    def test_list_rasters_in_mapset(self):
-        """Test human readable list of rasters in a specific mapset.
-
-        Supposing we are in user1 of NC and have access
-        to landsat (besides PERMANENT).
-        """
-        stdout = read_command('g.list', type='rast', mapset='landsat')
-        self.assertMultiLineEqual(stdout, LIST_RASTERS_MAPSET)
-
-    def test_list_rasters_titles(self):
-        """Test human readable list of rasters with titles.
-        """
-        stdout = read_command('g.list', flags='f', type='rast')
-        self.assertMultiLineEqual(stdout, LIST_RASTERS_TITLES)
-
-    def test_list_rasters_titles_in_mapset(self):
-        """Test human readable list of rasters with titles
-        in a specific mapset.
-        """
-        stdout = read_command('g.list', flags='f', type='rast',
-                              mapset='landsat')
-        self.assertMultiLineEqual(stdout, LIST_RASTERS_TITLES_MAPSET)
-
-
-if __name__ == '__main__':
-    grass.gunittest.test()

+ 0 - 12
general/g.remove/Makefile

@@ -1,12 +0,0 @@
-
-MODULE_TOPDIR = ../..
-
-PGM = g.remove
-
-include $(MODULE_TOPDIR)/include/Make/Module.make
-
-LIBES = $(MANAGELIB) $(RASTERLIB) $(GISLIB)
-DEPENDENCIES = $(MANAGEDEP) $(RASTERDEP) $(GISDEP)
-
-default: cmd
-

+ 0 - 58
general/g.remove/g.remove.html

@@ -1,58 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>g.remove</em> allows the user to remove specified data
-base element files from the current mapset.  
-
-<h2>EXAMPLE</h2>
-
-For example, the below command will cause the raster maps
-named <em>soils</em>, <em>slope</em>, and <em>temp</em>,
-the vector maps named <em>roads</em> and <em>rail</em>,
-and the
-
-
-<a href="i.group.html">imagery</a> group files
-
-named <em>nhap.1</em> and <em>nhap.2</em>, and these files'
-associated support files (e.g., cell header files, category
-files, etc.), to be removed from the user's current
-mapset.
-
-<div class="code"><pre>
-g.remove rast=soils,slope,temp vect=roads,rail group=nhap.1,nhap.2
-</pre></div>
-
-<h2>NOTE</h2>
-
-If a particular data base element file has support files
-associated with it (e.g., as is commonly the case with
-raster maps), <em>g.remove</em> will remove these support
-files along with the data base element file specified.
-
-<p>
-The user can only use <em>g.remove</em> to remove data
-files existing under the user's <em>current mapset</em>.
-
-<p> 
-To remove multiple files, the script <em>g.mremove</em> may be used.
-
-<h2>FILES</h2>
-
-<kbd>$GISBASE/etc/element_list</kbd> lists the element 
-types whose files can be removed by the user.
-
-<h2>SEE ALSO</h2>
-
-<em><a href="g.copy.html">g.copy</a></em><br>
-<em><a href="g.list.html">g.list</a></em><br>
-
-<em><a href="g.rename.html">g.rename</a></em><br>
-<em>g.mremove</em> 
-
-<h2>AUTHOR</h2>
-
-Michael Shapiro,
-U.S.Army Construction Engineering 
-Research Laboratory
-
-<p><i>Last changed: $Date$</i>

+ 0 - 136
general/g.remove/main.c

@@ -1,136 +0,0 @@
-\
-/****************************************************************************
- *
- * MODULE:       g.remove
- * AUTHOR(S):    CERL (original contributor)
- *               Radim Blazek <radim.blazek gmail.com>, 
- *               Cedric Shock <cedricgrass shockfamily.net>, 
- *               Huidae Cho <grass4u gmail.com>, 
- *               Glynn Clements <glynn gclements.plus.com>, 
- *               Jachym Cepicky <jachym les-ejk.cz>, 
- *               Markus Neteler <neteler itc.it>, 
- *               Martin Landa <landa.martin gmail.com>
- * PURPOSE:      lets users remove GRASS database files
- * COPYRIGHT:    (C) 1999-2007, 2011 by the GRASS Development Team
- *
- *               This program is free software under the GNU General Public
- *               License (>=v2). Read the file COPYING that comes with GRASS
- *               for details.
- *
- *****************************************************************************/
-#include <stdlib.h>
-#include <string.h>
-
-#include <grass/raster.h>
-#include <grass/glocale.h>
-#include <grass/manage.h>
-
-static int check_reclass(const char *name, const char *mapset, int force)
-{
-    char rname[GNAME_MAX], rmapset[GMAPSET_MAX];
-    char **rmaps;
-    int nrmaps;
-
-    if (Rast_is_reclassed_to(name, mapset, &nrmaps, &rmaps) > 0) {
-	for (; *rmaps; rmaps++) {
-	    /* force remove */
-	    if (force)
-		G_warning(_("Raster map <%s@%s> is a base map for <%s>. Remove forced."),
-			  name, mapset, *rmaps);
-	    else
-		G_warning(_("Raster map <%s@%s> is a base map. Remove reclassed map <%s> first."),
-			  name, mapset, *rmaps);
-	}
-
-	if (!force)
-	    return 1;
-    }
-
-    if (Rast_is_reclass(name, mapset, rname, rmapset) > 0 &&
-	Rast_is_reclassed_to(rname, rmapset, &nrmaps, &rmaps) > 0) {
-	char path[GPATH_MAX];
-	char *p = strchr(rname, '@');
-	char *qname = G_fully_qualified_name(name, mapset);
-
-	if (p)
-	    *p = '\0';
-
-	G_file_name_misc(path, "cell_misc", "reclassed_to", rname, rmapset);
-
-	if (nrmaps == 1 && !G_strcasecmp(rmaps[0], qname)) {
-
-	    if (remove(path) < 0)
-		G_warning(_("Removing information about reclassed map from <%s@%s> failed"),
-			  rname, rmapset);
-	}
-	else {
-	    FILE *fp = fopen(path, "w");
-
-	    if (fp) {
-		for (; *rmaps; rmaps++)
-		    if (G_strcasecmp(*rmaps, qname))
-			fprintf(fp, "%s\n", *rmaps);
-		fclose(fp);
-	    }
-	    else
-		G_warning(_("Removing information about reclassed map from <%s@%s> failed"),
-			  rname, rmapset);
-
-	}
-    }
-
-    return 0;
-}
-
-int main(int argc, char *argv[])
-{
-    int i, n, nlist;
-    struct GModule *module;
-    struct Option **parm;
-    struct Flag *force_flag;
-    const char *name, *mapset;
-    int result;
-
-    G_gisinit(argv[0]);
-
-    result = EXIT_SUCCESS;
-    
-    M_read_list(FALSE, &nlist);
-
-    module = G_define_module();
-    G_add_keyword(_("general"));
-    G_add_keyword(_("map management"));
-    G_add_keyword(_("remove"));
-    module->description =
-	_("Removes data base element files from "
-	  "the user's current mapset.");
-
-    force_flag = G_define_flag();
-    force_flag->key = 'f';
-    force_flag->description = _("Force removal for base raster maps");
-
-    parm = (struct Option **)G_calloc(nlist, sizeof(struct Option *));
-
-    for (n = 0; n < nlist; n++) {
-	parm[n] = M_define_option(n, _("removed"), YES);
-    }
-
-    if (G_parser(argc, argv))
-	exit(EXIT_FAILURE);
-
-    mapset = G_mapset();
-
-    for (n = 0; n < nlist; n++) {
-	if (parm[n]->answers)
-	    for (i = 0; (name = parm[n]->answers[i]); i++) {
-		if (G_strcasecmp(M_get_list(n)->alias, "rast") == 0 &&
-		    check_reclass(name, mapset, force_flag->answer))
-		    continue;
-
-		if (M_do_remove(n, name) == 1) {
-		    result = EXIT_FAILURE;
-		}
-	    }
-    }
-    exit(result);
-}