Преглед изворни кода

pythonlib: define default location/mapset for setup.init()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46764 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa пре 14 година
родитељ
комит
388a3d6003
1 измењених фајлова са 8 додато и 5 уклоњено
  1. 8 5
      lib/python/setup.py.sed

+ 8 - 5
lib/python/setup.py.sed

@@ -13,7 +13,7 @@ grass.init()
 ...
 @endcode
 
-(C) 2010 by the GRASS Development Team
+(C) 2010-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.
@@ -24,16 +24,16 @@ for details.
 import os
 import tempfile as tmpfile
 
-def init(gisbase, dbase, location, mapset):
+def init(gisbase, dbase = '', location = 'demolocation', mapset = 'PERMANENT'):
     """!Initialize system variables to run scripts without starting
     GRASS explicitly.
 
     User is resposible to delete gisrc file.
 
     @param gisbase path to GRASS installation
-    @param dbase   path to GRASS database
-    @param location location name
-    @param mapset   mapset within given location
+    @param dbase   path to GRASS database (default: '')
+    @param location location name (default: 'demolocation')
+    @param mapset   mapset within given location (default: 'PERMANENT')
     @return path to gisrc file
     """
     os.environ['PATH'] += os.pathsep + os.path.join(gisbase, 'bin') + \
@@ -44,6 +44,9 @@ def init(gisbase, dbase, location, mapset):
     
     os.environ['GIS_LOCK'] = str(os.getpid())
     
+    if not dbase:
+        dbase = gisbase
+    
     fd, gisrc = tmpfile.mkstemp()
     os.environ['GISRC'] = gisrc
     os.write(fd, "GISDBASE: %s\n" % dbase)