[GRASS-SVN] r73174 - in grass/trunk/gui/wxpython: . startup
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 24 18:06:26 PDT 2018
Author: wenzeslaus
Date: 2018-08-24 18:06:26 -0700 (Fri, 24 Aug 2018)
New Revision: 73174
Modified:
grass/trunk/gui/wxpython/gis_set.py
grass/trunk/gui/wxpython/startup/utils.py
Log:
wxGUI/startup: move delete mapset and location to separate functions
Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py 2018-08-25 00:52:12 UTC (rev 73173)
+++ grass/trunk/gui/wxpython/gis_set.py 2018-08-25 01:06:26 UTC (rev 73174)
@@ -22,7 +22,6 @@
import os
import sys
-import shutil
import copy
import platform
import codecs
@@ -39,6 +38,7 @@
from core.utils import GetListOfLocations, GetListOfMapsets
from startup.utils import (
get_lockfile_if_present, get_possible_database_path, create_mapset)
+import startup.utils as sutils
from startup.guiutils import SetSessionMapset, NewMapsetDialog
from location_wizard.dialogs import RegionDef
from gui_core.dialogs import TextEntryDialog
@@ -758,7 +758,7 @@
if dlg.ShowModal() == wx.ID_YES:
try:
- shutil.rmtree(os.path.join(self.gisdbase, location, mapset))
+ sutils.delete_mapset(self.gisdbase, location, mapset)
self.OnSelectLocation(None)
self.lbmapsets.SetSelection(0)
except:
@@ -786,7 +786,7 @@
if dlg.ShowModal() == wx.ID_YES:
try:
- shutil.rmtree(os.path.join(self.gisdbase, location))
+ sutils.delete_location(self.gisdbase, location)
self.UpdateLocations(self.gisdbase)
self.lblocations.SetSelection(0)
self.OnSelectLocation(None)
Modified: grass/trunk/gui/wxpython/startup/utils.py
===================================================================
--- grass/trunk/gui/wxpython/startup/utils.py 2018-08-25 00:52:12 UTC (rev 73173)
+++ grass/trunk/gui/wxpython/startup/utils.py 2018-08-25 01:06:26 UTC (rev 73174)
@@ -82,3 +82,17 @@
shutil.copy(region_path, mapset_path)
# set permissions to u+rw,go+r (disabled)
# os.chmod(os.path.join(database,location,mapset,'WIND'), 0644)
+
+
+def delete_mapset(database, location, mapset):
+ """Deletes a specified mapset"""
+ if mapset == 'PERMANENT':
+ # TODO: translatable or not?
+ raise ValueError("Mapset PERMANENT cannot be deleted"
+ " (whole location can be)")
+ shutil.rmtree(os.path.join(database, location, mapset))
+
+
+def delete_location(database, location):
+ """Deletes a specified location"""
+ shutil.rmtree(os.path.join(database, location))
More information about the grass-commit
mailing list