File tree Expand file tree Collapse file tree 1 file changed +5
-14
lines changed Expand file tree Collapse file tree 1 file changed +5
-14
lines changed Original file line number Diff line number Diff line change 7
7
8
8
# Normalize the case of a pathname.
9
9
# On MS-DOS it maps the pathname to lowercase, turns slashes into
10
- # backslashes and maps invalid consecutive characters to a single '_' .
10
+ # backslashes.
11
11
# Other normalizations (such as optimizing '../' away) are not allowed
12
12
# (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.
21
16
22
17
def normcase (s ):
23
18
res , s = splitdrive (s )
24
19
for c in s :
25
20
if c in '/\\ ' :
26
21
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
32
22
else :
33
23
res = res + c
34
24
return string .lower (res )
@@ -59,6 +49,7 @@ def join(a, b):
59
49
# Split a path in a drive specification (a drive letter followed by a
60
50
# colon) and the path specification.
61
51
# It is always true that drivespec + pathspec == p
52
+
62
53
def splitdrive (p ):
63
54
if p [1 :2 ] == ':' :
64
55
return p [0 :2 ], p [2 :]
You can’t perform that action at this time.
0 commit comments