[GRASS-SVN] r58083 - grass/trunk/lib/python/pygrass/modules/grid
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Oct 21 03:42:47 PDT 2013
Author: zarch
Date: 2013-10-21 03:42:46 -0700 (Mon, 21 Oct 2013)
New Revision: 58083
Modified:
grass/trunk/lib/python/pygrass/modules/grid/grid.py
Log:
Avoid to copy rasters when not necessary
Modified: grass/trunk/lib/python/pygrass/modules/grid/grid.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/grid/grid.py 2013-10-21 00:15:03 UTC (rev 58082)
+++ grass/trunk/lib/python/pygrass/modules/grid/grid.py 2013-10-21 10:42:46 UTC (rev 58083)
@@ -171,11 +171,13 @@
copy_special_mapset_files(path_src, path_dst)
src = Mapset(msrc, lsrc, gsrc)
dst = Mapset(mdst, ldst, gdst)
- dst.visible.extend(src.visible)
+ visible = [m for m in src.visible]
+ visible.append(src.name)
+ dst.visible.extend(visible)
return src, dst
-def copy_groups(groups, gisrc_src, gisrc_dst, region=None):
+def copy_groups(groups, gisrc_src, gisrc_dst, region=None, cp_rasts=False):
"""Copy group from one mapset to another, crop the raster to the region.
Parameters
@@ -211,7 +213,8 @@
env['GISRC'] = gisrc_src
get_grp(group=grp, env_=env)
rasts = get_grp.outputs.stdout.split()
- copy_rasters(rasts, gisrc_src, gisrc_dst, region=region)
+ if cp_rasts:
+ copy_rasters(rasts, gisrc_src, gisrc_dst, region=region)
# change gisdbase to dst
env['GISRC'] = gisrc_dst
set_grp(group=grp,
@@ -411,7 +414,7 @@
None.
"""
bbox, mapnames, gisrc_src, gisrc_dst, cmd, groups = args
- get_mapset(gisrc_src, gisrc_dst)
+ src, dst = get_mapset(gisrc_src, gisrc_dst)
env = os.environ.copy()
env['GISRC'] = gisrc_dst
if mapnames:
@@ -428,7 +431,8 @@
lcmd.extend(["%s=%s" % (k, v) for k, v in bbox.iteritems()])
sub.Popen(lcmd, env=env).wait()
if groups:
- copy_groups(groups, gisrc_src, gisrc_dst)
+ cp_rasts = src.gisdbase != dst.gisdbase or src.location != dst.location
+ copy_groups(groups, gisrc_src, gisrc_dst, cp_rasts=cp_rasts)
# run the grass command
sub.Popen(get_cmd(cmd), env=env).wait()
# remove temp GISRC
More information about the grass-commit
mailing list