ó ½z]c@sâdZddlmZddlmZddlmZddlmZddlmZddlmZdZ dZ de fd„ƒYZ d ed e ƒe fd„ƒYZ d ed e ƒe fd„ƒYZd„Zd„ZdS(s3Module containing the urlparse compatibility logic.iÿÿÿÿ(t namedtuplei(tcompat(t exceptions(tmisc(t normalizers(turit ParseResulttParseResultBytestschemetuserinfothosttporttpathtquerytfragmenttParseResultMixincBsGeZd„Zd„Zed„ƒZed„ƒZed„ƒZRS(csŸ‡fd†dDƒ\}}}|j|ksL|j|ksL|j|kr˜|rddj|ƒ}ntjtj||jƒtj||jƒ|fƒS|j S(Nc3s|]}ˆ|VqdS(N((t.0tp(t attributes(sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pys "sR R R s{0}(R R R ( R R R tformatRtnormalize_authorityRtto_strtencodingt authority(tselfRR R R ((RsE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyt_generate_authoritys  cCs |jƒS(s*Shim to match the standard library method.(tunsplit(R((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pytgeturl0scCs|jS(s#Shim to match the standard library.(R (R((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pythostname4scCs|jS(s#Shim to match the standard library.(R(R((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pytnetloc9scCs|jS(s#Shim to match the standard library.(R (R((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pytparams>s(t__name__t __module__RRtpropertyRRR(((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyRs   c Bs¹eZdZd Zdd„Zed d d d d d d dd„ƒZedeed„ƒZ e d„ƒZ e j e j e j e j e j e j e j d„Zd d„Zed„ZRS( s›Implementation of urlparse compatibility class. This uses the URIReference logic to handle compatibility with the urlparse.ParseResult class. sutf-8c Cs[tt|ƒj||pd|p$d||p0d|p9d||ƒ} | | _|| _| S(sCreate a new ParseResult.N(tsuperRt__new__tNoneRt reference( tclsRR R R R R Rturi_refRt parse_result((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyR#Ns       c Csød} |dk r#| |d7} n|dk r<| |7} n|dk r^| dj|ƒ7} ntjd|d| d|d|d|d |ƒjƒ} t| d tƒ\}}}|d| jd |d |d |d| jd| j d| j d| d |ƒ S(s-Create a ParseResult instance from its parts.tt@s:{0}RRR R RRtstrictR R R R'N( R$RRt URIReferencet normalizetauthority_fromtTrueRR R R( R&RR R R R R RRRR'((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyt from_parts^s.       c Cs‹tjj||ƒ}|s*|jƒ}nt||ƒ\}}}|d|jd|d|d|d|jd|jd|jd|d |ƒ S( sªParse a URI from the given unicode URI string. :param str uri_string: Unicode URI to be parsed into a reference. :param str encoding: The encoding of the string provided :param bool strict: Parse strictly according to :rfc:`3986` if True. If False, parse similarly to the standard library's urlparse function. :returns: :class:`ParseResult` or subclass thereof RR R R R R RR'R( RR,t from_stringR-R.RR R R( R&t uri_stringRR+tlazy_normalizeR%R R R ((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyR1zs    cCs |jjS(s Return the normalized authority.(R%R(R((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyR•sc CsÑtt|||||||fƒ}i} x?|D]7\} } | tjkr^t|| ƒ} n| | | Create a copy of this instance replacing with specified parts.RRR R RR'R( tziptPARSED_COMPONENTSRt UseExistingtgetattrRR%t copy_withRR(RRR R R R R RRt attrs_dicttnametvalueRtref((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyR8šs   csMˆp |j‰ttt‡fd†|Dƒƒƒ}td|jdˆ|S(s+Convert to an instance of ParseResultBytes.c3s3|])}t|dƒr'|jˆƒn|VqdS(tencodeN(thasattrR=(Rtattr(R(sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pys ³sR'R(RtdictR4R5RR%(RRtattrs((RsE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyR=®s  cCs[|}|rN|jrN|jjdƒ}|j|jƒ}|jd|ƒ}n|jjƒS(s‚Create a URI string from the components. :returns: The parsed URI reconstituted as a string. :rtype: str tidnaR (R R=tdecodeRR8R%R(Rtuse_idnaR(t hostbytesR ((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyR»s (N(RR t__doc__tslotsR#t classmethodR$R0R/R1R!RRR6R8R=tFalseR(((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyRDs       c Bs°eZdZded„Zedddddddded„ ƒZedeed„ƒZe d„ƒZ e j e j e j e j e j e j e j ed„Z ed„ZRS( s<Compatibility shim for the urlparse.ParseResultBytes object.sutf-8c Csptt|ƒj||pd|p$d||p0d|p9d|pBd|pKdƒ} | | _|| _| | _| S(s'Create a new ParseResultBytes instance.N(R"RR#R$RR%R3( R&RR R R R R RR'RR3R(((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyR#Ís        c CsFd} |dk r#| |d7} n|dk r<| |7} n|dk rd| djt|ƒƒ7} ntjd|d| d|d|d|d |ƒ} | s©| jƒ} ntj} t| d t ƒ\}}}|d| ||ƒd | ||ƒd | ||ƒd |d| ||ƒd| ||ƒd| ||ƒd| d |d| ƒ S(s-Create a ParseResult instance from its parts.R)R*s:{0}RRR R RRR+R R R R'R3N( R$RtintRR,R-Rtto_bytesR.R/( R&RR R R R R RRR3RR'RK((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyR0Þs6      c CsÐtjj||ƒ}|s*|jƒ}nt||ƒ\}}}tj} |d| |j|ƒd| ||ƒd| ||ƒd|d| |j|ƒd| |j |ƒd| |j |ƒd|d |d |ƒ S( s¯Parse a URI from the given unicode URI string. :param str uri_string: Unicode URI to be parsed into a reference. :param str encoding: The encoding of the string provided :param bool strict: Parse strictly according to :rfc:`3986` if True. If False, parse similarly to the standard library's urlparse function. :returns: :class:`ParseResultBytes` or subclass thereof RR R R R R RR'RR3( RR,R1R-R.RRKRR R R( R&R2RR+R3R%R R R RK((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyR1ÿs  cCs|jjj|jƒS(s Return the normalized authority.(R%RR=R(R((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyRsc  Csett|||||||fƒ} i} xs| D]k\} } | tjkr^t|| ƒ} nt| tƒ r’t| dƒr’| j|j ƒ} n| | | Create a copy of this instance replacing with specified parts.R=RRR R RR'RR3(R4R5RR6R7t isinstancetbytesR>R=RRRRR%R8R-R(RRR R R R R RR3RR9R:R;RRR<((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyR8!s0   cCs‹|}|rN|jrN|jj|jƒ}|jdƒ}|jd|ƒ}n|jrl|jdtƒ}n|jjƒ}|j|jƒS(sŠCreate a URI bytes object from the components. :returns: The parsed URI reconstituted as a string. :rtype: bytes RBR R3( R RCRR=R8R3RIR%R(RRDR(R RER((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyRAs N(RR RFR/R#RHR$R0R1R!RRR6R8RIR(((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyRÉs     cCsÕd}}}d}|}d|krA|jddƒ\}}n|jdƒru|jddƒ\}}|d7}nd|krœ|jddƒ\}}n| r²|r²|}n|rÈ| rÈ|}n|||fS(NR*it[t]t:(R$trsplitt startswithtsplit(RR R R t extra_hosttrest((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pytsplit_authorityTs       cs³y|jƒ‰Wn8tjk rJ|r/‚nt|jƒ\}}}n X‡fd†dDƒ\}}}|r¦yt|ƒ}Wq¦tk r¢tj|ƒ‚q¦Xn|||fS(Nc3s|]}ˆj|ƒVqdS(N(tget(RR(t subauthority(sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pys ysR R R (R R R (tauthority_infoRtInvalidAuthorityRVRRJt ValueErrort InvalidPort(R%R+R R R ((RXsE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyR.os  N(RR(RR R R R R R(RFt collectionsRR)RRRRRt__all__R5tobjectRRRRVR.(((sE/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/parseresult.pyts &„Š