File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import string
66
77
8- # Normalize the case of a pathname.
9- # On MS-DOS it maps the pathname to lowercase, turns slashes into
10- # backslashes.
11- # Other normalizations (such as optimizing '../' away) are not allowed
8+ # Normalize the case of a pathname and map slashes to backslashes.
9+ # Other normalizations (such as optimizing '../' away) are not done
1210# (this is done by normpath).
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.
11+
12+ _normtable = string . maketrans ( string . uppercase + " \\ /" ,
13+ string . lowercase + os . sep * 2 )
1614
1715def normcase (s ):
18- res , s = splitdrive (s )
19- for c in s :
20- if c in '/\\ ' :
21- res = res + os .sep
22- else :
23- res = res + c
24- return string .lower (res )
16+ return string .translate (s , _normtable )
2517
2618
2719# Return wheter a path is absolute.
You can’t perform that action at this time.
0 commit comments