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)
|
rpath = u'/'.join(new_rest)
|
||||||
|
|
||||||
if os.path.isabs(rpath):
|
if not os.path.isabs(rpath):
|
||||||
return rpath
|
rpath = base + u'/' + rpath
|
||||||
else:
|
|
||||||
return base + u'/' + rpath
|
if is_windows():
|
||||||
|
rpath = rpath.replace(u'/', u'\\')
|
||||||
|
return rpath
|
||||||
|
|
||||||
def get_data_path(dir_path):
|
def get_data_path(dir_path):
|
||||||
parts = dir_path.split('/')
|
parts = dir_path.split('/')
|
||||||
|
|
@ -59,34 +61,33 @@ def get_data_file_path(file_path):
|
||||||
def rmtree(path, **kwargs):
|
def rmtree(path, **kwargs):
|
||||||
if is_windows():
|
if is_windows():
|
||||||
if os.path.isabs(path):
|
if os.path.isabs(path):
|
||||||
path = u'//?/'+path
|
path = u'\\\\?\\'+path.replace(u'/', u'\\')
|
||||||
shutil.rmtree(path, **kwargs)
|
shutil.rmtree(path, **kwargs)
|
||||||
|
|
||||||
def copy(src, dest, **kwargs):
|
def copy(src, dest, **kwargs):
|
||||||
if is_windows():
|
if is_windows():
|
||||||
if os.path.isabs(src):
|
if os.path.isabs(src):
|
||||||
src = u'//?/'+src
|
src = u'\\\\?\\'+src.replace(u'/', u'\\')
|
||||||
if os.path.isabs(dest):
|
if os.path.isabs(dest):
|
||||||
dest = u'//?/'+dest
|
dest = u'\\\\?\\'+dest.replace(u'/', u'\\')
|
||||||
shutil.copy(src, dest, **kwargs)
|
shutil.copy(src, dest, **kwargs)
|
||||||
|
|
||||||
def move(src, dest, **kwargs):
|
def move(src, dest, **kwargs):
|
||||||
if is_windows():
|
if is_windows():
|
||||||
if os.path.isabs(src):
|
if os.path.isabs(src):
|
||||||
src = u'//?/'+src
|
src = u'\\\\?\\'+src.replace(u'/', u'\\')
|
||||||
if os.path.isabs(dest):
|
if os.path.isabs(dest):
|
||||||
dest = u'//?/'+dest
|
dest = u'\\\\?\\'+dest.replace(u'/', u'\\')
|
||||||
shutil.move(src, dest, **kwargs)
|
shutil.move(src, dest, **kwargs)
|
||||||
|
|
||||||
def copytree(src, dest, **kwargs):
|
def copytree(src, dest, **kwargs):
|
||||||
if is_windows():
|
if is_windows():
|
||||||
if os.path.isabs(src):
|
if os.path.isabs(src):
|
||||||
src = u'//?/'+src
|
src = u'\\\\?\\'+src.replace(u'/', u'\\')
|
||||||
if os.path.isabs(dest):
|
if os.path.isabs(dest):
|
||||||
dest = u'//?/'+dest
|
dest = u'\\\\?\\'+dest.replace(u'/', u'\\')
|
||||||
shutil.copytree(src, dest, **kwargs)
|
shutil.copytree(src, dest, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def log(*args):
|
def log(*args):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print(*args)
|
print(*args)
|
||||||
|
|
@ -109,6 +110,8 @@ def zip_files(zip_file_name, *args, **kwargs):
|
||||||
old_path = os.getcwd()
|
old_path = os.getcwd()
|
||||||
|
|
||||||
for arg in args:
|
for arg in args:
|
||||||
|
if is_windows():
|
||||||
|
arg = u'\\\\?\\'+os.path.abspath(arg).replace(u'/', u'\\')
|
||||||
if os.path.exists(arg):
|
if os.path.exists(arg):
|
||||||
if os.path.isdir(arg):
|
if os.path.isdir(arg):
|
||||||
directory = os.path.abspath(arg)
|
directory = os.path.abspath(arg)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue