diff options
author | Guido van Rossum <guido@python.org> | 1997-08-12 14:47:24 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-08-12 14:47:24 (GMT) |
commit | d510b72fff243d6ba6a98acef5eac733159fdbbb (patch) | |
tree | 367ebf3396d10dd0f9942a31bbf9fa72ec99b560 | |
parent | e2ad88c2027a39fda3620918d2ca41baee2a4fa5 (diff) | |
download | cpython-d510b72fff243d6ba6a98acef5eac733159fdbbb.zip cpython-d510b72fff243d6ba6a98acef5eac733159fdbbb.tar.gz cpython-d510b72fff243d6ba6a98acef5eac733159fdbbb.tar.bz2 |
Allow paths without drive specifier (Jack).
-rw-r--r-- | Lib/nturl2path.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/nturl2path.py b/Lib/nturl2path.py index 17f01f5..a25dc2a 100644 --- a/Lib/nturl2path.py +++ b/Lib/nturl2path.py @@ -4,8 +4,6 @@ def url2pathname(url): """ Convert a URL to a DOS path... - Currently only works for absolute paths - ///C|/foo/bar/spam.foo becomes @@ -13,6 +11,10 @@ def url2pathname(url): C:\foo\bar\spam.foo """ import string + if not '|' in url: + # No drive specifier, just convert slashes + components = string.splitfields(url, '/') + return string.joinfields(components, '\\') comp = string.splitfields(url, '|') if len(comp) != 2 or comp[0][-1] not in string.letters: error = 'Bad URL: ' + url @@ -28,8 +30,6 @@ def url2pathname(url): def pathname2url(p): """ Convert a DOS path name to a file url... - Currently only works for absolute paths - C:\foo\bar\spam.foo becomes @@ -38,6 +38,10 @@ def pathname2url(p): """ import string + if not ':' in p: + # No drive specifier, just convert slashes + components = string.splitfields(p, '\\') + return string.joinfields(components, '/') comp = string.splitfields(p, ':') if len(comp) != 2 or len(comp[0]) > 1: error = 'Bad path: ' + p |