
     h|i                        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                                          Zd	d
  ed          D             iZd eD             Zd6dZd7dZ G d d ej        dd                    Z G d d ej        dd                    Z G d de          Z G d de          Zd Zd Zd Zd8d Zd! Zd" Z d# Z!d$ Z"d% Z#d& Z$ ej%        d'          Z& ej%        d(          Z' ej%        d)          Z(ed*z   Z)eZ*ed+z   Z+ed,z   Z,ed,z   Z-d- Z.d. Z/d/ Z0d0 Z1d1 Z2d2 Z3d3 Z4	 	 	 	 	 	 	 	 	 	 d9d5Z5dS ):zRFC 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.1z:/?#[]@z!$&'()*+,;=zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~    c                 n    g | ]2}|t           v rt          |g          nd |z                                  3S )z%%%02X)_unreservedbytesencode).0is     M/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/uritools/__init__.py
<listcomp>r   B   sK     
 
 
HIa;&&qc


X\,A,A,C,C
 
 
r      c                     i | ]?}t           D ]5}||z                                   t                              ||z             6@S  )r   r   r   fromhex)r   abs      r   
<dictcomp>r$   G   sY       /0y BCQUNNemmAE**   r    utf-8strictc                    t          | t                    s|                     ||          } t          |t                    s|                    d          }	 t          |         }nG# t          $ r: t          d         dd         }|D ]}t          |g          ||<   |t          |<   Y nw xY wd                    t          |j        |                     S )z(Encode a URI string or string component.asciir   N)
isinstancer   r   _encodedKeyErrorjoinmap__getitem__)	uristringsafeencodingerrorsencodedr   s         r   r   r   L   s    i'' 7$$Xv66	dE"" ${{7##!4. ! ! !3-" 	$ 	$AsGAJJ 	!
 88C+Y77888s   A% %AB)(B)c           
         t          | t                    s|                     |pd|          } |                     d          }|d         g}|j        }t
          j        }|dd         D ]=} | ||dd         d|dd         z                         ||dd                    >|)d                    |                              ||          S d                    |          S )z(Decode a URI string or string component.r)      %r      N   r   )	r*   r   r   splitappend_decodedgetr-   decode)r0   r2   r3   partsresultr:   r=   ss           r   r   r   \   s    i'' B$$X%8&AA	OOD!!EAhZF]F\F122Y  vvaeTAbqbE\**+++quxx&&x888xxr   c                   $    e Zd ZdZdZd ZddZdS )	DefragResultz(Class to hold :func:`uridefrag` results.r    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.N   ##)fragmenturir*   r   )selfrF   s     r   geturizDefragResult.geturir   sJ    =8O%(( 	-8d?X--8c>H,,r   Nr&   r'   c                 :    | j         }|t          |||          S |S )zReturn the decoded fragment identifier, or `default` if the
        original URI did not contain a fragment component.

        rF   r   rH   defaultr2   r3   rF   s        r   getfragmentzDefragResult.getfragment|   s(    
 =Xx888Nr   Nr&   r'   )__name__
__module____qualname____doc__	__slots__rI   rN   r    r   r   rB   rB   m   sB        22I- - -	 	 	 	 	 	r   rB   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dS )&SplitResultz,Base class to hold :func:`urisplit` results.r    c                 `    | j         }|d S |                    | j                  \  }}}|r|S d S N)	authority
rpartitionAT)rH   rY   userinfopresent_s        r   r\   zSplitResult.userinfo   sB    N	4(33DG<<'1 	O4r   c                     | j         }|d S |                    | j                  \  }}}|                    | j                  \  }}}|                    | j                  r|S |S rX   )rY   rZ   r[   COLONlstripDIGITS)rH   rY   r^   hostinfohostports         r   rd   zSplitResult.host   sj    N	4"--dg661h ++DJ77a;;t{## 	OKr   c                     | j         }|d S |                    | j                  \  }}}|r|                    | j                  s|S d S rX   )rY   rZ   r`   ra   rb   )rH   rY   r^   r]   re   s        r   re   zSplitResult.port   sW    N	4$//
;;7D 	4;;t{33 	K4r   c                 p   | \  }}}}}g }||                     || j        g           |"|                     | j        | j        |g           |                    |           ||                     | j        |g           ||                     | j        |g           | j                            |          S )z[Return the re-combined version of the original URI reference as a
        string.

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

        Nr)   )rm   r*   r   r=   lower)rH   rM   rm   s      r   	getschemezSplitResult.getscheme   sS    
 >N&& 	"==))//111<<>>!r   r&   r'   c                 R   |d}nPt          |t          j        j                  st	          d          t          |          dk    rt          d          |                     |d         ||          |                     |d         |          | 	                    |d                   fS )	zvReturn the decoded userinfo, host and port subcomponents of the URI
        authority as a three-item tuple.

        NNNNzInvalid default type   zInvalid default lengthr   r7   r8   )
r*   collectionsabcIterable	TypeErrorlen
ValueErrorgetuserinfogethostgetport)rH   rM   r2   r3   s       r   getauthorityzSplitResult.getauthority   s     ?(GGG[_%=>> 	72333\\Q56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.

        )r\   r   )rH   rM   r2   r3   r\   s        r   r|   zSplitResult.getuserinfo   s(     =NXx888r   c                 V   | j         }||s||S |                    | j                  r7|                    | j                  r|                     |dd                   S |                    | j                  s|                    | j                  rt          d|z            	 t          |t                    r't          j
        |                    d                    S t          j
        |          S # t          $ r& t          |d|                                          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.

        Nr7   zInvalid host %rr)   r&   )rd   
startswithLBRACKETendswithRBRACKET_SplitResult__parse_ip_literalr{   r*   r   	ipaddressIPv4Addressr=   r   rq   )rH   rM   r3   rd   s       r   r}   zSplitResult.gethost   s(    y<<)<N__T]++ 	7dm0L0L 	7**4":666__T]++ 	7t}}T]/K/K 	7.5666	<$&& 3 ,T[[-A-ABBB ,T222 	< 	< 	<T7F3399;;;;;	<s   (;C8 $C8 8-D('D(c                 6    | 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.

        )re   int)rH   rM   re   s      r   r~   zSplitResult.getport  s$     y 	t99Nr   c                 X    |                      | j                  }t          |||          S )z'Return the normalized decoded URI path.)!_SplitResult__remove_dot_segmentsrn   r   )rH   r2   r3   rn   s       r   getpathzSplitResult.getpath  s)    ))$)44x0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.

        )ro   r   )rH   rM   r2   r3   ro   s        r   getqueryzSplitResult.getquery  s'    
 
=NUHf555r   &c                     t          j        t                    }|                     |||          D ] \  }}||                             |           !|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.

        )rv   defaultdictlistgetquerylistr:   )rH   sepr2   r3   dictnamevalues          r   getquerydictzSplitResult.getquerydict#  sY     &t,,,,S(FCC 	% 	%KD%Je$$$$r   c                 :     j         sg S t          |t           j                             r j                             |          }npt          |t                    r. j                             |                    d                    }n- j                             |                    d                    }g } fd|D             D ]R}t          |d         ||          }|d         rt          |d         ||          }nd}|                    ||f           S|S )zSplit the query component into individual `name=value` pairs
        separated by `sep`, and return a list of `(name, value)`
        tuples.

        r)   c                 H    g | ]}||                     j                  S r    )	partitionEQ)r   qsrH   s     r   r   z,SplitResult.getquerylist.<locals>.<listcomp>>  s,    @@@R@bll47++@@@r   r   r7   r8   N)	ro   r*   typer9   r   r=   r   r   r:   )	rH   r   r2   r3   qslitemsr>   r   r   s	   `        r   r   zSplitResult.getquerylist/  s     z 	8IT$*--.. 	8*""3''CCU## 	8*""3::g#6#677CC*""3::g#6#677C@@@@c@@@ 	( 	(EU1Xx88DQx !%(Hf==LL$''''r   c                 :    | j         }||S t          |||          S )zReturn the decoded fragment identifier, or `default` if the
        original URI reference did not contain a fragment component.

        rK   rL   s        r   rN   zSplitResult.getfragmentG  s(    
 =NXx888r   c                     | j         duS )z&Return :const:`True` if this is a URI.Nrm   rH   s    r   r   zSplitResult.isuriR  s    {$&&r   c                 &    | j         duo| j        du S )z0Return :const:`True` if this is an absolute URI.N)rm   rF   r   s    r   r	   zSplitResult.isabsuriV  s    {$&@4=D+@@r   c                 &    | j         du o| j        duS )z9Return :const:`True` if this is a network-path reference.N)rm   rY   r   s    r   r
   zSplitResult.isnetpathZ  s    {d"At~T'AAr   c                 d    | j         du o'| j        du o| j                            | j                  S )z;Return :const:`True` if this is an absolute-path reference.Nrm   rY   rn   r   ri   r   s    r   r   zSplitResult.isabspath^  s<     K4 1$&1	$$TZ00	
r   c                 f    | j         du o(| j        du o| j                            | j                   S )z:Return :const:`True` if this is a relative-path reference.Nr   r   s    r   r   zSplitResult.isrelpathf  s?     K4 5$&5I((444	
r   c                 H    | j         du o| j        du o| j         o| j        du S )z:Return :const:`True` if this is a same-document reference.N)rm   rY   rn   ro   r   s    r   r   zSplitResult.issamedocn  s?     K4 #$&#I# 
d"		
r   Fc                 T   | j                             |                                          \  }}}}}|#|s|| j        k    r|                     |          }n|| j        }|                     |          }n|s!| j        }| j        }| j        }|| j        n|}nt|                    | j	                  r$| j        }| j        }|                     |          }n6| j        }| j        }|                     | 
                    |                    } t          |           |||||          S )zwTransform a URI reference relative to `self` into a
        :class:`SplitResult` representing its target URI.

        )REmatchgroupsrm   r   rY   rn   ro   r   ri   _SplitResult__merger   )rH   refr'   rm   rY   rn   ro   rF   s           r   	transformzSplitResult.transformw  s2   
 487==3E3E3L3L3N3N0	4 6Vt{-B-B--d33DD"[F--d33DD 	B[FI9D"'-DJJUEE__TZ(( 	B[FI--d33DD[FI--dll4.@.@AADtDzz&)T5(CCCr   c                     | j         | j        s
| j        |z   S | j                            | j                  }|d                             |d         |f          S )Nr7   r   )rY   rn   ri   rZ   r-   )rH   rn   r>   s      r   __mergezSplitResult.__merge  sT    >%di%:$$I((44E8==%(D!1222r   c                    g }|                     | j                  D ]}|| j        k    r|| j        k    r|                    |           /t          |          dk    r	|d         sK|r&|d         | j        k    r|                                 s|                    |           |                    | j                  d         | j        | j        fv r|                    | j                   |r?t          |          dk    r,|d         | j        k    r|	                    d| j                   | j        
                    |          S )Nr7   r   r   r8   )r9   ri   DOTDOTDOTr:   rz   poprZ   rl   insertr-   )clsrn   psegr@   s       r   __remove_dot_segmentsz!SplitResult.__remove_dot_segments  s-    CI&& 
	 
	ACG||cjATaQ $r(cj00



A??39%%a(SWcj,AAAKK	""" 	$CIINNtAw#)';';KK37###y~~d###r   c                     t          |t                    r|                    d          }|                    d          rt	          d          t          j        |          S )Nr)   vzaddress mechanism not supported)r*   r   r=   r   r{   r   IPv6Address)r   addresss     r   __parse_ip_literalzSplitResult.__parse_ip_literal  s^    " gu%% 	.nnW--Gc"" 	@>???$W---r   rX   rO   )Nr'   r&   r'   )r   r&   r'   F)rP   rQ   rR   rS   rT   propertyr\   rd   re   rI   rr   r   r|   r}   r~   r   r   r   r   rN   r   r	   r
   r   r   r   r   r   classmethodr   r   r    r   r   rV   rV      s        76I  X 	 	 X	   X' ' '(" " " "
 
 
 
&
9 
9 
9 
9< < < <,
 
 
 
1 1 1 1
	6 	6 	6 	6
 
 
 
   0	9 	9 	9 	9' ' 'A A AB B B
 
 

 
 

 
 
D D D D83 3 3 $ $ [$* . . [. . .r   rV   z$scheme authority path query fragmentc                   l    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dS )	SplitResultBytesr    s   
    (?:([A-Za-z][A-Za-z0-9+.-]*):)?  # scheme (RFC 3986 3.1)
    (?://([^/?#]*))?                 # authority
    ([^?#]*)                         # path
    (?:\?([^#]*))?                   # query
    (?:\#(.*))?                      # fragment
    flags)   :   /   ?rD      [   ]   @)   .s   ..)r      =
   0123456789NrP   rQ   rR   rT   recompileVERBOSEr   r`   ri   rj   rk   r   r   r[   r   r   rl   r   rb   r    r   r   r   r     sh        I 
	 j	
 	
 	
B95E5%x2 KCIE2FFFr   r   c                   l    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dS )	SplitResultStringr    z
    (?:([A-Za-z][A-Za-z0-9+.-]*):)?  # scheme (RFC 3986 3.1)
    (?://([^/?#]*))?                 # authority
    ([^?#]*)                         # path
    (?:\?([^#]*))?                   # query
    (?:\#(.*))?                      # fragment
    r   ):/?rE   []@).z..)r%   =
0123456789Nr   r    r   r   r   r     sh        I 
	 j	
 	
 	
B95E5%x2 KCIE2FFFr   r   c                     t          | t                    r|                     d          }n|                     d          }t          |d         |d         r|d         nd          S )zBRemove an existing fragment component from a URI reference string.rD   rE   r   r7   r8   N)r*   r   r   rB   )r0   r>   s     r   r   r     sa    )U## )##D))##C((aeAh"@%((DAAAr   c                     t          | t                    rt          }nt          } ||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   )r0   r?   s     r   r   r     sI     )U## #!"669??9--446677r   c                     | \  }}}}}t          |t                    rt          }nt          } ||||||                                          S )zdCombine the elements of a five-item iterable into a URI reference's
    string representation.

    )r*   r   r   r   rI   )r>   rm   rY   rn   ro   rF   r?   s          r   r   r   &  sV    
 05,FItUH$ #!"6&)T5(;;BBDDDr   Fc                    t          | t          |                    r5t          |                               ||                                          S t          | t
                    rGt          |                                                               ||                                          S t          |                               |                                |                                          S )zRConvert a URI reference relative to a base URI to its target URI
    string.

    )r*   r   r   r   rI   r   r=   )baser   r'   s      r   r   r   3  s    
 $S		"" G~~''V44;;===	D%	 	  G&&00f==DDFFF~~''

f==DDFFFr   c                 D    t          |                                           S )z-Return :const:`True` if `uristring` is a URI.)r   r   r0   s    r   r   r   @  s    I$$&&&r   c                 D    t          |                                           S )z7Return :const:`True` if `uristring` is an absolute URI.)r   r	   r   s    r   r	   r	   E  s    I'')))r   c                 D    t          |                                           S )z@Return :const:`True` if `uristring` is a network-path reference.)r   r
   r   s    r   r
   r
   J      I((***r   c                 D    t          |                                           S )zBReturn :const:`True` if `uristring` is an absolute-path reference.)r   r   r   s    r   r   r   O  r   r   c                 D    t          |                                           S )zAReturn :const:`True` if `uristring` is a relative-path reference.)r   r   r   s    r   r   r   T  r   r   c                 D    t          |                                           S )zAReturn :const:`True` if `uristring` is a same-document reference.)r   r   r   s    r   r   r   Y  r   r   s   ^[A-Za-z][A-Za-z0-9+.-]*$s   ^(?:(.*)@)?(.*?)(?::([0-9]*))?$z^(?:(.*)@)?(.*?)(?::([0-9]*))?$r   z:@/z:@/?c                 |    t                               |           r|                                 S t          d          )NzInvalid scheme component)
_SCHEME_REr   rq   r{   r   s    r   _schemer   o  s5     5||~~3444r   c                 R   g }| >|                     t          | t          |                     |                     d           t          |t          j                  r3|                     d|j                                        z   dz              nt          |t          j                  r-|                     |j                                                   not          |t                    r#|                     t          |                     n7|5|                     t          |                    d                               t          |t          j                  rB|                     t          t          |                                                               nnt          |t                    r#|                     t          |                     n6|4|                     t          |                                                     |rd                    |          nd S )Nr   r   r   r&   r   )r:   r   _SAFE_USERINFOr*   r   r   
compressedr   r   r   _hostnumbersNumber_portstrr-   )r\   rd   re   r2   rY   s        r   
_authorityr   v  s   I8^XFFGGG$	-.. 6 6 6 8 884?@@@@	D)/	0	0 6//112222	D%	 	  6t%%%%		t{{73344555$'' /s4yy//11223333	D%	 	  /t%%%%		t{{}}--..."+5388I5r   c                     |                      d          rt          d          dt          j        |           j                                        z   dz   S )Nr   zAddress mechanism not supportedr   r   )r   r{   r   r   r   r   )r   s    r   _ip_literalr     sR    # P:;;;i+G44?FFHHH4OOr   c                 ^   |                      d          r>|                     d          r)t          | dd                                                   S 	 t          |                     d                    S # t          $ r+ t          |                                 t          d          cY S w xY w)Nr   r   r7   r   r&   )r   r   r   r=   r{   r   rq   
_SAFE_HOST)rd   s    r   r   r     s    
 t 0t!4!4 04":,,..///<4;;w//000 < < <z7;;;;;<s   !A7 72B,+B,c                 \    |                      d          rt          d          | rd| z   S dS )Nr   zInvalid port subcomponentr   r   )ra   r{   )re   s    r   r   r     s>     {{=!! 4555	 d{sr   c           	         g }|j         }t                              |d          }| D ]\  }}t          |||          }| ||           $t	          |t
          t          f          r! ||dz   t          |||          z              a ||dz   t          t          |          ||          z              |                    d                              |          S )Nr%   r   r)   )	r:   _SAFE_QUERYreplacer   r*   r   r   r   r-   )	r   r   r2   termsr:   r1   keyr   r   s	            r   
_querylistr    s    E\FsB''D H H
UdH--=F4LLLLs|,, 	HF4$;5$!A!AABBBBF4$;3u::tX!F!FFGGGG::g##E***r   c                 v   g }|                                  D ]\  }t          |t          t          f          r|                    |f           9t          |t
          j        j                  r"|                    fd|D                        z|                    |f           t          |||          S )Nc                     g | ]}|fS r    r    )r   r   r  s     r   r   z_querydict.<locals>.<listcomp>  s    222q3(222r   )
r   r*   r   r   r:   rv   rw   rx   rh   r  )mappingr   r2   r   r   r  s        @r   
_querydictr
    s    Emmoo ' '
UeeS\** 	'LL#u&&&&{788 	'LL2222E2223333LL#u&&&&eS(+++r   r   c
                    t          | t                    rt          |           } n#| !t          |                                           } |d}nt          |t                    r-t                              |                                          }nt          |t                    r-t                              |                                          }nPt          |t          j
        j                  st          d          t          |          dk    rt          d          t          ||n|d         ||n|d         ||n|d         |	          }t!          |t"          |	          }|&|r$|                    d	          st          d
          |$|                    d          rt          d          | 9|7|                    d	          s"d|                    d	          d         v rd|z   }t          |t          t          f          rt!          |t(          |	          }nst          |t          j
        j                  rt-          |||	          }nBt          |t          j
        j                  rt/          |||	          }n|t          d          |t!          |t0          |	          }t3          | ||||f                                          S )z>Compose a URI reference string from its individual components.Nrt   zInvalid authority typeru   zInvalid authority lengthr   r7   r8   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_STRrv   rw   rx   ry   rz   r{   r   r   
_SAFE_PATHr   r   r  Mappingr
  r  _SAFE_FRAGMENTr   r=   )
rm   rY   rn   ro   rF   r\   rd   re   querysepr2   s
             r   r   r     s   . &%   *		)) &			Iu	%	% 5'--i88??AA			Is	#	# 5%++I66==??			;?#;<< 50111	Y1		3444(il il il	 I T:x00Ddood.C.C@AAAT__U33CDDD ~)+DOOD4I4I+4>>$''***4<D %%&& .%h77	E;?2	3	3 .5(H55	E;?3	4	4 .5(H55		,--- X~x@@ vy$x@AAHHJJJr   )r%   r&   r'   r   r   )
NNr%   NNNNNr   r&   )6rS   rv   collections.abcr   r   r   stringr   __all____version__r   r   r   r   	frozensetr   r   ranger+   r;   r   r   
namedtuplerB   rV   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    r   r   <module>r     s                 				      (  


" R  i
))++,,
  
 
MRUSVZZ
 
 
 4=  
9 9 9 9        "    );)..II   6~. ~. ~. ~. ~.K=*PQQ~. ~. ~.B
         {      F               FB B B8 8 8
E 
E 
E
G 
G 
G 
G' ' '
* * *
+ + +
+ + +
+ + +
+ + + RZ455
 !bj!CDD BJ@AA  c!
%
6!f$5 5 56 6 64P P P< < <	 	 	+ + +	, 	, 	, 	
		^K ^K ^K ^K ^K ^Kr   