new mcp servers format
This commit is contained in:
34
.venv/lib/python3.10/site-packages/google/protobuf/json_format.py
Executable file → Normal file
34
.venv/lib/python3.10/site-packages/google/protobuf/json_format.py
Executable file → Normal file
@@ -497,7 +497,6 @@ def ParseDict(
|
||||
|
||||
|
||||
_INT_OR_FLOAT = (int, float)
|
||||
_LIST_LIKE = (list, tuple)
|
||||
|
||||
|
||||
class _Parser(object):
|
||||
@@ -639,7 +638,7 @@ class _Parser(object):
|
||||
)
|
||||
elif field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
|
||||
message.ClearField(field.name)
|
||||
if not isinstance(value, _LIST_LIKE):
|
||||
if not isinstance(value, list):
|
||||
raise ParseError(
|
||||
'repeated field {0} must be in [] which is {1} at {2}'.format(
|
||||
name, value, path
|
||||
@@ -734,10 +733,8 @@ class _Parser(object):
|
||||
)(self)
|
||||
else:
|
||||
del value['@type']
|
||||
try:
|
||||
self._ConvertFieldValuePair(value, sub_message, path)
|
||||
finally:
|
||||
value['@type'] = type_url
|
||||
self._ConvertFieldValuePair(value, sub_message, path)
|
||||
value['@type'] = type_url
|
||||
# Sets Any message
|
||||
message.value = sub_message.SerializeToString()
|
||||
message.type_url = type_url
|
||||
@@ -755,8 +752,8 @@ class _Parser(object):
|
||||
"""Convert a JSON representation into Value message."""
|
||||
if isinstance(value, dict):
|
||||
self._ConvertStructMessage(value, message.struct_value, path)
|
||||
elif isinstance(value, _LIST_LIKE):
|
||||
self._ConvertListOrTupleValueMessage(value, message.list_value, path)
|
||||
elif isinstance(value, list):
|
||||
self._ConvertListValueMessage(value, message.list_value, path)
|
||||
elif value is None:
|
||||
message.null_value = 0
|
||||
elif isinstance(value, bool):
|
||||
@@ -772,9 +769,9 @@ class _Parser(object):
|
||||
)
|
||||
)
|
||||
|
||||
def _ConvertListOrTupleValueMessage(self, value, message, path):
|
||||
def _ConvertListValueMessage(self, value, message, path):
|
||||
"""Convert a JSON representation into ListValue message."""
|
||||
if not isinstance(value, _LIST_LIKE):
|
||||
if not isinstance(value, list):
|
||||
raise ParseError(
|
||||
'ListValue must be in [] which is {0} at {1}'.format(value, path)
|
||||
)
|
||||
@@ -974,20 +971,7 @@ def _ConvertInteger(value):
|
||||
'Bool value {0} is not acceptable for integer field'.format(value)
|
||||
)
|
||||
|
||||
try:
|
||||
return int(value)
|
||||
except ValueError as e:
|
||||
# Attempt to parse as an integer-valued float.
|
||||
try:
|
||||
f = float(value)
|
||||
except ValueError:
|
||||
# Raise the original exception for the int parse.
|
||||
raise e # pylint: disable=raise-missing-from
|
||||
if not f.is_integer():
|
||||
raise ParseError(
|
||||
'Couldn\'t parse non-integer string: "{0}"'.format(value)
|
||||
) from e
|
||||
return int(f)
|
||||
return int(value)
|
||||
|
||||
|
||||
def _ConvertFloat(value, field):
|
||||
@@ -1068,7 +1052,7 @@ _WKTJSONMETHODS = {
|
||||
],
|
||||
'google.protobuf.ListValue': [
|
||||
'_ListValueMessageToJsonObject',
|
||||
'_ConvertListOrTupleValueMessage',
|
||||
'_ConvertListValueMessage',
|
||||
],
|
||||
'google.protobuf.Struct': [
|
||||
'_StructMessageToJsonObject',
|
||||
|
||||
Reference in New Issue
Block a user