B @`@sdZddlZddlZiZded<ded<ded<d ed <d ed <d ed<ddeddDZxeD]\ZZeee<qfWddeddDddeddDddeddDZ xeD]\ZZee e<qW[[ddZ e dZ ddZ dS)zEncoding related utilities.Nz\t z\n z\r z\""z\''z\\\cCsg|] }t|qS)chr).0irrA/tmp/pip-unpacked-wheel-3chbcimp/google/protobuf/text_encoding.py -sr cCsg|] }d|qS)z\%03or)r r rrr r 2s cCsg|] }t|qSr)r )r r rrr r 3scCsg|] }d|qS)z\%03or)r r rrr r 4scsltjr4t|t}|r"|r"|tS|r*tnddnt|rTdfdd|DSdfdd|DS)amEscape 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). cSs|S)Nr)xrrr PzCEscape..c3s|]}t|VqdS)N)_cescape_unicode_to_str)r c)ord_rr TszCEscape..c3s|]}t|VqdS)N)_cescape_byte_to_str)r r)rrr rUs)sixPY3 isinstancestr translate_cescape_chr_to_symbol_mapordjoin)textZas_utf8Ztext_is_unicoder)rr CEscape:s  r#z"(\\+)x([0-9a-fA-F])(?![0-9a-fA-F])cCs:dd}t||}tjr$|dS|dddS)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. cSs4t|dd@r*|dd|dS|dS)NZx0r)lengroup)mrrr ReplaceHexeszCUnescape..ReplaceHexZ string_escapezutf-8Zunicode_escapeZraw_unicode_escape)_CUNESCAPE_HEXsubrPY2decodeencode)r"r)resultrrr CUnescape[s    r0)__doc__rerrrangeritemsbytestringrr#compiler*r0rrrr s( &