HEX
Server: LiteSpeed
System: Linux ws4.angoweb.net 5.14.0-611.13.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 11 04:57:59 EST 2025 x86_64
User: tswangoe (2287)
PHP: 8.1.33
Disabled: show_source, system, shell_exec, passthru, exec, phpinfo, popen, proc_open
Upload Files
File: //lib/python3.9/site-packages/google/protobuf/__pycache__/json_format.cpython-39.pyc
a

x��g���@sdZdZzddlmZWney6ddlmZYn0ddlZddlZddlZddl	m
Z
ddlZddlZddl
Z
ddlmZddlmZddlmZd	Zeejjejjejjejjg�Zeejjejjg�Zeejjejjg�Zd
ZdZ dZ!e�"e
�#d
��Z$e�"d�Z%Gdd�de&�Z'Gdd�de'�Z(Gdd�de'�Z)d>dd�Z*d?dd�Z+dd�Z,Gdd�de-�Z.dd �Z/d!d"�Z0d#d$�Z1d@d%d&�Z2dAd'd(�Z3e
j4e5fZ6Gd)d*�d*e-�Z7dBd+d,�Z8d-d.�Z9d/d0�Z:d1d2�Z;d3d4gd5d6gd5d6gd7d8gd9d:gd5d6gd;d<gd=�Z<dS)CatContains routines for printing protocol messages in JSON format.

Simple usage example:

  # Create a proto object and serialize it to a json format string.
  message = my_proto_pb2.MyMessage(foo='bar')
  json_string = json_format.MessageToJson(message)

  # Parse a json format string to proto object.
  message = json_format.Parse(json_string, my_proto_pb2.MyMessage())
zjieluo@google.com (Jie Luo)�)�OrderedDictN)�methodcaller)�
type_checkers)�
descriptor)�symbol_databasez%Y-%m-%dT%H:%M:%SZInfinityz	-InfinityZNaNzF[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]z\[[a-zA-Z0-9\._]*\]$c@seZdZdZdS)�Errorz'Top-level module error for json_format.N��__name__�
__module__�__qualname__�__doc__�r
r
�?/usr/lib/python3.9/site-packages/google/protobuf/json_format.pyrXsrc@seZdZdZdS)�SerializeToJsonErrorz&Thrown if serialization to JSON fails.Nrr
r
r
rr\src@seZdZdZdS)�
ParseErrorz Thrown in case of parsing error.Nrr
r
r
rr`srF�c	Cs t|||||d�}|�|||�S)aRConverts protobuf message to JSON format.

  Args:
    message: The protocol buffers message instance to serialize.
    including_default_value_fields: If True, singular primitive fields,
        repeated fields, and map fields will always be serialized.  If
        False, only serialize non-empty fields.  Singular message fields
        and oneof fields are not affected by this option.
    preserving_proto_field_name: If True, use the original proto field
        names as defined in the .proto file. If False, convert the field
        names to lowerCamelCase.
    indent: The JSON object will be pretty-printed with this indent level.
        An indent level of 0 or negative will only insert newlines.
    sort_keys: If True, then the output will be sorted by field names.
    use_integers_for_enums: If true, print integers instead of enum names.
    descriptor_pool: A Descriptor Pool for resolving types. If None use the
        default.
    float_precision: If set, use this to specify float field valid digits.

  Returns:
    A string containing the JSON formatted protocol buffer message.
  ��float_precision)�_Printer�ToJsonString)	�message�including_default_value_fields�preserving_proto_field_name�indent�	sort_keys�use_integers_for_enums�descriptor_poolr�printerr
r
r�
MessageToJsonds�rcCst|||||d�}|�|�S)a�Converts protobuf message to a dictionary.

  When the dictionary is encoded to JSON, it conforms to proto3 JSON spec.

  Args:
    message: The protocol buffers message instance to serialize.
    including_default_value_fields: If True, singular primitive fields,
        repeated fields, and map fields will always be serialized.  If
        False, only serialize non-empty fields.  Singular message fields
        and oneof fields are not affected by this option.
    preserving_proto_field_name: If True, use the original proto field
        names as defined in the .proto file. If False, convert the field
        names to lowerCamelCase.
    use_integers_for_enums: If true, print integers instead of enum names.
    descriptor_pool: A Descriptor Pool for resolving types. If None use the
        default.
    float_precision: If set, use this to specify float field valid digits.

  Returns:
    A dict representation of the protocol buffer message.
  r)r�_MessageToJsonObject)rrrrrrrr
r
r�
MessageToDict�s�r cCs"|jtjjko |jjo |j��jS�N)�typer�FieldDescriptorZTYPE_MESSAGE�message_typeZhas_optionsZ
GetOptionsZ	map_entry)�fieldr
r
r�_IsMapEntry�s
�
�r&c@sjeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)rz)JSON format printer for protocol message.FNcCs4||_||_||_||_|r*d�|�|_nd|_dS)Nz.{}g)rrrr�format�float_format)�selfrrrrrr
r
r�__init__�sz_Printer.__init__cCs|�|�}tj|||d�S)N)rr)r�json�dumps)r)rrr�jsr
r
rr�s
z_Printer.ToJsonStringcCsL|j}|j}t|�r|�|�S|tvr<tt|d|�|�Si}|�||�S)zEConverts message to an object according to Proto3 JSON Specification.r)�
DESCRIPTOR�	full_name�_IsWrapperMessage�_WrapperMessageToJsonObject�_WKTJSONMETHODSr�_RegularMessageToJsonObject)r)r�message_descriptorr/r-r
r
rr�s
z_Printer._MessageToJsonObjectc
s�|��}�z�|D]�\�}�jr&�j}n�j}t��r��jjd}i}|D]6}t|t�rf|r`d}	qjd}	n|}	��	|||�||	<qH|||<q�j
tjj
kr���fdd�|D�||<q�jr�d�j}��	�|�||<q��	�|�||<q�j�r�|j}
|
jD]���j
tjj
k�r�jtjjks��j�r&q��j�r6�j}n�j}||v�rHq�t���r\i||<q��j
tjj
k�rvg||<q���	��j�||<q�Wn8t�y�}ztd��j|���WYd}~n
d}~00|S)	z?Converts normal message according to Proto3 JSON Specification.�value�true�falsecsg|]}���|��qSr
)�_FieldToJsonObject)�.0�k�r%r)r
r�
<listcomp>�s�z8_Printer._RegularMessageToJsonObject.<locals>.<listcomp>z[%s]z#Failed to serialize {0} field: {1}.N)�
ListFieldsr�name�	json_namer&r$�fields_by_name�
isinstance�boolr8�labelrr#�LABEL_REPEATED�is_extensionr/rr.�fields�cpp_type�CPPTYPE_MESSAGE�containing_oneofZ
default_value�
ValueErrorrr')r)rr-rFr5r>Zv_fieldZjs_map�keyZrecorded_keyr4�er
r;rr3�sf
�

�

��



�z$_Printer._RegularMessageToJsonObjectcCsB|jtjjkr|�|�S|jtjjkrx|jr0|S|jjdkr@dS|jj	�
|d�}|dur^|jS|jj
dkrn|Std��n�|jtjjkr�|jtjjkr�t�|��d�S|Sn�|jtjjkr�t|�S|jtvr�t|�S|jtv�r>t�|��r�|dk�r�tStSt�|��rtS|jtjj k�r>|j!�r4t"t#||j!��St$�%|�S|S)z<Converts field value according to Proto3 JSON Specification.�google.protobuf.NullValueN�proto3zKEnum field contains an integer value which can not mapped to an enum value.�utf-8g)&rGrr#rHr�CPPTYPE_ENUMr�	enum_typer/�values_by_number�getr>�file�syntaxr�CPPTYPE_STRINGr"�
TYPE_BYTES�base64Z	b64encode�decode�CPPTYPE_BOOLrB�_INT64_TYPES�str�_FLOAT_TYPES�math�isinf�
_NEG_INFINITY�	_INFINITY�isnan�_NAN�
CPPTYPE_FLOATr(�floatr'rZToShortestFloat)r)r%r5�
enum_valuer
r
rr8sB




z_Printer._FieldToJsonObjectcCs�|��siSt�}|j}||d<t||j�}|�|j�|j}|j}t	|�r^|�
|�|d<|S|tvr�tt|d|�|�|d<|S|�
||�S)z<Converts Any message according to Proto3 JSON Specification.�@typer5r)r=r�type_url�_CreateMessageFromTypeUrlrZParseFromStringr5r.r/r0r1r2rr3)r)rr-rh�sub_messager4r/r
r
r�_AnyMessageToJsonObjectEs(��z _Printer._AnyMessageToJsonObjectcCs|��S)z8Converts message according to Proto3 JSON Specification.)r�r)rr
r
r�_GenericMessageToJsonObjectZsz$_Printer._GenericMessageToJsonObjectcCsd|�d�}|dus|dkrdS|dkr2|�|j�S|dkrB|j}n
t||�}|jj|}|�||�S)z>Converts Value message according to Proto3 JSON Specification.�kindN�
null_value�
list_value�struct_value)Z
WhichOneof�_ListValueMessageToJsonObjectrprq�getattrr.r@r8)r)r�whichr5Zoneof_descriptorr
r
r�_ValueMessageToJsonObject`s

z"_Printer._ValueMessageToJsonObjectcs�fdd�|jD�S)zBConverts ListValue message according to Proto3 JSON Specification.csg|]}��|��qSr
)ru)r9r5�r)r
rr<rs�z:_Printer._ListValueMessageToJsonObject.<locals>.<listcomp>)�valuesrlr
rvrrrps
�z&_Printer._ListValueMessageToJsonObjectcCs*|j}i}|D]}|�||�||<q|S)z?Converts Struct message according to Proto3 JSON Specification.)rFru)r)rrF�retrKr
r
r�_StructMessageToJsonObjectus
z#_Printer._StructMessageToJsonObjectcCs|�|jjd|j�S)Nr5)r8r.r@r5rlr
r
rr1}s�z$_Printer._WrapperMessageToJsonObject)FFFNN)r	r
rrr*rrr3r8rkrmrurrryr1r
r
r
rr�s"�
@+rcCs|jjdkS)Nzgoogle/protobuf/wrappers.proto)rTr>)r4r
r
rr0�sr0cCs4i}|D]&\}}||vr&td�|���|||<q|S)Nz'Failed to load JSON: duplicate key {0}.)rr')r-�resultr>r5r
r
r�_DuplicateChecker�s
r{cCsht��}|dur|jn|}|�d�d}z|�|�}Wn tyVtd�|���Yn0|�|�}|�S)z"Creates a message from a type URL.N�/���z1Can not find message descriptor by type_url: {0}.)	rZDefault�pool�splitZFindMessageTypeByName�KeyError�	TypeErrorr'ZGetPrototype)rhrZdbr~�	type_namer4Z
message_classr
r
rri�s�

ric
Csnt|tj�s|�d�}ztj|td�}Wn6ty^}ztd�	t
|����WYd}~n
d}~00t||||�S)a�Parses a JSON representation of a protocol message into a message.

  Args:
    text: Message JSON representation.
    message: A protocol buffer message to merge into.
    ignore_unknown_fields: If True, do not raise errors for unknown fields.
    descriptor_pool: A Descriptor Pool for resolving types. If None use the
        default.

  Returns:
    The same message passed as argument.

  Raises::
    ParseError: On JSON parsing problems.
  rO)Zobject_pairs_hookzFailed to load JSON: {0}.N)rA�six�	text_typerYr+�loadsr{rJrr'r\�	ParseDict)�textr�ignore_unknown_fieldsrr-rLr
r
r�Parse�s(r�cCst||�}|�||�|S)a�Parses a JSON dictionary representation into a message.

  Args:
    js_dict: Dict representation of a JSON message.
    message: A protocol buffer message to merge into.
    ignore_unknown_fields: If True, do not raise errors for unknown fields.
    descriptor_pool: A Descriptor Pool for resolving types. If None use the
      default.

  Returns:
    The same message passed as argument.
  )�_Parser�ConvertMessage)Zjs_dictrr�r�parserr
r
rr��s
r�c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)r�z(JSON format parser for protocol message.cCs||_||_dSr!)r�r)r)r�rr
r
rr*�sz_Parser.__init__cCsT|j}|j}t|�r"|�||�n.|tvrDtt|d||�|�n|�||�dS)z�Convert a JSON object into a message.

    Args:
      value: A JSON object.
      message: A WKT or regular protocol message to record the data.

    Raises:
      ParseError: In case of convert problems.
    �N)r.r/r0�_ConvertWrapperMessager2r�_ConvertFieldValuePair)r)r5rr4r/r
r
rr��s
z_Parser.ConvertMessagecCs�g}|j}tdd�|jD��}|D�]�}�z�|�|d�}|sJ|j�|d�}|s�t�|�r�|jsntd�	|j
���|dd�}|j�|�}|s�d�
|�d�dd��}|j�|�}|s�|jr�Wq"td�	|j
|d	d
�|jD����||vr�td�	|jj
|���|�|�|jdu�r>|jj}	|	|v�r4td�	|jj
|	���|�|	�||}
|
du�r�|jtjjk�r�|jj
d
k�r�t||j�}d|_n:|jtjjk�r�|jj
dk�r�t||jd�n|�|j�Wq"t|��r�|�|j�|�|
||��n>|j tjj!k�r�|�|j�t"|
t#��s td�	||
���|jtjjk�rz|
D]B}t||j��$�}|du�rh|jj
d
k�rhtd��|�%||��q4n6|
D]0}|du�r�td��t||j��t&||���q~nt|jtjjk�r�|j'�r�|j|}nt||j�}|�(�|�%|
|�n.|j'�rt&|
|�|j|<nt||jt&|
|��Wq"t�y~}
z<|�r^|jdu�r^td�	||
���ntt)|
���WYd}
~
q"d}
~
0t*�y�}
ztd�	||
���WYd}
~
q"d}
~
0t+�y�}
ztd�	||
���WYd}
~
q"d}
~
00q"dS)z�Convert field value pairs into regular message.

    Args:
      js: A JSON object to convert the field value pairs.
      message: A regular protocol message to record the data.

    Raises:
      ParseError: In case of problems converting.
    css|]}|j|fVqdSr!�r?�r9�fr
r
r�	<genexpr>�s�z1_Parser._ConvertFieldValuePair.<locals>.<genexpr>Nz)Message type {0} does not have extensionsr�r}�.zVMessage type "{0}" has no field named "{1}".
 Available Fields(except extensions): {2}cSsg|]
}|j�qSr
r�r�r
r
rr<�z2_Parser._ConvertFieldValuePair.<locals>.<listcomp>z9Message type "{0}" should not have multiple "{1}" fields.z?Message type "{0}" should not have multiple "{1}" oneof fields.�google.protobuf.ValuerrMz.repeated field {0} must be in [] which is {1}.zAnull is not allowed to be used as an element in a repeated field.zFailed to parse {0} field: {1}.),r.�dictrFrSr@�_VALID_EXTENSION_NAME�matchZ
is_extendablerr'r/Z
ExtensionsZ_FindExtensionByName�joinrr��appendrIr>rGrr#rHr$rsrorPrQ�setattr�
ClearFieldr&�_ConvertMapFieldValuerCrDrA�list�addr��_ConvertScalarFieldValuerEZSetInParentr\rJr�)r)r-r�namesr4Zfields_by_json_namer>r%Z
identifierZ
oneof_namer5rj�itemrLr
r
rr��s�
�
����

�


�
�
�

�
�
 $z_Parser._ConvertFieldValuePaircCs�t|t�r|sdSz|d}Wnty8td��Yn0t||j�}|j}|j}t|�rl|�	|d|�n@|t
vr�tt
|d|d|�|�n|d=|�||�||d<|�
�|_||_dS)z/Convert a JSON representation into Any message.Nrgz*@type is missing when parsing any message.r5r�)rAr�r�rrirr.r/r0r�r2rr�ZSerializeToStringr5rh)r)r5rrhrjr4r/r
r
r�_ConvertAnyMessage]s,��
z_Parser._ConvertAnyMessagec
Cs@z|�|�Wn,ty:}zt|��WYd}~n
d}~00dS)z?Convert a JSON representation into message with FromJsonString.N)ZFromJsonStringrJr)r)r5rrLr
r
r�_ConvertGenericMessagevsz_Parser._ConvertGenericMessagecCs�t|t�r|�||j�nvt|t�r4|�||j�n\|durDd|_nLt|t�rV||_	n:t|t
j�rj||_n&t|t
�r|||_ntd�|t|����dS)z1Convert a JSON representation into Value message.Nrz"Value {0} has unexpected type {1}.)rAr��_ConvertStructMessagerqr��_ConvertListValueMessagerprorBZ
bool_valuer�Zstring_typesZstring_value�
_INT_OR_FLOATZnumber_valuerr'r")r)r5rr
r
r�_ConvertValueMessages



�z_Parser._ConvertValueMessagecCsBt|t�std�|���|�d�|D]}|�||j���q&dS)z5Convert a JSON representation into ListValue message.z%ListValue must be in [] which is {0}.rwN)rAr�rr'r�r�rwr�)r)r5rr�r
r
rr��s
�
z _Parser._ConvertListValueMessagecCsDt|t�std�|���|��|D]}|�|||j|�q$dS)z2Convert a JSON representation into Struct message.z&Struct must be in a dict which is {0}.N)rAr�rr'ZClearr�rF)r)r5rrKr
r
rr��s
�z_Parser._ConvertStructMessagecCs"|jjd}t|dt||��dS)z3Convert a JSON representation into Wrapper message.r5N)r.r@r�r�)r)r5rr%r
r
rr��sz_Parser._ConvertWrapperMessagecCs�t|t�std�|j|���|jjd}|jjd}|D]V}t||d�}|jt	j
jkrt|�||t
||j�|�q8t|||�t
||j�|<q8dS)a5Convert map field value for a message map field.

    Args:
      value: A JSON object to convert the map field value.
      message: A protocol message to record the converted data.
      field: The descriptor of the map field to be converted.

    Raises:
      ParseError: In case of convert problems.
    z-Map field {0} must be in a dict which is {1}.rKr5TN)rAr�rr'r>r$r@r�rGrr#rHr�rs)r)r5rr%Z	key_fieldZvalue_fieldrK�	key_valuer
r
rr��s&
�����z_Parser._ConvertMapFieldValueN)r	r
rrr*r�r�r�r�r�r�r�r�r�r
r
r
rr��sv		r�cCsZ|jtvrt|�S|jtvr&t||�S|jtjjkr>t||�S|jtjj	kr�|j
tjjkr�t|t
j�rr|�d�}n|}|ddt|�d}t�|�St�|�r�td��|Sn�|jtjjk�rV|jj�|d�}|du�rPzt|�}|jj�|d�}Wn(t�ytd�||jj���Yn0|du�rP|jj dk�r<|Std�||jj���|j!SdS)aBConvert a single scalar field value.

  Args:
    value: A scalar value to convert the scalar field value.
    field: The descriptor of the field to convert.
    require_str: If True, the field value must be a str.

  Returns:
    The converted scalar field value

  Raises:
    ParseError: In case of convert problems.
  rO�=�zUnpaired surrogateNz)Invalid enum value {0} for enum type {1}.rN)"rG�
_INT_TYPES�_ConvertIntegerr]�
_ConvertFloatrr#rZ�_ConvertBoolrVr"rWrAr�r��encode�lenrXZurlsafe_b64decode�_UNPAIRED_SURROGATE_PATTERN�searchrrPrQZvalues_by_namerS�intrRrJr'r/rTrU�number)r5r%�require_strZencodedZpadded_valuerfr�r
r
rr��sB






�
�r�cCsht|t�r |��s td�|���t|tj�rH|�d�dkrHtd�|���t|t�r`td�|���t	|�S)z�Convert an integer.

  Args:
    value: A scalar value to convert.

  Returns:
    The integer value.

  Raises:
    ParseError: If an integer couldn't be consumed.
  zCouldn't parse integer: {0}.� r}zCouldn't parse integer: "{0}".z3Bool value {0} is not acceptable for integer field.)
rAre�
is_integerrr'r�r��findrBr�)r5r
r
rr��s
�r�cCs�t|t�rrt�|�rtd��t�|�r@|dkr8td��ntd��|jtjj	krr|t
jkr`td��|t
jkrrtd��|dkr�td��z
t|�WSt
y�|tkr�td	�YS|tkr�td
�YS|tkr�td�YStd�|���Yn0dS)
z!Convert an floating point number.z-Couldn't parse NaN, use quoted "NaN" instead.rzJCouldn't parse Infinity or value too large, use quoted "Infinity" instead.zLCouldn't parse -Infinity or value too small, use quoted "-Infinity" instead.zFloat value too largezFloat value too small�nanz.Couldn't parse float "nan", use "NaN" instead.z-inf�infzCouldn't parse float: {0}.N)rArer^rbrr_rGrr#rdrZ
_FLOAT_MAXZ
_FLOAT_MINrJr`rarcr')r5r%r
r
rr�s0






r�cCs@|r*|dkrdS|dkrdStd�|���t|t�s<td��|S)z�Convert a boolean value.

  Args:
    value: A scalar value to convert.
    require_str: If True, value must be a str.

  Returns:
    The bool parsed.

  Raises:
    ParseError: If a boolean value couldn't be consumed.
  r6Tr7Fz$Expected "true" or "false", not {0}.z&Expected true or false without quotes.)rr'rArB)r5r�r
r
rr�9s

r�rkr�rmr�rrr�ryr�rur�)zgoogle.protobuf.Anyzgoogle.protobuf.Durationzgoogle.protobuf.FieldMaskzgoogle.protobuf.ListValuezgoogle.protobuf.Structzgoogle.protobuf.Timestampr�)FFrFFNN)FFFNN)FN)FN)F)=r�
__author__�collectionsr�ImportErrorZordereddictrXr+r^�operatorr�re�sysr�Zgoogle.protobuf.internalrZgoogle.protobufrrZ_TIMESTAMPFOMAT�	frozensetr#Z
CPPTYPE_INT32ZCPPTYPE_UINT32Z
CPPTYPE_INT64ZCPPTYPE_UINT64r�r[rdZCPPTYPE_DOUBLEr]rar`rc�compile�ur�r��	Exceptionrrrrr r&�objectrr0r{rir�r�Z
integer_typesrer�r�r�r�r�r�r2r
r
r
r�<module>s�����
�
*�
&K	
�
z
6$��������