Simplify normalize_sep.
This commit is contained in:
parent
af1538a139
commit
5e397b1928
1 changed files with 6 additions and 5 deletions
|
@ -35,7 +35,7 @@ class Path:
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
self.absolute_path = path
|
self.absolute_path = path
|
||||||
|
|
||||||
self.absolute_path = self.absolute_path.replace('/', self.sep).replace('\\', self.sep)
|
self.absolute_path = normalize_sep(self.absolute_path, self.sep)
|
||||||
|
|
||||||
def __contains__(self, other):
|
def __contains__(self, other):
|
||||||
other = Path(other, force_sep=self.force_sep)
|
other = Path(other, force_sep=self.force_sep)
|
||||||
|
@ -307,10 +307,11 @@ def glob_patternize(piece):
|
||||||
break
|
break
|
||||||
return piece
|
return piece
|
||||||
|
|
||||||
def normalize_sep(path):
|
def normalize_sep(path, sep=None):
|
||||||
for char in ('\\', '/'):
|
sep = sep or os.sep
|
||||||
if char != os.sep:
|
path = path.replace('/', sep)
|
||||||
path = path.replace(char, os.sep)
|
path = path.replace('\\', sep)
|
||||||
|
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def system_root():
|
def system_root():
|
||||||
|
|
Loading…
Reference in a new issue