From 55652cabc0552adaa44dafa8fc5652b8faeca00f Mon Sep 17 00:00:00 2001 From: calvin Date: Mon, 7 Feb 2005 15:41:53 +0000 Subject: [PATCH] fix nt path name for network paths git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2284 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- ChangeLog | 5 +++++ linkcheck/checker/fileurl.py | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 49d11668..8127dbf7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,11 @@ Type: bugfix Changed: linkcheck/url.py, linkcheck/tests/test_url.py + * Fix NT path name for network paths. + Type: bugfix + Closes: SF bug #1117839 + Changed: linkcheck/checker/fileurl.py + 2.3 "Napoleon Dynamite" (released 3.2.2005) * Use and require Python >= 2.4. diff --git a/linkcheck/checker/fileurl.py b/linkcheck/checker/fileurl.py index 817d2e90..3791dd92 100644 --- a/linkcheck/checker/fileurl.py +++ b/linkcheck/checker/fileurl.py @@ -53,6 +53,16 @@ def get_files (dirname): return files +def prepare_urlpath_for_nt (path): + """ + URLs like 'file://server/path/' result in a path named '/server/path'. + However urllib.url2pathname expects '////server/path'. + """ + if '|' not in path: + return "////"+path.lstrip("/") + return path + + def get_nt_filename (path): """ Return case sensitive filename for NT path. @@ -153,7 +163,10 @@ class FileUrl (urlbase.UrlBase): return True def get_os_filename (self): - return urllib.url2pathname(self.urlparts[2]) + path = self.urlparts[2] + if os.name == 'nt': + path = prepare_urlpath_for_nt(path) + return urllib.url2pathname(path) def is_directory (self): filename = self.get_os_filename()