
    }Wh                         d Z ddlZddlmZ ddlmZ d Zd Zd Zd	 Zd
 Z	d Z
d Zd Z ej        d          Zd Zd Zd ZdS )z.Module with functions to normalize components.    N   )compat)miscc                 *    |                                  S )zNormalize the scheme component.)lower)schemes    Y/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/rfc3986/normalizers.pynormalize_schemer
      s    <<>>    c                     | \  }}}d}|r|t          |          dz   z  }|r|t          |          z  }|r|d|z   z  }|S )z)Normalize an authority tuple to a string. @:)normalize_percent_charactersnormalize_host)	authorityuserinfohostportresults        r	   normalize_authorityr      sh    $HdDF ?.x883>> '.&&& #*Mr   c                 *    t          j        |           S )z<Normalize a username to make it safe to include in userinfo.r   urlquote)usernames    r	   normalize_usernamer   (       ?8$$$r   c                 *    t          j        |           S )z/Normalize a password to make safe for userinfo.r   )passwords    r	   normalize_passwordr    -   r   r   c                    t           j                            |           r|                     d          }|dk    r{|                     d          }|dk    s"||k     s||k    r-|t	          |           dz
  k    r|                     ddd          } | d|                                         | |d         z   S |                                 S )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  Z''z))jCIIM.I.I||C22 >''))DN::::<<r   c                 F    | s| S t          |           } t          |           S )zNormalize the path string.)r   remove_dot_segments)paths    r	   normalize_pathr/   I   s*     '--Dt$$$r   c                 (    | s| S t          |           S )zNormalize the query string.r   )querys    r	   normalize_queryr3   R   s     '...r   c                 (    | s| S t          |           S )zNormalize the fragment string.r1   )fragments    r	   normalize_fragmentr6   Y   s     '111r   z%[A-Fa-f0-9]{2}c                     t          t                              |                     }|D ]>}|                                s(|                     ||                                          } ?| S )zAll 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   s_    
 /))!,,--G ( (yy{{ 	(		!QWWYY''AHr   c                    |                      d          }g }|D ];}|dk    r	|dk    r|                    |           %|r|                                 <|                     d          r |r|d         r|                    dd           |                     d          r|                    d           d                    |          S )zURemove 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'""""  	JJLLL 	||C & F1I a 	zz-   b88Fr   c                    | | S t          t                              t          j        | |                              }t          j        | |          }||                    d          k    }t                      }t          dt          |                    D ]}|||dz            }t          |          }|r|dk    s&|dk     r6|
                                t          j        v r|                    |           b|                    d                    |                                                                                     |
                    |          S )z7Encode the specific component in the provided encoding.N   %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      sD    mX F FGG  x88I*iood.C.CC++K1c)nn%% 	I 	IQU#t99 	44<<sNNt{{}}0DDDt$$$:,,X66==??EEGGHHH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 4 				              

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