Forráskód Böngészése

wxGUI/startup: mapset and location remames as functions

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@73178 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 6 éve
szülő
commit
b63e3aee02
2 módosított fájl, 18 hozzáadás és 4 törlés
  1. 4 4
      gui/wxpython/gis_set.py
  2. 14 0
      gui/wxpython/startup/utils.py

+ 4 - 4
gui/wxpython/gis_set.py

@@ -653,8 +653,8 @@ class GRASSStartup(wx.Frame):
                     newmapset, style=wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
                     newmapset, style=wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
             else:
             else:
                 try:
                 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.OnSelectLocation(None)
                     self.lbmapsets.SetSelection(
                     self.lbmapsets.SetSelection(
                         self.listOfMapsets.index(newmapset))
                         self.listOfMapsets.index(newmapset))
@@ -696,8 +696,8 @@ class GRASSStartup(wx.Frame):
                     newlocation, style=wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
                     newlocation, style=wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
             else:
             else:
                 try:
                 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.UpdateLocations(self.gisdbase)
                     self.lblocations.SetSelection(
                     self.lblocations.SetSelection(
                         self.listOfLocations.index(newlocation))
                         self.listOfLocations.index(newlocation))

+ 14 - 0
gui/wxpython/startup/utils.py

@@ -96,3 +96,17 @@ def delete_mapset(database, location, mapset):
 def delete_location(database, location):
 def delete_location(database, location):
     """Deletes a specified location"""
     """Deletes a specified location"""
     shutil.rmtree(os.path.join(database, 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))