From 0fe81d258de824010bf092375d1ce5136e0f27d9 Mon Sep 17 00:00:00 2001
From: "Mads M. Pedersen" <mmpe@dtu.dk>
Date: Thu, 12 Jan 2017 16:08:55 +0100
Subject: [PATCH] revert to old unix path method

---
 wetb/hawc2/htc_file.py                       |  4 ++--
 wetb/utils/cluster_tools/cluster_resource.py | 25 ++++++++++----------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/wetb/hawc2/htc_file.py b/wetb/hawc2/htc_file.py
index fc51e07..b5ad46c 100644
--- a/wetb/hawc2/htc_file.py
+++ b/wetb/hawc2/htc_file.py
@@ -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:]
diff --git a/wetb/utils/cluster_tools/cluster_resource.py b/wetb/utils/cluster_tools/cluster_resource.py
index aea4f8d..78ed0f1 100644
--- a/wetb/utils/cluster_tools/cluster_resource.py
+++ b/wetb/utils/cluster_tools/cluster_resource.py
@@ -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("\\", "/")
 
 
 
-- 
GitLab