X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_common%2Ffslocal.py;fp=osm_common%2Ffslocal.py;h=bd243f025ee75df2080848df86d6ea757cb22585;hb=d4378aa85f33bffbf3ef303dbd66513562cbe8f2;hp=61600ec96e1b8918c25e5ebc485172a2b06ffd6e;hpb=d63ea273e23c9e1350ed300872f703faf4ddc3c7;p=osm%2Fcommon.git 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 @@ class FsLocal(FsBase): 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 @@ class FsLocal(FsBase): 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