Skip to content

Commit fda5c1a

Browse files
committed
redefined normcase()
1 parent 3b8e160 commit fda5c1a

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

Lib/dospath.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,18 @@
77

88
# Normalize the case of a pathname.
99
# On MS-DOS it maps the pathname to lowercase, turns slashes into
10-
# backslashes and maps invalid consecutive characters to a single '_'.
10+
# backslashes.
1111
# Other normalizations (such as optimizing '../' away) are not allowed
1212
# (this is done by normpath).
13-
#
14-
# Amrit: Things that can be valid regular expressions cannot be normalized
15-
# away. (which is pretty much all special characters)
16-
#
17-
# I am assuming that at least these chars may be used:
18-
# [, ], |, *, +, ?
19-
20-
mapchar = '_'
13+
# Previously, this version mapped invalid consecutive characters to a
14+
# single '_', but this has been removed. This functionality should
15+
# possibly be added as a new function.
2116

2217
def normcase(s):
2318
res, s = splitdrive(s)
2419
for c in s:
2520
if c in '/\\':
2621
res = res + os.sep
27-
elif c == '.' and res[-1:] == os.sep:
28-
res = res + mapchar + c
29-
elif ord(c) < 32 or c in ' ",:;<=>':
30-
if res[-1:] != mapchar:
31-
res = res + mapchar
3222
else:
3323
res = res + c
3424
return string.lower(res)
@@ -59,6 +49,7 @@ def join(a, b):
5949
# Split a path in a drive specification (a drive letter followed by a
6050
# colon) and the path specification.
6151
# It is always true that drivespec + pathspec == p
52+
6253
def splitdrive(p):
6354
if p[1:2] == ':':
6455
return p[0:2], p[2:]

0 commit comments

Comments
 (0)