U
    S³d]  ã                   @   sô   d Z ddlZi Zded< ded< ded< d	ed
< ded< ded< dd„ eddƒD ƒZe ¡ D ]\ZZeee< q\dd„ eddƒD ƒdd„ eddƒD ƒ dd„ eddƒD ƒ Ze ¡ D ]\ZZeee< q²[[e	dœdd„Z
e d¡Ze	edœdd„ZdS )zEncoding related utilities.é    Nz\té	   z\né
   z\ré   z\"é"   z\'é'   z\\é\   c                 C   s   g | ]}t |ƒ‘qS © ©Úchr©Ú.0Úir   r   úA/tmp/pip-unpacked-wheel-1ori_g8k/google/protobuf/text_encoding.pyÚ
<listcomp>+   s     r   é   c                 C   s   g | ]}d | ‘qS ©z\%03or   r   r   r   r   r   0   s     é    c                 C   s   g | ]}t |ƒ‘qS r   r	   r   r   r   r   r   1   s     é   c                 C   s   g | ]}d | ‘qS r   r   r   r   r   r   r   2   s     )Úreturnc                    s`   t | tƒ}|r|r|  t¡S |r$tndd„ ‰ |rHd ‡ fdd„| D ƒ¡S d ‡ fdd„| D ƒ¡S )am  Escape a bytes string for use in an text protocol buffer.

  Args:
    text: A byte string to be escaped.
    as_utf8: Specifies if result may contain non-ASCII characters.
        In Python 3 this allows unescaped non-ASCII Unicode characters.
        In Python 2 the return value will be valid UTF-8 rather than only ASCII.
  Returns:
    Escaped string (str).
  c                 S   s   | S ©Nr   )Úxr   r   r   Ú<lambda>L   ó    zCEscape.<locals>.<lambda>Ú c                 3   s   | ]}t ˆ |ƒ V  qd S r   )Ú_cescape_unicode_to_str©r   Úc©Zord_r   r   Ú	<genexpr>N   s     zCEscape.<locals>.<genexpr>c                 3   s   | ]}t ˆ |ƒ V  qd S r   )Ú_cescape_byte_to_strr   r   r   r   r   O   s     )Ú
isinstanceÚstrÚ	translateÚ_cescape_chr_to_symbol_mapÚordÚjoin)ÚtextZas_utf8Ztext_is_unicoder   r   r   ÚCEscape8   s    

r'   z"(\\+)x([0-9a-fA-F])(?![0-9a-fA-F]))r&   r   c                 C   s*   dd„ }t  || ¡}| d¡ d¡ d¡S )z”Unescape a text string with C-style escape sequences to UTF-8 bytes.

  Args:
    text: The data to parse in a str.
  Returns:
    A byte string.
  c                 S   s4   t |  d¡ƒd@ r*|  d¡d |  d¡ S |  d¡S )Né   Zx0é   r   )ÚlenÚgroup)Úmr   r   r   Ú
ReplaceHex^   s    zCUnescape.<locals>.ReplaceHexzutf-8Zunicode_escapeZraw_unicode_escape)Ú_CUNESCAPE_HEXÚsubÚencodeÚdecode)r&   r-   Úresultr   r   r   Ú	CUnescapeU   s    		
ÿýr3   )Ú__doc__Úrer#   Úranger   ÚitemsÚbyteÚstringr   r!   r'   Úcompiler.   Úbytesr3   r   r   r   r   Ú<module>   s,   
ÿþ

