o
    {j6h%                     @   s   d Z ddlZdd Zdd Ze Zdd edd	D Zee ed
d edd	D  dd Zde	fddZ
edZde	defddZdS )zEncoding related utilities.    Nc                 C   s   | dko| dk S )N        )ir   r   l/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/google/protobuf/text_encoding.py_AsciiIsPrint   s   r   c                  C   st   i } t ddD ]}t|sd| | |< qd| td< d| td< d| td	< d
| td< d| td< d| td< | S )Nr      \%03oz\t	z\n
z\rz\""z\''z\\\)ranger   ord)retr   r   r   r   _MakeStrEscapes   s   r   c                 C   s   i | ]}|t |qS r   )chr.0r   r   r   r   
<dictcomp>       r      c                 C   s   i | ]}|d | qS )r	   r   r   r   r   r   r   !   r   r   c              
   C   s   d}| rHz||  dt7 }d} W n3 tyE } z'|| d |j  dt7 }|t| |j  7 }| |jd d  } W Y d }~nd }~ww | s|S )N utf-8   )decode	translate_str_escapesUnicodeDecodeErrorstart_byte_escapes)
text_bytesr   er   r   r   _DecodeUtf8EscapeErrors$   s   r%   returnc                 C   sF   t | t}|r|r| tS t| S |r| d} d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).
  r   r   c                 S   s   g | ]}t | qS r   )r"   )r   cr   r   r   
<listcomp>J   s    zCEscape.<locals>.<listcomp>)
isinstancestrr   r   r%   encodejoin)textas_utf8text_is_unicoder   r   r   CEscape1   s   


r0   z"(\\+)x([0-9a-fA-F])(?![0-9a-fA-F])r-   c                 C   s>   dd }t || }|dd}|dd}|dS )zUnescape 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 )Nr   x0   r   )lengroup)mr   r   r   
ReplaceHexY   s   
zCUnescape.<locals>.ReplaceHexraw_unicode_escaper   unicode_escapezlatin-1)_CUNESCAPE_HEXsubr+   r   )r-   r6   resultr   r   r   	CUnescapeP   s
   		
r<   )__doc__rer   r   r   r   r"   updater%   r*   r0   compiler9   bytesr<   r   r   r   r   <module>   s   

