"tests/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "8701e8644bbfd45f986e1d73e5f68e117be405be"
Commit 02ceae83 authored by Kai Chen's avatar Kai Chen
Browse files

add symlink method

parent 2f49db9d
...@@ -5,4 +5,4 @@ from .opencv_info import * ...@@ -5,4 +5,4 @@ from .opencv_info import *
from .image import * from .image import *
from .video import * from .video import *
from .visualization import * from .visualization import *
from .version import * from .version import __version__
...@@ -33,6 +33,9 @@ def check_file_exist(filename, msg_tmpl='file "{}" does not exist'): ...@@ -33,6 +33,9 @@ def check_file_exist(filename, msg_tmpl='file "{}" does not exist'):
def mkdir_or_exist(dir_name, mode=0o777): def mkdir_or_exist(dir_name, mode=0o777):
if dir_name == '':
return
dir_name = osp.expanduser(dir_name)
if six.PY3: if six.PY3:
os.makedirs(dir_name, mode=mode, exist_ok=True) os.makedirs(dir_name, mode=mode, exist_ok=True)
else: else:
...@@ -40,6 +43,12 @@ def mkdir_or_exist(dir_name, mode=0o777): ...@@ -40,6 +43,12 @@ def mkdir_or_exist(dir_name, mode=0o777):
os.makedirs(dir_name, mode=0o777) os.makedirs(dir_name, mode=0o777)
def symlink(src, dst, overwrite=True, **kwargs):
if os.path.lexists(dst) and overwrite:
os.remove(dst)
os.symlink(src, dst, **kwargs)
def _scandir_py35(dir_path, suffix=None): def _scandir_py35(dir_path, suffix=None):
for entry in os.scandir(dir_path): for entry in os.scandir(dir_path):
if not entry.is_file(): if not entry.is_file():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment