diff options
| author | Guido van Rossum <guido@python.org> | 1997-08-12 14:46:58 (GMT) | 
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 1997-08-12 14:46:58 (GMT) | 
| commit | e2ad88c2027a39fda3620918d2ca41baee2a4fa5 (patch) | |
| tree | 3ac5b0b2341346c3da9711f61b75a239d1856355 /Lib/ntpath.py | |
| parent | efa683726f00f3ec0fff779f16d9ad22e4de442e (diff) | |
| download | cpython-e2ad88c2027a39fda3620918d2ca41baee2a4fa5.zip cpython-e2ad88c2027a39fda3620918d2ca41baee2a4fa5.tar.gz cpython-e2ad88c2027a39fda3620918d2ca41baee2a4fa5.tar.bz2  | |
Rewrite normcase() using string.translate...
Diffstat (limited to 'Lib/ntpath.py')
| -rw-r--r-- | Lib/ntpath.py | 20 | 
1 files changed, 6 insertions, 14 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py index ea855d5..224e65e 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -5,23 +5,15 @@ import stat  import string -# Normalize the case of a pathname. -# On MS-DOS it maps the pathname to lowercase, turns slashes into -# backslashes. -# Other normalizations (such as optimizing '../' away) are not allowed +# Normalize the case of a pathname and map slashes to backslashes. +# Other normalizations (such as optimizing '../' away) are not done  # (this is done by normpath). -# 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. + +_normtable = string.maketrans(string.uppercase + "\\/", +			      string.lowercase + os.sep * 2)  def normcase(s): -	res, s = splitdrive(s) -	for c in s: -		if c in '/\\': -			res = res + os.sep -		else: -			res = res + c -	return string.lower(res) +    return string.translate(s, _normtable)  # Return wheter a path is absolute.  | 
