From 5a604ce0a802b154b6a0a980bace4c9f6503a511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 26 Sep 2014 23:27:51 +0000 Subject: [PATCH] use .replace() for modifications --- rfc3986/uri.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/rfc3986/uri.py b/rfc3986/uri.py index 872f5d2..1de3a1a 100644 --- a/rfc3986/uri.py +++ b/rfc3986/uri.py @@ -308,14 +308,14 @@ class URIReference(namedtuple('URIReference', URI_COMPONENTS)): resolving = self if not strict and resolving.scheme == base_uri.scheme: - resolving = resolving._replace(scheme=None) + resolving = resolving.replace(scheme=None) # http://tools.ietf.org/html/rfc3986#page-32 if resolving.scheme is not None: - target = resolving._replace(path=normalize_path(resolving.path)) + target = resolving.replace(path=normalize_path(resolving.path)) else: if resolving.authority is not None: - target = resolving._replace( + target = resolving.replace( scheme=base_uri.scheme, path=normalize_path(resolving.path) ) @@ -325,7 +325,7 @@ class URIReference(namedtuple('URIReference', URI_COMPONENTS)): query = resolving.query else: query = base_uri.query - target = resolving._replace( + target = resolving.replace( scheme=base_uri.scheme, authority=base_uri.authority, path=base_uri.path, @@ -338,7 +338,7 @@ class URIReference(namedtuple('URIReference', URI_COMPONENTS)): path = normalize_path( merge_paths(base_uri, resolving.path) ) - target = resolving._replace( + target = resolving.replace( scheme=base_uri.scheme, authority=base_uri.authority, path=path, @@ -366,6 +366,9 @@ class URIReference(namedtuple('URIReference', URI_COMPONENTS)): result_list.extend(['#', self.fragment]) return ''.join(result_list) + def replace(self, **kwargs): + return self._replace(**kwargs) + def valid_ipv4_host_address(host): # If the host exists, and it might be IPv4, check each byte in the