
    01i                         S r SSKrSSKJr  SSKJr  S rS rS rS	 rS
 r	S r
S rS r\R                  " S5      rS rS rS rg)z.Module with functions to normalize components.    N   )compat)miscc                 "    U R                  5       $ )zNormalize the scheme component.)lower)schemes    M/home/james-whalen/.local/lib/python3.13/site-packages/rfc3986/normalizers.pynormalize_schemer
      s    <<>    c                     U u  pnSnU(       a  U[        U5      S-   -  nU(       a  U[        U5      -  nU(       a  USU-   -  nU$ )z)Normalize an authority tuple to a string. @:)normalize_percent_charactersnormalize_host)	authorityuserinfohostportresults        r	   normalize_authorityr      sQ    $HDF.x83>>.&&#*Mr   c                 .    [         R                  " U 5      $ )z<Normalize a username to make it safe to include in userinfo.r   urlquote)usernames    r	   normalize_usernamer   (       ??8$$r   c                 .    [         R                  " U 5      $ )z/Normalize a password to make safe for userinfo.r   )passwords    r	   normalize_passwordr    -   r   r   c                 T   [         R                  R                  U 5      (       au  U R                  S5      nUS:w  a^  U R                  S5      nUS:X  d  X:  d  X:X  a%  U[	        U 5      S-
  :X  a  U R                  SSS5      n U SU R                  5       XS -   $ U R                  5       $ )zNormalize a host string.%z%25   r   N)r   IPv6_MATCHERmatchfindlenreplacer   )r   percent
percent_25s      r	   r   r   2   s    t$$))C.b=5)J b ')jCIM.I||C2 >'')DN::::<r   c                 @    U (       d  U $ [        U 5      n [        U 5      $ )zNormalize the path string.)r   remove_dot_segments)paths    r	   normalize_pathr/   I   s    '-Dt$$r   c                 *    U (       d  U $ [        U 5      $ )zNormalize the query string.r   )querys    r	   normalize_queryr3   R   s    '..r   c                 *    U (       d  U $ [        U 5      $ )zNormalize the fragment string.r1   )fragments    r	   normalize_fragmentr6   Y   s    '11r   z%[A-Fa-f0-9]{2}c                     [        [        R                  U 5      5      nU H9  nUR                  5       (       a  M  U R	                  X"R                  5       5      n M;     U $ )zyAll percent characters should be upper-cased.

For example, ``"%3afoo%DF%ab"`` should be turned into ``"%3Afoo%DF%AB"``.
)setPERCENT_MATCHERfindallisupperr)   upper)smatchesms      r	   r   r   c   sI    
 /))!,-Gyy{{		!WWY'A  Hr   c                    U R                  S5      n/ nU H=  nUS:X  a  M  US:w  a  UR                  U5        M$  U(       d  M-  UR                  5         M?     U R                  S5      (       a#  U(       a
  US   (       a  UR	                  SS5        U R                  S5      (       a  UR                  S5        SR                  U5      $ )zMRemove dot segments from the string.

See also Section 5.2.4 of :rfc:`3986`.
/.z..r   r   )z/.z/..)splitappendpop
startswithinsertendswithjoin)r=   segmentsoutputsegments       r	   r-   r-   o   s     wws|HFc>_MM'" VJJL  	||C&F1Ia 	zz-  b88Fr   c                 \   U c  U $ [        [        R                  [        R                  " X5      5      5      n[        R
                  " X5      nX#R                  S5      :H  n[        5       n[        S[        U5      5       H  nX6US-    n[        U5      nU(       a  US:X  d(  US:  a5  UR                  5       [        R                  ;   a  UR                  U5        M]  UR                  SR                  U5      R                  5       R!                  5       5        M     UR                  U5      $ )z7Encode the specific component in the provided encoding.   %r   r      z%{0:02x})r(   r9   r:   r   to_strto_bytescount	bytearrayrangeorddecoder   NON_PCT_ENCODEDextendformatencoder<   )	uri_componentencodingpercent_encodings	uri_bytesis_percent_encodedencoded_uriibytebyte_ords	            r	   encode_componentrd      s     m FG 8I*ood.CC+K1c)n%QU#t944<sNt{{}0D0DDt$:,,X6==?EEGH & h''r   )__doc__rer   r   r   r
   r   r   r    r   r/   r3   r6   compiler9   r   r-   rd    r   r	   <module>ri      s\    5 	  

%
%
.%/2 **./	D(r   