
    ?wgzi              
       J   d Z ddlZddlZddlZddlZddlZddlmZ dZdZ	dZ
dZe
ez   ZdZ eej                               Zd	 ed
      D  cg c]"  } | ev r	 e| g      nd| z  j                         $ c} iZeD ci c]/  }eD ](  }||z   j                         ej)                  ||z         * 1 c}}Zd0dZd1dZ G d d ej0                  dd            Z G d d ej0                  dd            Z G d de      Z G d de      Zd Zd Zd Zd2dZ d Z!d Z"d Z#d Z$d  Z%d! Z& ejN                  d"      Z( ejN                  d#      Z) ejN                  d$      Z*ed%z   Z+eZ,ed&z   Z-ed'z   Z.ed'z   Z/d( Z0d) Z1d* Z2d+ Z3d, Z4d- Z5d. Z6	 	 	 	 	 	 	 	 	 	 d3d/Z7yc c} w c c}}w )4zRFC 3986 compliant, scheme-agnostic replacement for `urllib.parse`.

This module defines RFC 3986 compliant replacements for the most
commonly used functions of the Python Standard Library
:mod:`urllib.parse` module.

    N)	hexdigits)
GEN_DELIMSRESERVED
SUB_DELIMS
UNRESERVED	isabspathisabsuri	isnetpath	isrelpath	issamedocisuri
uricompose	uridecode	uridefrag	uriencodeurijoinurisplit
uriunsplitz4.0.3z:/?#[]@z!$&'()*+,;=zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~       z%%%02Xc                 Z   t        | t              s| j                  ||      } t        |t              s|j                  d      }	 t        |   }dj                  t        |j                  |             S # t        $ r. t        d   dd }|D ]  }t        |g      ||<    |t        |<   Y [w xY w)z(Encode a URI string or string component.asciir   N)
isinstancebytesencode_encodedKeyErrorjoinmap__getitem__)	uristringsafeencodingerrorsencodedis         H/var/www/horilla/myenv/lib/python3.12/site-packages/uritools/__init__.pyr   r   L   s    i'$$Xv6	dE"{{7#!4. 88C++Y788  !3-" 	$AsGAJ	$ 	!s   	A3 34B*)B*c           
      v   t        | t              s| j                  |xs d|      } | j                  d      }|d   g}|j                  }t
        j                  }|dd D ]%  } | ||dd d|dd z                 ||dd        ' |!dj                  |      j                  ||      S dj                  |      S )z(Decode a URI string or string component.r      %r      N   r   )	r   r   r   splitappend_decodedgetr   decode)r!   r#   r$   partsresultr-   r0   ss           r'   r   r   \   s    i'$$X%8&A	OOD!EAhZF]]F\\F12Y vaeTAbqE\*+qu xx&&x88xxr   c                   "    e Zd ZdZdZd ZddZy)DefragResultz(Class to hold :func:`uridefrag` results. c                     | j                   }|| j                  S t        |t              r| j                  dz   |z   S | j                  dz   |z   S )z>Return the recombined version of the original URI as a string.   ##)fragmenturir   r   )selfr:   s     r'   geturizDefragResult.geturir   sJ    ==88O%(88d?X--88c>H,,r   Nc                 <    | j                   }|t        |||      S |S )zReturn the decoded fragment identifier, or `default` if the
        original URI did not contain a fragment component.

        r:   r   r<   defaultr#   r$   r:   s        r'   getfragmentzDefragResult.getfragment|   s'    
 ==Xx88Nr   Nutf-8strict)__name__
__module____qualname____doc__	__slots__r=   rB   r6   r   r'   r5   r5   m   s    2I-	r   r5   zuri fragmentc                       e Zd ZdZdZed        Zed        Zed        Zd Z	ddZ
dd	Zdd
ZddZddZddZddZd dZd dZddZd Zd Zd Zd Zd Zd Zd!dZd Zed        Zed        Zy)"SplitResultz,Base class to hold :func:`urisplit` results.r6   c                 h    | j                   }|y |j                  | j                        \  }}}|r|S y N)	authority
rpartitionAT)r<   rO   userinfopresent_s        r'   rR   zSplitResult.userinfo   s:    NN	(33DGG<'1Or   c                     | j                   }|y |j                  | j                        \  }}}|j                  | j                        \  }}}|j	                  | j
                        r|S |S rN   )rO   rP   rQ   COLONlstripDIGITS)r<   rO   rT   hostinfohostports         r'   rZ   zSplitResult.host   sb    NN	"--dgg61h ++DJJ7a;;t{{#OKr   c                     | j                   }|y |j                  | j                        \  }}}|r|j                  | j                        s|S y rN   )rO   rP   rV   rW   rX   )r<   rO   rT   rS   r[   s        r'   r[   zSplitResult.port   sI    NN	$//

;7D4;;t{{3Kr   c                 |   | \  }}}}}g }||j                  || j                  g       |(|j                  | j                  | j                  |g       |j                  |       ||j                  | j                  |g       ||j                  | j
                  |g       | j                  j                  |      S )z[Return the re-combined version of the original URI reference as a
        string.

        )extendrV   SLASHr-   QUESTHASHEMPTYr   )r<   schemerO   pathqueryr:   r2   s          r'   r=   zSplitResult.geturi   s    
 480	4 MM64::./ MM4::tzz9=>dMM4::u-.MM499h/0zzv&&r   Nc                     | j                   }||S t        |t              r|j                  d      j	                         S |j	                         S )zReturn the URI scheme in canonical (lowercase) form, or `default`
        if the original URI reference did not contain a scheme component.

        r   )rc   r   r   r0   lower)r<   rA   rc   s      r'   	getschemezSplitResult.getscheme   sE    
 >N&==)//11<<>!r   c                    |d}nHt        |t        j                  j                        st	        d      t        |      dk7  rt        d      | j                  |d   ||      | j                  |d   |      | j                  |d         fS )zvReturn the decoded userinfo, host and port subcomponents of the URI
        authority as a three-item tuple.

        NNNzInvalid default type   zInvalid default lengthr   r*   r+   )
r   collectionsabcIterable	TypeErrorlen
ValueErrorgetuserinfogethostgetport)r<   rA   r#   r$   s       r'   getauthorityzSplitResult.getauthority   s     ?(GG[__%=%=>233\Q566 WQZ6:LLV,LL$
 	
r   c                 <    | j                   }||S t        |||      S )zReturn the decoded userinfo subcomponent of the URI authority, or
        `default` if the original URI reference did not contain a
        userinfo field.

        )rR   r   )r<   rA   r#   r$   rR   s        r'   rr   zSplitResult.getuserinfo   s'     ==NXx88r   c                 .   | j                   }||s||S |j                  | j                        r/|j                  | j                        r| j                  |dd       S |j                  | j                        s|j                  | j                        rt        d|z        	 t        |t              r$t        j                  |j                  d            S t        j                  |      S # t        $ r t        |d|      j                         cY S w xY w)zReturn the decoded host subcomponent of the URI authority as a
        string or an :mod:`ipaddress` address object, or `default` if
        the original URI reference did not contain a host.

        r*   zInvalid host %rr   rD   )rZ   
startswithLBRACKETendswithRBRACKET_SplitResult__parse_ip_literalrq   r   r   	ipaddressIPv4Addressr0   r   rg   )r<   rA   r$   rZ   s       r'   rs   zSplitResult.gethost   s     yy<)<N__T]]+dmm0L**4":66__T]]+t}}T]]/K.566	<$& ,,T[[-ABB ,,T22 	<T7F399;;	<s   $3C- C- -$DDc                 8    | j                   }|rt        |      S |S )zReturn the port subcomponent of the URI authority as an
        :class:`int`, or `default` if the original URI reference did
        not contain a port or if the port was empty.

        )r[   int)r<   rA   r[   s      r'   rt   zSplitResult.getport  s     yyt9Nr   c                 R    | j                  | j                        }t        |||      S )z'Return the normalized decoded URI path.)!_SplitResult__remove_dot_segmentsrd   r   )r<   r#   r$   rd   s       r'   getpathzSplitResult.getpath  s%    ))$))4x00r   c                 <    | j                   }||S t        |||      S )zReturn the decoded query string, or `default` if the original URI
        reference did not contain a query component.

        )re   r   )r<   rA   r#   r$   re   s        r'   getqueryzSplitResult.getquery  s&    
 

=NUHf55r   c                     t        j                  t              }| j                  |||      D ]  \  }}||   j	                  |        |S )a  Split the query component into individual `name=value` pairs
        separated by `sep` and return a dictionary of query variables.
        The dictionary keys are the unique query variable names and
        the values are lists of values for each name.

        )rl   defaultdictlistgetquerylistr-   )r<   sepr#   r$   dictnamevalues          r'   getquerydictzSplitResult.getquerydict#  sM     &&t,,,S(FC 	%KD%Je$	%r   c                 H   | j                   sg S t        |t        | j                               r| j                   j                  |      }net        |t              r+| j                   j                  |j                  d            }n*| j                   j                  |j                  d            }g }|D cg c]   }|s|j                  | j                        " c}D ]=  }t        |d   ||      }|d   rt        |d   ||      }	nd}	|j                  ||	f       ? |S c c}w )zSplit the query component into individual `name=value` pairs
        separated by `sep`, and return a list of `(name, value)`
        tuples.

        r   r   r*   r+   N)re   r   typer,   r   r0   r   	partitionEQr   r-   )
r<   r   r#   r$   qslitemsqsr1   r   r   s
             r'   r   zSplitResult.getquerylist/  s     zzIT$**-.**""3'CU#**""3::g#67C**""3::g#67C69@Rbll477+@ 	(EU1Xx8DQx!%(Hf=LL$'	(  As   5D=Dc                 <    | j                   }||S t        |||      S )zReturn the decoded fragment identifier, or `default` if the
        original URI reference did not contain a fragment component.

        r?   r@   s        r'   rB   zSplitResult.getfragmentG  s'    
 ==NXx88r   c                     | j                   duS )z&Return :const:`True` if this is a URI.Nrc   r<   s    r'   r   zSplitResult.isuriR  s    {{$&&r   c                 >    | j                   duxr | j                  du S )z0Return :const:`True` if this is an absolute URI.N)rc   r:   r   s    r'   r	   zSplitResult.isabsuriV  s    {{$&@4==D+@@r   c                 >    | j                   du xr | j                  duS )z9Return :const:`True` if this is a network-path reference.N)rc   rO   r   s    r'   r
   zSplitResult.isnetpathZ  s    {{d"At~~T'AAr   c                     | j                   du xr5 | j                  du xr% | j                  j                  | j                        S )z;Return :const:`True` if this is an absolute-path reference.Nrc   rO   rd   ry   r_   r   s    r'   r   zSplitResult.isabspath^  sA     KK4 1$&1		$$TZZ0	
r   c                     | j                   du xr6 | j                  du xr& | j                  j                  | j                         S )z:Return :const:`True` if this is a relative-path reference.Nr   r   s    r'   r   zSplitResult.isrelpathf  sD     KK4 5$&5II((44	
r   c                 |    | j                   du xr- | j                  du xr | j                   xr | j                  du S )z:Return :const:`True` if this is a same-document reference.N)rc   rO   rd   re   r   s    r'   r   zSplitResult.issamedocn  sG     KK4 #$&#II# 

d"		
r   c                 |   | j                   j                  |      j                         \  }}}}}|#|s|| j                  k7  r| j	                  |      }n|| j                  }| j	                  |      }n|s5| j                  }| j
                  }| j                  }|| j                  n|}n}|j                  | j                        r*| j                  }| j
                  }| j	                  |      }n8| j                  }| j
                  }| j	                  | j                  |            } t        |       |||||      S )zwTransform a URI reference relative to `self` into a
        :class:`SplitResult` representing its target URI.

        )REmatchgroupsrc   r   rO   rd   re   ry   r_   _SplitResult__merger   )r<   refrE   rc   rO   rd   re   r:   s           r'   	transformzSplitResult.transformw  s   
 4877==3E3L3L3N0	4 6Vt{{-B--d3D"[[F--d3D[[FI99D"'-DJJUE__TZZ([[FI--d3D[[FI--dll4.@ADtDz&)T5(CCr   c                     | j                   | j                  s| j                  |z   S | j                  j                  | j                        }|d   j	                  |d   |f      S )Nr*   r   )rO   rd   r_   rP   r   )r<   rd   r1   s      r'   __mergezSplitResult.__merge  sU    >>%dii::$$II((4E8==%(D!122r   c                    g }|j                  | j                        D ]}  }|| j                  k(  r|| j                  k7  r|j	                  |       4t        |      dk(  r|d   sH|r#|d   | j                  k7  r|j                          m|j	                  |        |j                  | j                        d   | j                  | j                  fv r|j	                  | j                         |r<t        |      dk(  r.|d   | j                  k(  r|j                  d| j                         | j                  j                  |      S )Nr*   r   rx   r+   )r,   r_   DOTDOTDOTr-   rp   poprP   rb   insertr   )clsrd   psegr3   s       r'   __remove_dot_segmentsz!SplitResult.__remove_dot_segments  s     CII& 
	ACGG|cjjATaQ$r(cjj0
A
	 ??399%a(SWWcjj,AAKK		"CINtAw#))';KK377#yy~~d##r   c                     t        |t              r|j                  d      }|j                  d      rt	        d      t        j                  |      S )Nr   vzaddress mechanism not supported)r   r   r0   ry   rq   r~   IPv6Address)r   addresss     r'   __parse_ip_literalzSplitResult.__parse_ip_literal  sG    " gu%nnW-Gc">??$$W--r   rN   rC   )NrE   rD   rE   )&rD   rE   F)rF   rG   rH   rI   rJ   propertyrR   rZ   r[   r=   rh   ru   rr   rs   rt   r   r   r   r   rB   r   r	   r
   r   r   r   r   r   classmethodr   r}   r6   r   r'   rL   rL      s     7I  	 	  '("
&
9<,
1
	6
0	9'AB


D83 $ $* . .r   rL   z$scheme authority path query fragmentc                   x    e Zd ZdZ ej
                  dej                        Zd\  ZZ	Z
ZZZZd\  ZZd\  ZZdZy)	SplitResultBytesr6   s   
    (?:([A-Za-z][A-Za-z0-9+.-]*):)?  # scheme (RFC 3986 3.1)
    (?://([^/?#]*))?                 # authority
    ([^?#]*)                         # path
    (?:\?([^#]*))?                   # query
    (?:\#(.*))?                      # fragment
    flags)   :   /   ?r8      [   ]   @)   .s   ..)r      =
   0123456789NrF   rG   rH   rJ   recompileVERBOSEr   rV   r_   r`   ra   rz   r|   rQ   r   r   rb   r   rX   r6   r   r'   r   r     sV    I 
	 jj	
B95E5%x2 KCIE2Fr   r   c                   x    e Zd ZdZ ej
                  dej                        Zd\  ZZ	Z
ZZZZd\  ZZd\  ZZdZy)	SplitResultStringr6   z
    (?:([A-Za-z][A-Za-z0-9+.-]*):)?  # scheme (RFC 3986 3.1)
    (?://([^/?#]*))?                 # authority
    ([^?#]*)                         # path
    (?:\?([^#]*))?                   # query
    (?:\#(.*))?                      # fragment
    r   ):/?r9   []@).z..) =
0123456789Nr   r6   r   r'   r   r     sV    I 
	 jj	
B95E5%x2 KCIE2Fr   r   c                     t        | t              r| j                  d      }n| j                  d      }t        |d   |d   r	|d         S d      S )zBRemove an existing fragment component from a URI reference string.r8   r9   r   r*   r+   N)r   r   r   r5   )r!   r1   s     r'   r   r     sO    )U###D)##C(aeAh%(AADAAr   c                     t        | t              rt        }nt        } ||j                  j                  |       j                          S )zSplit a well-formed URI reference string into a tuple with five
    components corresponding to a URI's general structure::

      <scheme>://<authority>/<path>?<query>#<fragment>

    )r   r   r   r   r   r   r   )r!   r2   s     r'   r   r     s9     )U#!"699??9-44677r   c                     | \  }}}}}t        |t              rt        }nt        } ||||||      j	                         S )zdCombine the elements of a five-item iterable into a URI reference's
    string representation.

    )r   r   r   r   r=   )r1   rc   rO   rd   re   r:   r2   s          r'   r   r   $  sD    
 05,FItUH$!"&)T5(;BBDDr   c                 z   t        | t        |            r)t        |       j                  ||      j	                         S t        | t
              r7t        | j                               j                  ||      j	                         S t        |       j                  |j                         |      j	                         S )zRConvert a URI reference relative to a base URI to its target URI
    string.

    )r   r   r   r   r=   r   r0   )baser   rE   s      r'   r   r   1  s    
 $S	"~''V4;;==	D%	 &00f=DDFF~''

f=DDFFr   c                 4    t        |       j                         S )z-Return :const:`True` if `uristring` is a URI.)r   r   r!   s    r'   r   r   >  s    I$$&&r   c                 4    t        |       j                         S )z7Return :const:`True` if `uristring` is an absolute URI.)r   r	   r   s    r'   r	   r	   C  s    I''))r   c                 4    t        |       j                         S )z@Return :const:`True` if `uristring` is a network-path reference.)r   r
   r   s    r'   r
   r
   H      I((**r   c                 4    t        |       j                         S )zBReturn :const:`True` if `uristring` is an absolute-path reference.)r   r   r   s    r'   r   r   M  r   r   c                 4    t        |       j                         S )zAReturn :const:`True` if `uristring` is a relative-path reference.)r   r   r   s    r'   r   r   R  r   r   c                 4    t        |       j                         S )zAReturn :const:`True` if `uristring` is a same-document reference.)r   r   r   s    r'   r   r   W  r   r   s   ^[A-Za-z][A-Za-z0-9+.-]*$s   ^(?:(.*)@)?(.*?)(?::([0-9]*))?$z^(?:(.*)@)?(.*?)(?::([0-9]*))?$r   z:@/z:@/?c                 b    t         j                  |       r| j                         S t        d      )NzInvalid scheme component)
_SCHEME_REr   rg   rq   r   s    r'   _schemer   m  s(    ||~344r   c                    g }| 1|j                  t        | t        |             |j                  d       t        |t        j
                        r0|j                  d|j                  j                         z   dz          nt        |t        j                        r*|j                  |j                  j                                nVt        |t              r|j                  t        |             n+|)|j                  t        |j                  d                   t        |t        j                        r2|j                  t        t        |      j                                      nUt        |t              r|j                  t        |             n*|(|j                  t        |j                                      |rdj                  |      S d S )Nr   r   r   rD   r   )r-   r   _SAFE_USERINFOr   r~   r   
compressedr   r   r   _hostnumbersNumber_portstrr   )rR   rZ   r[   r#   rO   s        r'   
_authorityr   t  sO   I8^XFG$	--. 6 6 884?@	D)//	0//12	D%	 t%		t{{7345$'s4y//123	D%	 t%		t{{}-."+388I55r   c                     | j                  d      rt        d      dt        j                  |       j                  j                         z   dz   S )Nr   zAddress mechanism not supportedr   r   )ry   rq   r~   r   r   r   )r   s    r'   _ip_literalr     sF    #:;;i++G4??FFHH4OOr   c                    | j                  d      r-| j                  d      rt        | dd j                               S 	 t        | j                  d            S # t        $ r" t        | j                         t        d      cY S w xY w)Nr   r   r*   rx   rD   )ry   r{   r   r0   rq   r   rg   
_SAFE_HOST)rZ   s    r'   r   r     sr    
 tt!44":,,.//<4;;w/00 <z7;;<s    A (BBc                 J    | j                  d      rt        d      | rd| z   S y)Nr   zInvalid port subcomponentr   r   )rW   rq   )r[   s    r'   r   r     s,     {{=!455	d{r   c           	      r   g }|j                   }t        j                  |d      }| D ]o  \  }}t        |||      }|	 ||       t	        |t
        t        f      r ||dz   t        |||      z          N ||dz   t        t        |      ||      z          q |j                  d      j                  |      S )Nr   r   r   )	r-   _SAFE_QUERYreplacer   r   r   r   r   r   )	r   r   r#   termsr-   r"   keyr   r   s	            r'   
_querylistr     s    E\\FsB'D H
UdH-=4Ls|,4$;5$!AAB4$;3u:tX!FFGH ::g##E**r   c                 `   g }| j                         D ]  \  }}t        |t        t        f      r|j	                  ||f       0t        |t
        j                  j                        r"|j                  |D cg c]  }||f c}       v|j	                  ||f        t        |||      S c c}w rN   )
r   r   r   r   r-   rl   rm   rn   r^   r   )mappingr   r#   r   r   r   r   s          r'   
_querydictr     s    Emmo '
UeeS\*LL#u&{778LLE2q3(23LL#u&' eS(++ 3s   6B+
c
                    t        | t              rt        |       } n| t        | j                               } |d}nt        |t              r$t        j                  |      j                         }n|t        |t              r$t        j                  |      j                         }nHt        |t        j                  j                        st        d      t        |      dk7  rt        d      t        ||n|d   ||n|d   ||n|d   |	      }t!        |t"        |	      }||r|j%                  d      st        d	      ||j%                  d
      rt        d      | .|,|j%                  d      sd|j'                  d      d   v rd|z   }t        |t        t        f      rt!        |t(        |	      }nqt        |t        j                  j*                        rt-        |||	      }n?t        |t        j                  j                        rt/        |||	      }n|t        d      |t!        |t0        |	      }t3        | ||||f      j5                         S )z>Compose a URI reference string from its individual components.rj   zInvalid authority typerk   zInvalid authority lengthr   r*   r+   r   z%Invalid path with authority components   //z(Invalid path without authority componentr   s   ./zInvalid query type)r   r   r   r   _AUTHORITY_RE_BYTESr   r   r   _AUTHORITY_RE_STRrl   rm   rn   ro   rp   rq   r   r   
_SAFE_PATHry   r   r   Mappingr   r   _SAFE_FRAGMENTr   r0   )
rc   rO   rd   re   r:   rR   rZ   r[   querysepr#   s
             r'   r   r     s   . &% 		) &		Iu	%'--i8??A		Is	#%++I6==?		;??#;#;<011	Y1	344(il il il	I T:x0Ddood.C@AAT__U3CDD ~)+DOOD4I4>>$'**4<D %%&%h7	E;??22	35(H5	E;??33	45(H5		,-- X~x@ vy$x@AHHJJr   )r   rD   rE   r   r   )
NNr   NNNNNr   rD   )8rI   rl   collections.abcr~   r   r   stringr   __all____version__r   r   r   r   	frozensetr   _unreservedranger   r   fromhexr.   r   r   
namedtupler5   rL   r   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r  r  r   r   r  r   r  r   r   r   r   r   r   r   r   )r&   abs   000r'   <module>r     s>       	 (  


" R  
))+,
 MRSVZ
HIa;&qc
X\,A,A,CC
 5>/0yBCQUNNemmAE**
9  ");))..I 6~.K=*PQ~.B
{ D DB8
E
G'
*
+
+
+
+ RZZ45
 !bjj!CD BJJ@A  c!
%
6!f$564P<	+	, 	
		^KQ

s   'F=4F