|
@@ -9,26 +9,12 @@ import shutil
|
|
import ctypes as ct
|
|
import ctypes as ct
|
|
import fnmatch
|
|
import fnmatch
|
|
|
|
|
|
-from grass import script
|
|
|
|
-#from grass.script import setup
|
|
|
|
-#
|
|
|
|
-#
|
|
|
|
-#GISBASE = "/home/pietro/docdat/src/gis/grass/grass71/dist.x86_64-unknown-linux-gnu"
|
|
|
|
-#LOCATION = "nc_basic_spm_grass7'"
|
|
|
|
-#GISDBASE = "/home/pietro/docdat/gis"
|
|
|
|
-#MAPSET = "sqlite"
|
|
|
|
-#GUI = "wxpython"
|
|
|
|
-#
|
|
|
|
-#setup.init(GISBASE, GISDBASE, LOCATION, MAPSET)
|
|
|
|
-script.gisenv()
|
|
|
|
|
|
|
|
import grass.lib.gis as libgis
|
|
import grass.lib.gis as libgis
|
|
from grass.pygrass.functions import getenv
|
|
from grass.pygrass.functions import getenv
|
|
from grass.pygrass.errors import GrassError
|
|
from grass.pygrass.errors import GrassError
|
|
|
|
|
|
|
|
|
|
-#write dec to check if user have permissions or not
|
|
|
|
-
|
|
|
|
ETYPE = {'rast': libgis.G_ELEMENT_RASTER,
|
|
ETYPE = {'rast': libgis.G_ELEMENT_RASTER,
|
|
'rast3d': libgis.G_ELEMENT_RASTER3D,
|
|
'rast3d': libgis.G_ELEMENT_RASTER3D,
|
|
'vect': libgis.G_ELEMENT_VECTOR,
|
|
'vect': libgis.G_ELEMENT_VECTOR,
|
|
@@ -56,7 +42,7 @@ def _check(value, path, type):
|
|
return getenv(type)
|
|
return getenv(type)
|
|
else:
|
|
else:
|
|
raise GrassError("%s <%s> not found" % (type.title(),
|
|
raise GrassError("%s <%s> not found" % (type.title(),
|
|
- join(path, value)))
|
|
|
|
|
|
+ join(path, value)))
|
|
|
|
|
|
|
|
|
|
def set_current_mapset(mapset, location=None, gisdbase=None):
|
|
def set_current_mapset(mapset, location=None, gisdbase=None):
|
|
@@ -127,7 +113,7 @@ class Gisdbase(object):
|
|
for loc in self.locations():
|
|
for loc in self.locations():
|
|
yield Location(loc, self.name)
|
|
yield Location(loc, self.name)
|
|
|
|
|
|
- # TODO remove or complete this function
|
|
|
|
|
|
+ # TODO remove or complete this function
|
|
def new_location(self):
|
|
def new_location(self):
|
|
if libgis.G__make_location() != 0:
|
|
if libgis.G__make_location() != 0:
|
|
raise GrassError("Cannot create new location")
|
|
raise GrassError("Cannot create new location")
|
|
@@ -381,7 +367,6 @@ class VisibleMapset(object):
|
|
"""Return the mapsets in the search path"""
|
|
"""Return the mapsets in the search path"""
|
|
with open(self.spath, "a+") as f:
|
|
with open(self.spath, "a+") as f:
|
|
lines = f.readlines()
|
|
lines = f.readlines()
|
|
- #lines.remove('')
|
|
|
|
if lines:
|
|
if lines:
|
|
return [l.strip() for l in lines]
|
|
return [l.strip() for l in lines]
|
|
lns = ['PERMANENT', ]
|
|
lns = ['PERMANENT', ]
|
|
@@ -422,7 +407,7 @@ class VisibleMapset(object):
|
|
|
|
|
|
def extend(self, mapsets):
|
|
def extend(self, mapsets):
|
|
"""Add more mapsets to the search path
|
|
"""Add more mapsets to the search path
|
|
-
|
|
|
|
|
|
+
|
|
:param mapsets: a list of mapset's names
|
|
:param mapsets: a list of mapset's names
|
|
:type mapsets: list
|
|
:type mapsets: list
|
|
"""
|
|
"""
|