bug 605. New method at fslocal for rename folders
Change-Id: Ic0acd82873a3790f228641ba676d2da9235059f1
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
diff --git a/osm_common/__init__.py b/osm_common/__init__.py
index ecd9261..73fd77e 100644
--- a/osm_common/__init__.py
+++ b/osm_common/__init__.py
@@ -15,6 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-version = '0.1.14'
+version = '0.1.15'
# TODO add package version filling commit id with 0's; e.g.: '5.0.0.post11+00000000.dirty-1'
-date_version = '2018-11-27'
+date_version = '2018-12-05'
diff --git a/osm_common/fsbase.py b/osm_common/fsbase.py
index b941c21..87d974d 100644
--- a/osm_common/fsbase.py
+++ b/osm_common/fsbase.py
@@ -62,6 +62,9 @@
def mkdir(self, folder):
raise FsException("Method 'mkdir' not implemented")
+ def dir_rename(self, src, dst):
+ raise FsException("Method 'dir_rename' not implemented")
+
def file_exists(self, storage):
raise FsException("Method 'file_exists' not implemented")
diff --git a/osm_common/fslocal.py b/osm_common/fslocal.py
index 61600ec..bd243f0 100644
--- a/osm_common/fslocal.py
+++ b/osm_common/fslocal.py
@@ -63,6 +63,22 @@
except Exception as e:
raise FsException(str(e), http_code=HTTPStatus.INTERNAL_SERVER_ERROR)
+ def dir_rename(self, src, dst):
+ """
+ Rename one directory name. If dst exist, it replaces (deletes) existing directory
+ :param src: source directory
+ :param dst: destination directory
+ :return: None or raises and exception
+ """
+ try:
+ if os.path.exists(self.path + dst):
+ rmtree(self.path + dst)
+
+ os.rename(self.path + src, self.path + dst)
+
+ except Exception as e:
+ raise FsException(str(e), http_code=HTTPStatus.INTERNAL_SERVER_ERROR)
+
def file_exists(self, storage, mode=None):
"""
Indicates if "storage" file exist
@@ -143,7 +159,7 @@
def file_delete(self, storage, ignore_non_exist=False):
"""
- Delete storage content recursivelly
+ Delete storage content recursively
:param storage: can be a str or list of str
:param ignore_non_exist: not raise exception if storage does not exist
:return: None