Commit f31b3dd7 authored by Lars Kruse's avatar Lars Kruse

improve handling of filename URI

* Windows: use "urllib.url2pathname" instead of manual decoding
* non-Windows: use "urllib.url2pathname" instead of doing nothing

Filenames including whitespace or special characters can now be used
with the RecentChooserMenu ("recently used model files").
parent af1fe18e
......@@ -143,12 +143,12 @@ class URIHandler(object):
return None
def get_path(self):
encoded_path = self._uri.path
if get_platform() == PLATFORM_WINDOWS:
text = self._uri.netloc + self._uri.path
text = text.lstrip("/").replace("/", "\\")
return re.sub("%([0-9a-fA-F]{2})", lambda token: chr(int(token.groups()[0], 16)), text)
else:
return self._uri.path
# prepend "netloc" (the drive letter - e.g. "c:")
encoded_path = self._uri.netloc + encoded_path
# decode all special characters like "%20" and replace "/" with "\\" (Windows)
return urllib.url2pathname(encoded_path)
def get_url(self):
return self._uri.geturl()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment