summaryrefslogtreecommitdiffstats
path: root/Lib/dospath.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-08-10 19:27:42 (GMT)
committerGuido van Rossum <guido@python.org>1995-08-10 19:27:42 (GMT)
commitfda5c1a807e412ec23c9940b049f8599197b8d3e (patch)
treec459cd6cb9f839c4713a7369faf92837634ded8e /Lib/dospath.py
parent3b8e1604e8dd4c871e5e8a22d6c738c7f2d39f3a (diff)
downloadcpython-fda5c1a807e412ec23c9940b049f8599197b8d3e.zip
cpython-fda5c1a807e412ec23c9940b049f8599197b8d3e.tar.gz
cpython-fda5c1a807e412ec23c9940b049f8599197b8d3e.tar.bz2
redefined normcase()
Diffstat (limited to 'Lib/dospath.py')
-rw-r--r--Lib/dospath.py19
1 files changed, 5 insertions, 14 deletions
diff --git a/Lib/dospath.py b/Lib/dospath.py
index 770174f..725b381 100644
--- a/Lib/dospath.py
+++ b/Lib/dospath.py
@@ -7,28 +7,18 @@ import string
# Normalize the case of a pathname.
# On MS-DOS it maps the pathname to lowercase, turns slashes into
-# backslashes and maps invalid consecutive characters to a single '_'.
+# backslashes.
# Other normalizations (such as optimizing '../' away) are not allowed
# (this is done by normpath).
-#
-# Amrit: Things that can be valid regular expressions cannot be normalized
-# away. (which is pretty much all special characters)
-#
-# I am assuming that at least these chars may be used:
-# [, ], |, *, +, ?
-
-mapchar = '_'
+# Previously, this version mapped invalid consecutive characters to a
+# single '_', but this has been removed. This functionality should
+# possibly be added as a new function.
def normcase(s):
res, s = splitdrive(s)
for c in s:
if c in '/\\':
res = res + os.sep
- elif c == '.' and res[-1:] == os.sep:
- res = res + mapchar + c
- elif ord(c) < 32 or c in ' ",:;<=>':
- if res[-1:] != mapchar:
- res = res + mapchar
else:
res = res + c
return string.lower(res)
@@ -59,6 +49,7 @@ def join(a, b):
# Split a path in a drive specification (a drive letter followed by a
# colon) and the path specification.
# It is always true that drivespec + pathspec == p
+
def splitdrive(p):
if p[1:2] == ':':
return p[0:2], p[2:]