
    =f              	           d Z ddlZddlmZmZmZ i Z G d de          Zdde	d	e	d
e	de	fdZ
dde	d	e	d
e	de	fdZe
Zde	dee	         fdZde	d	e	d
e	de	fdZdS )u  Transliterate Unicode text into plain 7-bit ASCII.

Example usage:

>>> from unidecode import unidecode
>>> unidecode("北亰")
"Bei Jing "

The transliteration uses a straightforward map, and doesn't have alternatives
for the same character based on language, position, or anything else.

A standard string object will be returned. If you need bytes, use:

>>> unidecode("Κνωσός").encode("ascii")
b'Knosos'
    N)DictOptionalSequencec                   :     e Zd Zddedee         ddf fdZ xZS )UnidecodeErrorNmessageindexreturnc                 f    t          t          |                               |           || _        dS )zRaised for Unidecode-related errors.

        The index attribute contains the index of the character that caused
        the error.
        N)superr   __init__r	   )selfr   r	   	__class__s      D/var/www/html/env/lib/python3.11/site-packages/unidecode/__init__.pyr   zUnidecodeError.__init__   s.     	nd##,,W555


    )N)__name__
__module____qualname__strr   intr   __classcell__)r   s   @r   r   r      s[          HSM T          r   r   ignore?stringerrorsreplace_strr
   c                 t    	 |                      d          }| S # t          $ r Y nw xY wt          | ||          S )u_  Transliterate an Unicode object into an ASCII string

    >>> unidecode("北亰")
    "Bei Jing "

    This function first tries to convert the string using ASCII codec.
    If it fails (because of non-ASCII characters), it falls back to
    transliteration using the character tables.

    This is approx. five times faster if the string only contains ASCII
    characters, but slightly slower than unicode_expect_nonascii if
    non-ASCII characters are present.

    errors specifies what to do with characters that have not been
    found in replacement tables. The default is 'ignore' which ignores
    the character. 'strict' raises an UnidecodeError. 'replace'
    substitutes the character with replace_str (default is '?').
    'preserve' keeps the original character.

    Note that if 'preserve' is used the returned string might not be
    ASCII!
    ASCII)encodeUnicodeEncodeError
_unidecode)r   r   r   
bytestrings       r   unidecode_expect_asciir#   #   sU    0]]7++
     
 ffk222s    
&&c                 $    t          | ||          S )u   Transliterate an Unicode object into an ASCII string

    >>> unidecode("北亰")
    "Bei Jing "

    See unidecode_expect_ascii.
    )r!   )r   r   r   s      r   unidecode_expect_nonasciir%   D   s     ffk222r   charc                    t          |           }|dk     rt          |           S |dk    rd S d|cxk    rdk    r"n nt          j        d| dt          d           |dz	  }|d	z  }	 t
          |         }nm# t          $ r` 	 t          d
|z  t                      t                      dg          }n# t          $ r d t
          |<   Y Y d S w xY w|j        xt
          |<   }Y nw xY w|rt          |          |k    r||         S d S )N   i i   i  zSurrogate character z; will be ignored. You might be using a narrow Python build.         zunidecode.x%03xdata)ordr   warningswarnRuntimeWarningCacheKeyError
__import__globalslocalsImportErrorr,   len)r&   	codepointsectionpositiontablemods         r   _get_repl_strr=   Q   sT   D		I44yy7t$$$$f$$$$$GKttN&	+ 	+ 	+ 1nG3H
*g * * *	.8'))VXXPVxXXCC 	 	 	!E'N444	
 "%)g*  Uh&&Xts6   'A5 5
C .B/.C/CCCCCc                 6   g }t          |           D ]s\  }}t          |          }|H|dk    rd}n?|dk    rt          d||fz  |          |dk    r|}n|dk    r|}nt          d|          |                    |           td                    |          S )Nr    strictz4no replacement found for character %r in position %dreplacepreservez#invalid value for errors parameter )	enumerater=   r   appendjoin)r   r   r   retvalr	   r&   repls          r   r!   r!   u   s    F ((  tT""<!!8##$ &),0%=&9:?A A A9$$":%%$nPVPV%XYYYd776??r   )r   r   )__doc__r.   typingr   r   r   r1   
ValueErrorr   r   r#   r%   	unidecoder=   r!    r   r   <module>rM      s=      + + + + + + + + + +
    Z   3 33 3 3S 3[^ 3 3 3 3B	3 	3c 	33 	3PS 	3^a 	3 	3 	3 	3 #	" " " " " "Hs C S S      r   