from __future__ import annotations from rfc3986.api import uri_reference class URI: def __init__(self, uri:str): self._uri=uri self._parse= uri_reference(uri) self._normal=self._parse.normalize() def getUri(self): return self._uri def getScheme(self): return self._parse.scheme def getHost(self): return self._parse.host def getPath(self): return self._parse.path def getQuery(self): return self._parse.query def getFragment(self): return self._parse.fragment def __repr__(self)->str: return self._uri def __eq__(self, other): return isinstance(other, self.__class__) and \ self._normal==other._normal def __hash__(self): return hash(tuple(self._normal.items()))