mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Faster implementation of normcase (using string.lower(
string.replace(...)) instead of a for loop). Don't call normcase() in normpath() -- the filesystem just might be case preserving...
This commit is contained in:
parent
505d80b39d
commit
0d530cedd7
1 changed files with 2 additions and 8 deletions
|
@ -15,13 +15,7 @@ import string
|
||||||
# possibly be added as a new function.
|
# possibly be added as a new function.
|
||||||
|
|
||||||
def normcase(s):
|
def normcase(s):
|
||||||
res, s = splitdrive(s)
|
return string.lower(string.replace(s, "/", "\\"))
|
||||||
for c in s:
|
|
||||||
if c in '/\\':
|
|
||||||
res = res + os.sep
|
|
||||||
else:
|
|
||||||
res = res + c
|
|
||||||
return string.lower(res)
|
|
||||||
|
|
||||||
|
|
||||||
# Return wheter a path is absolute.
|
# Return wheter a path is absolute.
|
||||||
|
@ -316,7 +310,7 @@ def expandvars(path):
|
||||||
# Also, components of the path are silently truncated to 8+3 notation.
|
# Also, components of the path are silently truncated to 8+3 notation.
|
||||||
|
|
||||||
def normpath(path):
|
def normpath(path):
|
||||||
path = normcase(path)
|
path = string.replace(path, "/", "\\")
|
||||||
prefix, path = splitdrive(path)
|
prefix, path = splitdrive(path)
|
||||||
while path[:1] == os.sep:
|
while path[:1] == os.sep:
|
||||||
prefix = prefix + os.sep
|
prefix = prefix + os.sep
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue