Add resolve_symlinks arg to normalize_path()

This commit is contained in:
Thomas Kluyver 2015-03-18 15:38:12 -07:00
parent 09f2b343e9
commit 7e9a42dcda
2 changed files with 6 additions and 3 deletions

View File

@ -47,7 +47,7 @@ class UninstallPathSet(object):
return True
def add(self, path):
path = os.path.normcase(os.path.expanduser(path))
path = normalize_path(path, resolve_symlinks=False)
if not os.path.exists(path):
return
if self._permitted(path):

View File

@ -260,12 +260,15 @@ def make_path_relative(path, rel_to):
return os.path.sep.join(full_parts)
def normalize_path(path):
def normalize_path(path, resolve_symlinks=True):
"""
Convert a path to its canonical, case-normalized, absolute version.
"""
return os.path.normcase(os.path.realpath(os.path.expanduser(path)))
path = os.path.expanduser(path)
if resolve_symlinks:
path = os.path.realpath(path)
return os.path.normcase(path)
def splitext(path):