Fixed long paths on python 2. Version bump.
This commit is contained in:
parent
e57e46a18a
commit
3b5d07cb36
2 changed files with 16 additions and 13 deletions
|
|
@ -1 +1 @@
|
|||
v0.3.4b
|
||||
v0.4.1b
|
||||
|
|
|
|||
27
utils.py
27
utils.py
|
|
@ -33,10 +33,12 @@ def path_join(base, *rest):
|
|||
|
||||
rpath = u'/'.join(new_rest)
|
||||
|
||||
if os.path.isabs(rpath):
|
||||
return rpath
|
||||
else:
|
||||
return base + u'/' + rpath
|
||||
if not os.path.isabs(rpath):
|
||||
rpath = base + u'/' + rpath
|
||||
|
||||
if is_windows():
|
||||
rpath = rpath.replace(u'/', u'\\')
|
||||
return rpath
|
||||
|
||||
def get_data_path(dir_path):
|
||||
parts = dir_path.split('/')
|
||||
|
|
@ -59,34 +61,33 @@ def get_data_file_path(file_path):
|
|||
def rmtree(path, **kwargs):
|
||||
if is_windows():
|
||||
if os.path.isabs(path):
|
||||
path = u'//?/'+path
|
||||
path = u'\\\\?\\'+path.replace(u'/', u'\\')
|
||||
shutil.rmtree(path, **kwargs)
|
||||
|
||||
def copy(src, dest, **kwargs):
|
||||
if is_windows():
|
||||
if os.path.isabs(src):
|
||||
src = u'//?/'+src
|
||||
src = u'\\\\?\\'+src.replace(u'/', u'\\')
|
||||
if os.path.isabs(dest):
|
||||
dest = u'//?/'+dest
|
||||
dest = u'\\\\?\\'+dest.replace(u'/', u'\\')
|
||||
shutil.copy(src, dest, **kwargs)
|
||||
|
||||
def move(src, dest, **kwargs):
|
||||
if is_windows():
|
||||
if os.path.isabs(src):
|
||||
src = u'//?/'+src
|
||||
src = u'\\\\?\\'+src.replace(u'/', u'\\')
|
||||
if os.path.isabs(dest):
|
||||
dest = u'//?/'+dest
|
||||
dest = u'\\\\?\\'+dest.replace(u'/', u'\\')
|
||||
shutil.move(src, dest, **kwargs)
|
||||
|
||||
def copytree(src, dest, **kwargs):
|
||||
if is_windows():
|
||||
if os.path.isabs(src):
|
||||
src = u'//?/'+src
|
||||
src = u'\\\\?\\'+src.replace(u'/', u'\\')
|
||||
if os.path.isabs(dest):
|
||||
dest = u'//?/'+dest
|
||||
dest = u'\\\\?\\'+dest.replace(u'/', u'\\')
|
||||
shutil.copytree(src, dest, **kwargs)
|
||||
|
||||
|
||||
def log(*args):
|
||||
if DEBUG:
|
||||
print(*args)
|
||||
|
|
@ -109,6 +110,8 @@ def zip_files(zip_file_name, *args, **kwargs):
|
|||
old_path = os.getcwd()
|
||||
|
||||
for arg in args:
|
||||
if is_windows():
|
||||
arg = u'\\\\?\\'+os.path.abspath(arg).replace(u'/', u'\\')
|
||||
if os.path.exists(arg):
|
||||
if os.path.isdir(arg):
|
||||
directory = os.path.abspath(arg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue