Skip to content
Snippets Groups Projects
Commit 0fe81d25 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

revert to old unix path method

parent 4223cc4a
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ from io import open
from builtins import str
from future import standard_library
from wetb.utils.process_exec import pexec
from wetb.utils.cluster_tools.cluster_resource import unix_path
from wetb.utils.cluster_tools.cluster_resource import unix_path, unix_path_old
standard_library.install_aliases()
from collections import OrderedDict
......@@ -104,7 +104,7 @@ class HTCFile(HTCContents, HTCDefaults):
def readfilelines(self, filename):
with open(unix_path(filename), encoding='cp1252') as fid:
with open(unix_path_old(filename), encoding='cp1252') as fid:
lines = list(fid.readlines())
if lines[0].encode().startswith(b'\xc3\xaf\xc2\xbb\xc2\xbf'):
lines[0] = lines[0][3:]
......
......@@ -42,18 +42,19 @@ def unix_path(path, cwd=None, fail_on_missing=False):
path+="/"
return path.replace("\\","/")
# filename = os.path.realpath(filename.replace("\\", "/")).replace("\\", "/")
# ufn, rest = os.path.splitdrive(filename)
# ufn += "/"
# for f in rest[1:].split("/"):
# f_lst = [f_ for f_ in os.listdir(ufn) if f_.lower() == f.lower()]
# if len(f_lst) > 1:
# f_lst = [f_ for f_ in f_lst if f_ == f]
# elif len(f_lst) == 0:
# raise IOError("'%s' not found in '%s'" % (f, ufn))
# else: # one match found
# ufn = os.path.join(ufn, f_lst[0])
# return ufn.replace("\\", "/")
def unix_path_old(filename):
filename = os.path.realpath(filename.replace("\\", "/")).replace("\\", "/")
ufn, rest = os.path.splitdrive(filename)
ufn += "/"
for f in rest[1:].split("/"):
f_lst = [f_ for f_ in os.listdir(ufn) if f_.lower() == f.lower()]
if len(f_lst) > 1:
f_lst = [f_ for f_ in f_lst if f_ == f]
elif len(f_lst) == 0:
raise IOError("'%s' not found in '%s'" % (f, ufn))
else: # one match found
ufn = os.path.join(ufn, f_lst[0])
return ufn.replace("\\", "/")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment