[GRASS-SVN] r73178 - in grass/trunk/gui/wxpython: . startup

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 24 18:38:01 PDT 2018


Author: wenzeslaus
Date: 2018-08-24 18:38:01 -0700 (Fri, 24 Aug 2018)
New Revision: 73178

Modified:
   grass/trunk/gui/wxpython/gis_set.py
   grass/trunk/gui/wxpython/startup/utils.py
Log:
wxGUI/startup: mapset and location remames as functions

Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py	2018-08-25 01:35:26 UTC (rev 73177)
+++ grass/trunk/gui/wxpython/gis_set.py	2018-08-25 01:38:01 UTC (rev 73178)
@@ -653,8 +653,8 @@
                     newmapset, style=wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
             else:
                 try:
-                    os.rename(os.path.join(self.gisdbase, location, mapset),
-                              os.path.join(self.gisdbase, location, newmapset))
+                    sutils.rename_mapset(self.gisdbase, location,
+                                         mapset, newmapset)
                     self.OnSelectLocation(None)
                     self.lbmapsets.SetSelection(
                         self.listOfMapsets.index(newmapset))
@@ -696,8 +696,8 @@
                     newlocation, style=wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
             else:
                 try:
-                    os.rename(os.path.join(self.gisdbase, location),
-                              os.path.join(self.gisdbase, newlocation))
+                    sutils.rename_location(self.gisdbase,
+                                           location, newlocation)
                     self.UpdateLocations(self.gisdbase)
                     self.lblocations.SetSelection(
                         self.listOfLocations.index(newlocation))

Modified: grass/trunk/gui/wxpython/startup/utils.py
===================================================================
--- grass/trunk/gui/wxpython/startup/utils.py	2018-08-25 01:35:26 UTC (rev 73177)
+++ grass/trunk/gui/wxpython/startup/utils.py	2018-08-25 01:38:01 UTC (rev 73178)
@@ -96,3 +96,17 @@
 def delete_location(database, location):
     """Deletes a specified location"""
     shutil.rmtree(os.path.join(database, location))
+
+
+
+def rename_mapset(database, location, old_name, new_name):
+    """Rename mapset from *old_name* to *new_name*"""
+    location_path = os.path.join(database, location)
+    os.rename(os.path.join(location_path, old_name),
+              os.path.join(location_path, new_name))
+
+
+def rename_location(database, old_name, new_name):
+    """Rename location from *old_name* to *new_name*"""
+    os.rename(os.path.join(database, old_name),
+              os.path.join(database, new_name))



More information about the grass-commit mailing list