def UriToFilePath( uri ): parsed_uri = urlparse( uri ) if parsed_uri.scheme != 'file': raise InvalidUriException( uri ) # url2pathname doesn't work as expected when uri.path is percent-encoded and # is a windows path for ex: # url2pathname('/C%3a/') == 'C:\\C:' # whereas # url2pathname('/C:/') == 'C:\\' # Therefore first unquote pathname. pathname = unquote( parsed_uri.path ) return os.path.abspath( url2pathname( pathname ) )
def UriToFilePath(uri): if uri[:5] != "file:": raise InvalidUriException(uri) return os.path.abspath(url2pathname(uri[5:]))
def UriToFilePath( uri ): if uri [ : 5 ] != "file:": raise InvalidUriException( uri ) return os.path.abspath( url2pathname( uri[ 5 : ] ) )