[GRASS-SVN] r73173 - in grass/trunk/gui/wxpython: . startup
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 24 17:52:13 PDT 2018
Author: wenzeslaus
Date: 2018-08-24 17:52:12 -0700 (Fri, 24 Aug 2018)
New Revision: 73173
Modified:
grass/trunk/gui/wxpython/gis_set.py
grass/trunk/gui/wxpython/startup/utils.py
Log:
wxGUI/startup: move mapset creation core to an utils function
Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py 2018-08-24 16:04:44 UTC (rev 73172)
+++ grass/trunk/gui/wxpython/gis_set.py 2018-08-25 00:52:12 UTC (rev 73173)
@@ -38,7 +38,7 @@
from core.gcmd import GMessage, GError, DecodeString, RunCommand
from core.utils import GetListOfLocations, GetListOfMapsets
from startup.utils import (
- get_lockfile_if_present, get_possible_database_path)
+ get_lockfile_if_present, get_possible_database_path, create_mapset)
from startup.guiutils import SetSessionMapset, NewMapsetDialog
from location_wizard.dialogs import RegionDef
from gui_core.dialogs import TextEntryDialog
@@ -1014,20 +1014,7 @@
try:
self.gisdbase = self.tgisdbase.GetValue()
location = self.listOfLocations[self.lblocations.GetSelection()]
- os.mkdir(os.path.join(self.gisdbase, location, mapset))
- # copy WIND file and its permissions from PERMANENT and set
- # permissions to u+rw,go+r
- shutil.copy(
- os.path.join(
- self.gisdbase,
- location,
- 'PERMANENT',
- 'WIND'),
- os.path.join(
- self.gisdbase,
- location,
- mapset))
- # os.chmod(os.path.join(database,location,mapset,'WIND'), 0644)
+ create_mapset(self.gisdbase, location, mapset)
self.OnSelectLocation(None)
self.lbmapsets.SetSelection(self.listOfMapsets.index(mapset))
self.bstart.SetFocus()
Modified: grass/trunk/gui/wxpython/startup/utils.py
===================================================================
--- grass/trunk/gui/wxpython/startup/utils.py 2018-08-24 16:04:44 UTC (rev 73172)
+++ grass/trunk/gui/wxpython/startup/utils.py 2018-08-25 00:52:12 UTC (rev 73173)
@@ -17,6 +17,7 @@
import os
+import shutil
def get_possible_database_path():
@@ -67,3 +68,17 @@
else:
return None
+
+def create_mapset(database, location, mapset):
+ """Creates a mapset in a specified location"""
+ location_path = os.path.join(database, location)
+ mapset_path = os.path.join(location_path, mapset)
+ # create an empty directory
+ os.mkdir(mapset_path)
+ # copy WIND file and its permissions from PERMANENT
+ # this uses PERMANENT's current region instead of default (?)
+ region_file = 'WIND'
+ region_path = os.path.join(location_path, 'PERMANENT', region_file)
+ shutil.copy(region_path, mapset_path)
+ # set permissions to u+rw,go+r (disabled)
+ # os.chmod(os.path.join(database,location,mapset,'WIND'), 0644)
More information about the grass-commit
mailing list