Skip to content

Commit

Permalink
Add support for case-sensitive paths in Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
17451k committed Sep 25, 2019
1 parent 8bebec5 commit 5f299be
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions clade/extensions/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


class Path(Extension):
__version__ = "1"
__version__ = "2"

def __init__(self, work_dir, conf=None):
super().__init__(work_dir, conf)
Expand All @@ -43,25 +43,38 @@ def get_rel_paths(self, paths, cwd):

return npaths

def get_rel_path(self, path, cwd):
key = cwd.lower() + " " + path.lower()
npath = self.paths.get(key)
def get_rel_path(self, path, cwd, load_paths=False):
if load_paths:
self.paths = self.load_paths()

key = cwd + " " + path
# get data either by key, or by key.lower()
npath = self.paths.get(key, self.paths.get(key.lower()))

if npath:
return npath
else:
elif load_paths:
self.error("Can't find path {!r} in Paths".format(key))
raise RuntimeError

# self.paths may not contain all necessary data
return self.get_rel_path(path, cwd, load_paths=True)

def get_abs_path(self, path, load_paths=False):
if load_paths:
self.paths = self.load_paths()
return self.paths[key]

def get_abs_path(self, path):
key = path.lower()
npath = self.paths.get(key)
key = path
npath = self.paths.get(key, self.paths.get(key.lower()))

if npath:
return npath
else:
self.paths = self.load_paths()
return self.paths[key]
elif load_paths:
self.error("Can't find path {!r} in Paths".format(key))
raise RuntimeError

# self.paths may not contain all necessary data
return self.get_abs_path(path, load_paths=True)

def dump_paths(self):
self.dump_data(self.paths, self.paths_file)
Expand All @@ -81,7 +94,10 @@ def normalize_rel_paths(self, paths, cwd):
def normalize_rel_path(self, path, cwd):
cwd = cwd.strip()
path = path.strip()
key = cwd.lower() + " " + path.lower()

key = cwd + " " + path
if sys.platform == "win32":
key = key.lower()

if not self.paths:
self.paths = self.load_paths()
Expand All @@ -100,7 +116,10 @@ def normalize_rel_path(self, path, cwd):

def normalize_abs_path(self, path):
path = path.strip()
key = path.lower()

key = path
if sys.platform == "win32":
key = key.lower()

if not self.paths:
self.paths = self.load_paths()
Expand Down

0 comments on commit 5f299be

Please sign in to comment.