2 # nturl2path convert a NT pathname to a file URL and
6 """ Convert a URL to a DOS path...
15 # No drive specifier, just convert slashes
16 components
= string
.splitfields(url
, '/')
17 return string
.joinfields(components
, '\\')
18 comp
= string
.splitfields(url
, '|')
19 if len(comp
) != 2 or comp
[0][-1] not in string
.letters
:
20 error
= 'Bad URL: ' + url
22 drive
= string
.upper(comp
[0][-1])
23 components
= string
.splitfields(comp
[1], '/')
25 for comp
in components
:
27 path
= path
+ '\\' + comp
32 """ Convert a DOS path name to a file url...
37 ///C|/foo/bar/spam.foo
42 # No drive specifier, just convert slashes
43 components
= string
.splitfields(p
, '\\')
44 return string
.joinfields(components
, '/')
45 comp
= string
.splitfields(p
, ':')
46 if len(comp
) != 2 or len(comp
[0]) > 1:
47 error
= 'Bad path: ' + p
50 drive
= string
.upper(comp
[0])
51 components
= string
.splitfields(comp
[1], '\\')
52 path
= '///' + drive
+ '|'
53 for comp
in components
:
55 path
= path
+ '/' + comp