From 24a08c4442798dbefc0bb8e89a0ffd4a72e05b2b Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Wed, 6 Nov 2019 10:22:09 +0100 Subject: [PATCH] Add replacing of backslashes from normalize_path result --- xmlschema/resources.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xmlschema/resources.py b/xmlschema/resources.py index b65af5d..2f9bea1 100644 --- a/xmlschema/resources.py +++ b/xmlschema/resources.py @@ -113,9 +113,9 @@ def normalize_url(url, base_url=None, keep_relative=False): url_parts = urlsplit(url, scheme='file') if url_parts.scheme not in uses_relative: - return 'file:///{}'.format(url_parts.geturl()) # Eg. k:/Python/lib/.... + normalized_url = 'file:///{}'.format(url_parts.geturl()) # Eg. k:/Python/lib/.... elif url_parts.scheme != 'file': - return urlunsplit(( + normalized_url = urlunsplit(( url_parts.scheme, url_parts.netloc, pathname2url(url_parts.path), @@ -123,18 +123,20 @@ def normalize_url(url, base_url=None, keep_relative=False): url_parts.fragment, )) elif os.path.isabs(url_parts.path): - return url_parts.geturl() + normalized_url = url_parts.geturl() elif keep_relative: # Can't use urlunsplit with a scheme because it converts relative paths to absolute ones. - return 'file:{}'.format(urlunsplit(('',) + url_parts[1:])) + normalized_url = 'file:{}'.format(urlunsplit(('',) + url_parts[1:])) else: - return urlunsplit(( + normalized_url = urlunsplit(( url_parts.scheme, url_parts.netloc, os.path.abspath(url_parts.path), url_parts.query, url_parts.fragment, )) + + return normalized_url.replace('\\', '/') def fetch_resource(location, base_url=None, timeout=30):