new mcp servers format
This commit is contained in:
2
.venv/lib/python3.10/site-packages/google/protobuf/__init__.py
Executable file → Normal file
2
.venv/lib/python3.10/site-packages/google/protobuf/__init__.py
Executable file → Normal file
@@ -7,4 +7,4 @@
|
||||
|
||||
# Copyright 2007 Google Inc. All Rights Reserved.
|
||||
|
||||
__version__ = '6.30.2'
|
||||
__version__ = '5.29.4'
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0
.venv/lib/python3.10/site-packages/google/protobuf/any.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/any.py
Executable file → Normal file
8
.venv/lib/python3.10/site-packages/google/protobuf/any_pb2.py
Executable file → Normal file
8
.venv/lib/python3.10/site-packages/google/protobuf/any_pb2.py
Executable file → Normal file
@@ -2,7 +2,7 @@
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# NO CHECKED-IN PROTOBUF GENCODE
|
||||
# source: google/protobuf/any.proto
|
||||
# Protobuf Python Version: 6.30.2
|
||||
# Protobuf Python Version: 5.29.4
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
@@ -11,9 +11,9 @@ from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf.internal import builder as _builder
|
||||
_runtime_version.ValidateProtobufRuntimeVersion(
|
||||
_runtime_version.Domain.PUBLIC,
|
||||
6,
|
||||
30,
|
||||
2,
|
||||
5,
|
||||
29,
|
||||
4,
|
||||
'',
|
||||
'google/protobuf/any.proto'
|
||||
)
|
||||
|
||||
8
.venv/lib/python3.10/site-packages/google/protobuf/api_pb2.py
Executable file → Normal file
8
.venv/lib/python3.10/site-packages/google/protobuf/api_pb2.py
Executable file → Normal file
@@ -2,7 +2,7 @@
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# NO CHECKED-IN PROTOBUF GENCODE
|
||||
# source: google/protobuf/api.proto
|
||||
# Protobuf Python Version: 6.30.2
|
||||
# Protobuf Python Version: 5.29.4
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
@@ -11,9 +11,9 @@ from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf.internal import builder as _builder
|
||||
_runtime_version.ValidateProtobufRuntimeVersion(
|
||||
_runtime_version.Domain.PUBLIC,
|
||||
6,
|
||||
30,
|
||||
2,
|
||||
5,
|
||||
29,
|
||||
4,
|
||||
'',
|
||||
'google/protobuf/api.proto'
|
||||
)
|
||||
|
||||
0
.venv/lib/python3.10/site-packages/google/protobuf/compiler/__init__.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/compiler/__init__.py
Executable file → Normal file
Binary file not shown.
Binary file not shown.
8
.venv/lib/python3.10/site-packages/google/protobuf/compiler/plugin_pb2.py
Executable file → Normal file
8
.venv/lib/python3.10/site-packages/google/protobuf/compiler/plugin_pb2.py
Executable file → Normal file
@@ -2,7 +2,7 @@
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# NO CHECKED-IN PROTOBUF GENCODE
|
||||
# source: google/protobuf/compiler/plugin.proto
|
||||
# Protobuf Python Version: 6.30.2
|
||||
# Protobuf Python Version: 5.29.4
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
@@ -11,9 +11,9 @@ from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf.internal import builder as _builder
|
||||
_runtime_version.ValidateProtobufRuntimeVersion(
|
||||
_runtime_version.Domain.PUBLIC,
|
||||
6,
|
||||
30,
|
||||
2,
|
||||
5,
|
||||
29,
|
||||
4,
|
||||
'',
|
||||
'google/protobuf/compiler/plugin.proto'
|
||||
)
|
||||
|
||||
0
.venv/lib/python3.10/site-packages/google/protobuf/descriptor.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/descriptor.py
Executable file → Normal file
26
.venv/lib/python3.10/site-packages/google/protobuf/descriptor_database.py
Executable file → Normal file
26
.venv/lib/python3.10/site-packages/google/protobuf/descriptor_database.py
Executable file → Normal file
@@ -52,24 +52,14 @@ class DescriptorDatabase(object):
|
||||
for name in _ExtractSymbols(message, package):
|
||||
self._AddSymbol(name, file_desc_proto)
|
||||
for enum in file_desc_proto.enum_type:
|
||||
self._AddSymbol(
|
||||
('.'.join((package, enum.name)) if package else enum.name),
|
||||
file_desc_proto,
|
||||
)
|
||||
self._AddSymbol(('.'.join((package, enum.name))), file_desc_proto)
|
||||
for enum_value in enum.value:
|
||||
self._file_desc_protos_by_symbol[
|
||||
'.'.join((package, enum_value.name)) if package else enum_value.name
|
||||
] = file_desc_proto
|
||||
'.'.join((package, enum_value.name))] = file_desc_proto
|
||||
for extension in file_desc_proto.extension:
|
||||
self._AddSymbol(
|
||||
('.'.join((package, extension.name)) if package else extension.name),
|
||||
file_desc_proto,
|
||||
)
|
||||
self._AddSymbol(('.'.join((package, extension.name))), file_desc_proto)
|
||||
for service in file_desc_proto.service:
|
||||
self._AddSymbol(
|
||||
('.'.join((package, service.name)) if package else service.name),
|
||||
file_desc_proto,
|
||||
)
|
||||
self._AddSymbol(('.'.join((package, service.name))), file_desc_proto)
|
||||
|
||||
def FindFileByName(self, name):
|
||||
"""Finds the file descriptor proto by file name.
|
||||
@@ -112,14 +102,6 @@ class DescriptorDatabase(object):
|
||||
Raises:
|
||||
KeyError if no file contains the specified symbol.
|
||||
"""
|
||||
if symbol.count('.') == 1 and symbol[0] == '.':
|
||||
symbol = symbol.lstrip('.')
|
||||
warnings.warn(
|
||||
'Please remove the leading "." when '
|
||||
'FindFileContainingSymbol, this will turn to error '
|
||||
'in 2026 Jan.',
|
||||
RuntimeWarning,
|
||||
)
|
||||
try:
|
||||
return self._file_desc_protos_by_symbol[symbol]
|
||||
except KeyError:
|
||||
|
||||
117
.venv/lib/python3.10/site-packages/google/protobuf/descriptor_pb2.py
Executable file → Normal file
117
.venv/lib/python3.10/site-packages/google/protobuf/descriptor_pb2.py
Executable file → Normal file
File diff suppressed because one or more lines are too long
0
.venv/lib/python3.10/site-packages/google/protobuf/descriptor_pool.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/descriptor_pool.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/duration.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/duration.py
Executable file → Normal file
8
.venv/lib/python3.10/site-packages/google/protobuf/duration_pb2.py
Executable file → Normal file
8
.venv/lib/python3.10/site-packages/google/protobuf/duration_pb2.py
Executable file → Normal file
@@ -2,7 +2,7 @@
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# NO CHECKED-IN PROTOBUF GENCODE
|
||||
# source: google/protobuf/duration.proto
|
||||
# Protobuf Python Version: 6.30.2
|
||||
# Protobuf Python Version: 5.29.4
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
@@ -11,9 +11,9 @@ from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf.internal import builder as _builder
|
||||
_runtime_version.ValidateProtobufRuntimeVersion(
|
||||
_runtime_version.Domain.PUBLIC,
|
||||
6,
|
||||
30,
|
||||
2,
|
||||
5,
|
||||
29,
|
||||
4,
|
||||
'',
|
||||
'google/protobuf/duration.proto'
|
||||
)
|
||||
|
||||
8
.venv/lib/python3.10/site-packages/google/protobuf/empty_pb2.py
Executable file → Normal file
8
.venv/lib/python3.10/site-packages/google/protobuf/empty_pb2.py
Executable file → Normal file
@@ -2,7 +2,7 @@
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# NO CHECKED-IN PROTOBUF GENCODE
|
||||
# source: google/protobuf/empty.proto
|
||||
# Protobuf Python Version: 6.30.2
|
||||
# Protobuf Python Version: 5.29.4
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
@@ -11,9 +11,9 @@ from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf.internal import builder as _builder
|
||||
_runtime_version.ValidateProtobufRuntimeVersion(
|
||||
_runtime_version.Domain.PUBLIC,
|
||||
6,
|
||||
30,
|
||||
2,
|
||||
5,
|
||||
29,
|
||||
4,
|
||||
'',
|
||||
'google/protobuf/empty.proto'
|
||||
)
|
||||
|
||||
8
.venv/lib/python3.10/site-packages/google/protobuf/field_mask_pb2.py
Executable file → Normal file
8
.venv/lib/python3.10/site-packages/google/protobuf/field_mask_pb2.py
Executable file → Normal file
@@ -2,7 +2,7 @@
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# NO CHECKED-IN PROTOBUF GENCODE
|
||||
# source: google/protobuf/field_mask.proto
|
||||
# Protobuf Python Version: 6.30.2
|
||||
# Protobuf Python Version: 5.29.4
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
@@ -11,9 +11,9 @@ from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf.internal import builder as _builder
|
||||
_runtime_version.ValidateProtobufRuntimeVersion(
|
||||
_runtime_version.Domain.PUBLIC,
|
||||
6,
|
||||
30,
|
||||
2,
|
||||
5,
|
||||
29,
|
||||
4,
|
||||
'',
|
||||
'google/protobuf/field_mask.proto'
|
||||
)
|
||||
|
||||
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/__init__.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/__init__.py
Executable file → Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/api_implementation.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/api_implementation.py
Executable file → Normal file
7
.venv/lib/python3.10/site-packages/google/protobuf/internal/builder.py
Executable file → Normal file
7
.venv/lib/python3.10/site-packages/google/protobuf/internal/builder.py
Executable file → Normal file
@@ -54,13 +54,12 @@ def BuildTopDescriptorsAndMessages(file_des, module_name, module):
|
||||
module: Generated _pb2 module
|
||||
"""
|
||||
|
||||
def BuildMessage(msg_des, prefix):
|
||||
def BuildMessage(msg_des):
|
||||
create_dict = {}
|
||||
for (name, nested_msg) in msg_des.nested_types_by_name.items():
|
||||
create_dict[name] = BuildMessage(nested_msg, prefix + msg_des.name + '.')
|
||||
create_dict[name] = BuildMessage(nested_msg)
|
||||
create_dict['DESCRIPTOR'] = msg_des
|
||||
create_dict['__module__'] = module_name
|
||||
create_dict['__qualname__'] = prefix + msg_des.name
|
||||
message_class = _reflection.GeneratedProtocolMessageType(
|
||||
msg_des.name, (_message.Message,), create_dict)
|
||||
_sym_db.RegisterMessage(message_class)
|
||||
@@ -84,7 +83,7 @@ def BuildTopDescriptorsAndMessages(file_des, module_name, module):
|
||||
|
||||
# Build messages.
|
||||
for (name, msg_des) in file_des.message_types_by_name.items():
|
||||
module[name] = BuildMessage(msg_des, '')
|
||||
module[name] = BuildMessage(msg_des)
|
||||
|
||||
|
||||
def AddHelpersToExtensions(file_des):
|
||||
|
||||
13
.venv/lib/python3.10/site-packages/google/protobuf/internal/containers.py
Executable file → Normal file
13
.venv/lib/python3.10/site-packages/google/protobuf/internal/containers.py
Executable file → Normal file
@@ -412,13 +412,6 @@ class ScalarMap(MutableMapping[_K, _V]):
|
||||
def __repr__(self) -> str:
|
||||
return repr(self._values)
|
||||
|
||||
def setdefault(self, key: _K, value: Optional[_V] = None) -> _V:
|
||||
if value == None:
|
||||
raise ValueError('The value for scalar map setdefault must be set.')
|
||||
if key not in self._values:
|
||||
self.__setitem__(key, value)
|
||||
return self[key]
|
||||
|
||||
def MergeFrom(self, other: 'ScalarMap[_K, _V]') -> None:
|
||||
self._values.update(other._values)
|
||||
self._message_listener.Modified()
|
||||
@@ -533,12 +526,6 @@ class MessageMap(MutableMapping[_K, _V]):
|
||||
def __repr__(self) -> str:
|
||||
return repr(self._values)
|
||||
|
||||
def setdefault(self, key: _K, value: Optional[_V] = None) -> _V:
|
||||
raise NotImplementedError(
|
||||
'Set message map value directly is not supported, call'
|
||||
' my_map[key].foo = 5'
|
||||
)
|
||||
|
||||
def MergeFrom(self, other: 'MessageMap[_K, _V]') -> None:
|
||||
# pylint: disable=protected-access
|
||||
for key in other._values:
|
||||
|
||||
179
.venv/lib/python3.10/site-packages/google/protobuf/internal/decoder.py
Executable file → Normal file
179
.venv/lib/python3.10/site-packages/google/protobuf/internal/decoder.py
Executable file → Normal file
@@ -58,7 +58,6 @@ we repeatedly read a tag, look up the corresponding decoder, and invoke it.
|
||||
__author__ = 'kenton@google.com (Kenton Varda)'
|
||||
|
||||
import math
|
||||
import numbers
|
||||
import struct
|
||||
|
||||
from google.protobuf import message
|
||||
@@ -72,27 +71,6 @@ from google.protobuf.internal import wire_format
|
||||
_DecodeError = message.DecodeError
|
||||
|
||||
|
||||
def IsDefaultScalarValue(value):
|
||||
"""Returns whether or not a scalar value is the default value of its type.
|
||||
|
||||
Specifically, this should be used to determine presence of implicit-presence
|
||||
fields, where we disallow custom defaults.
|
||||
|
||||
Args:
|
||||
value: A scalar value to check.
|
||||
|
||||
Returns:
|
||||
True if the value is equivalent to a default value, False otherwise.
|
||||
"""
|
||||
if isinstance(value, numbers.Number) and math.copysign(1.0, value) < 0:
|
||||
# Special case for negative zero, where "truthiness" fails to give the right
|
||||
# answer.
|
||||
return False
|
||||
|
||||
# Normally, we can just use Python's boolean conversion.
|
||||
return not value
|
||||
|
||||
|
||||
def _VarintDecoder(mask, result_type):
|
||||
"""Return an encoder for a basic varint value (does not include tag).
|
||||
|
||||
@@ -190,19 +168,6 @@ def ReadTag(buffer, pos):
|
||||
return tag_bytes, pos
|
||||
|
||||
|
||||
def DecodeTag(tag_bytes):
|
||||
"""Decode a tag from the bytes.
|
||||
|
||||
Args:
|
||||
tag_bytes: the bytes of the tag
|
||||
|
||||
Returns:
|
||||
Tuple[int, int] of the tag field number and wire type.
|
||||
"""
|
||||
(tag, _) = _DecodeVarint(tag_bytes, 0)
|
||||
return wire_format.UnpackTag(tag)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -259,7 +224,7 @@ def _SimpleDecoder(wire_type, decode_value):
|
||||
(new_value, pos) = decode_value(buffer, pos)
|
||||
if pos > end:
|
||||
raise _DecodeError('Truncated message.')
|
||||
if clear_if_default and IsDefaultScalarValue(new_value):
|
||||
if clear_if_default and not new_value:
|
||||
field_dict.pop(key, None)
|
||||
else:
|
||||
field_dict[key] = new_value
|
||||
@@ -500,7 +465,7 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default,
|
||||
(enum_value, pos) = _DecodeSignedVarint32(buffer, pos)
|
||||
if pos > end:
|
||||
raise _DecodeError('Truncated message.')
|
||||
if clear_if_default and IsDefaultScalarValue(enum_value):
|
||||
if clear_if_default and not enum_value:
|
||||
field_dict.pop(key, None)
|
||||
return pos
|
||||
# pylint: disable=protected-access
|
||||
@@ -595,7 +560,7 @@ def StringDecoder(field_number, is_repeated, is_packed, key, new_default,
|
||||
new_pos = pos + size
|
||||
if new_pos > end:
|
||||
raise _DecodeError('Truncated string.')
|
||||
if clear_if_default and IsDefaultScalarValue(size):
|
||||
if clear_if_default and not size:
|
||||
field_dict.pop(key, None)
|
||||
else:
|
||||
field_dict[key] = _ConvertToUnicode(buffer[pos:new_pos])
|
||||
@@ -636,7 +601,7 @@ def BytesDecoder(field_number, is_repeated, is_packed, key, new_default,
|
||||
new_pos = pos + size
|
||||
if new_pos > end:
|
||||
raise _DecodeError('Truncated string.')
|
||||
if clear_if_default and IsDefaultScalarValue(size):
|
||||
if clear_if_default and not size:
|
||||
field_dict.pop(key, None)
|
||||
else:
|
||||
field_dict[key] = buffer[pos:new_pos].tobytes()
|
||||
@@ -765,6 +730,7 @@ def MessageSetItemDecoder(descriptor):
|
||||
|
||||
local_ReadTag = ReadTag
|
||||
local_DecodeVarint = _DecodeVarint
|
||||
local_SkipField = SkipField
|
||||
|
||||
def DecodeItem(buffer, pos, end, message, field_dict):
|
||||
"""Decode serialized message set to its value and new position.
|
||||
@@ -796,10 +762,9 @@ def MessageSetItemDecoder(descriptor):
|
||||
elif tag_bytes == item_end_tag_bytes:
|
||||
break
|
||||
else:
|
||||
field_number, wire_type = DecodeTag(tag_bytes)
|
||||
_, pos = _DecodeUnknownField(buffer, pos, end, field_number, wire_type)
|
||||
pos = SkipField(buffer, pos, end, tag_bytes)
|
||||
if pos == -1:
|
||||
raise _DecodeError('Unexpected end-group tag.')
|
||||
raise _DecodeError('Missing group end tag.')
|
||||
|
||||
if pos > end:
|
||||
raise _DecodeError('Truncated message.')
|
||||
@@ -857,10 +822,9 @@ def UnknownMessageSetItemDecoder():
|
||||
elif tag_bytes == item_end_tag_bytes:
|
||||
break
|
||||
else:
|
||||
field_number, wire_type = DecodeTag(tag_bytes)
|
||||
_, pos = _DecodeUnknownField(buffer, pos, end, field_number, wire_type)
|
||||
pos = SkipField(buffer, pos, end, tag_bytes)
|
||||
if pos == -1:
|
||||
raise _DecodeError('Unexpected end-group tag.')
|
||||
raise _DecodeError('Missing group end tag.')
|
||||
|
||||
if pos > end:
|
||||
raise _DecodeError('Truncated message.')
|
||||
@@ -918,6 +882,30 @@ def MapDecoder(field_descriptor, new_default, is_message_map):
|
||||
|
||||
return DecodeMap
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# Optimization is not as heavy here because calls to SkipField() are rare,
|
||||
# except for handling end-group tags.
|
||||
|
||||
def _SkipVarint(buffer, pos, end):
|
||||
"""Skip a varint value. Returns the new position."""
|
||||
# Previously ord(buffer[pos]) raised IndexError when pos is out of range.
|
||||
# With this code, ord(b'') raises TypeError. Both are handled in
|
||||
# python_message.py to generate a 'Truncated message' error.
|
||||
while ord(buffer[pos:pos+1].tobytes()) & 0x80:
|
||||
pos += 1
|
||||
pos += 1
|
||||
if pos > end:
|
||||
raise _DecodeError('Truncated message.')
|
||||
return pos
|
||||
|
||||
def _SkipFixed64(buffer, pos, end):
|
||||
"""Skip a fixed64 value. Returns the new position."""
|
||||
|
||||
pos += 8
|
||||
if pos > end:
|
||||
raise _DecodeError('Truncated message.')
|
||||
return pos
|
||||
|
||||
|
||||
def _DecodeFixed64(buffer, pos):
|
||||
"""Decode a fixed64."""
|
||||
@@ -925,11 +913,25 @@ def _DecodeFixed64(buffer, pos):
|
||||
return (struct.unpack('<Q', buffer[pos:new_pos])[0], new_pos)
|
||||
|
||||
|
||||
def _DecodeFixed32(buffer, pos):
|
||||
"""Decode a fixed32."""
|
||||
def _SkipLengthDelimited(buffer, pos, end):
|
||||
"""Skip a length-delimited value. Returns the new position."""
|
||||
|
||||
new_pos = pos + 4
|
||||
return (struct.unpack('<I', buffer[pos:new_pos])[0], new_pos)
|
||||
(size, pos) = _DecodeVarint(buffer, pos)
|
||||
pos += size
|
||||
if pos > end:
|
||||
raise _DecodeError('Truncated message.')
|
||||
return pos
|
||||
|
||||
|
||||
def _SkipGroup(buffer, pos, end):
|
||||
"""Skip sub-group. Returns the new position."""
|
||||
|
||||
while 1:
|
||||
(tag_bytes, pos) = ReadTag(buffer, pos)
|
||||
new_pos = SkipField(buffer, pos, end, tag_bytes)
|
||||
if new_pos == -1:
|
||||
return pos
|
||||
pos = new_pos
|
||||
|
||||
|
||||
def _DecodeUnknownFieldSet(buffer, pos, end_pos=None):
|
||||
@@ -942,16 +944,14 @@ def _DecodeUnknownFieldSet(buffer, pos, end_pos=None):
|
||||
field_number, wire_type = wire_format.UnpackTag(tag)
|
||||
if wire_type == wire_format.WIRETYPE_END_GROUP:
|
||||
break
|
||||
(data, pos) = _DecodeUnknownField(
|
||||
buffer, pos, end_pos, field_number, wire_type
|
||||
)
|
||||
(data, pos) = _DecodeUnknownField(buffer, pos, wire_type)
|
||||
# pylint: disable=protected-access
|
||||
unknown_field_set._add(field_number, wire_type, data)
|
||||
|
||||
return (unknown_field_set, pos)
|
||||
|
||||
|
||||
def _DecodeUnknownField(buffer, pos, end_pos, field_number, wire_type):
|
||||
def _DecodeUnknownField(buffer, pos, wire_type):
|
||||
"""Decode a unknown field. Returns the UnknownField and new position."""
|
||||
|
||||
if wire_type == wire_format.WIRETYPE_VARINT:
|
||||
@@ -965,19 +965,72 @@ def _DecodeUnknownField(buffer, pos, end_pos, field_number, wire_type):
|
||||
data = buffer[pos:pos+size].tobytes()
|
||||
pos += size
|
||||
elif wire_type == wire_format.WIRETYPE_START_GROUP:
|
||||
end_tag_bytes = encoder.TagBytes(
|
||||
field_number, wire_format.WIRETYPE_END_GROUP
|
||||
)
|
||||
data, pos = _DecodeUnknownFieldSet(buffer, pos, end_pos)
|
||||
# Check end tag.
|
||||
if buffer[pos - len(end_tag_bytes) : pos] != end_tag_bytes:
|
||||
raise _DecodeError('Missing group end tag.')
|
||||
(data, pos) = _DecodeUnknownFieldSet(buffer, pos)
|
||||
elif wire_type == wire_format.WIRETYPE_END_GROUP:
|
||||
return (0, -1)
|
||||
else:
|
||||
raise _DecodeError('Wrong wire type in tag.')
|
||||
|
||||
if pos > end_pos:
|
||||
raise _DecodeError('Truncated message.')
|
||||
|
||||
return (data, pos)
|
||||
|
||||
|
||||
def _EndGroup(buffer, pos, end):
|
||||
"""Skipping an END_GROUP tag returns -1 to tell the parent loop to break."""
|
||||
|
||||
return -1
|
||||
|
||||
|
||||
def _SkipFixed32(buffer, pos, end):
|
||||
"""Skip a fixed32 value. Returns the new position."""
|
||||
|
||||
pos += 4
|
||||
if pos > end:
|
||||
raise _DecodeError('Truncated message.')
|
||||
return pos
|
||||
|
||||
|
||||
def _DecodeFixed32(buffer, pos):
|
||||
"""Decode a fixed32."""
|
||||
|
||||
new_pos = pos + 4
|
||||
return (struct.unpack('<I', buffer[pos:new_pos])[0], new_pos)
|
||||
|
||||
|
||||
def _RaiseInvalidWireType(buffer, pos, end):
|
||||
"""Skip function for unknown wire types. Raises an exception."""
|
||||
|
||||
raise _DecodeError('Tag had invalid wire type.')
|
||||
|
||||
def _FieldSkipper():
|
||||
"""Constructs the SkipField function."""
|
||||
|
||||
WIRETYPE_TO_SKIPPER = [
|
||||
_SkipVarint,
|
||||
_SkipFixed64,
|
||||
_SkipLengthDelimited,
|
||||
_SkipGroup,
|
||||
_EndGroup,
|
||||
_SkipFixed32,
|
||||
_RaiseInvalidWireType,
|
||||
_RaiseInvalidWireType,
|
||||
]
|
||||
|
||||
wiretype_mask = wire_format.TAG_TYPE_MASK
|
||||
|
||||
def SkipField(buffer, pos, end, tag_bytes):
|
||||
"""Skips a field with the specified tag.
|
||||
|
||||
|pos| should point to the byte immediately after the tag.
|
||||
|
||||
Returns:
|
||||
The new position (after the tag value), or -1 if the tag is an end-group
|
||||
tag (in which case the calling loop should break).
|
||||
"""
|
||||
|
||||
# The wire type is always in the first byte since varints are little-endian.
|
||||
wire_type = ord(tag_bytes[0:1]) & wiretype_mask
|
||||
return WIRETYPE_TO_SKIPPER[wire_type](buffer, pos, end)
|
||||
|
||||
return SkipField
|
||||
|
||||
SkipField = _FieldSkipper()
|
||||
|
||||
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/encoder.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/encoder.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/enum_type_wrapper.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/enum_type_wrapper.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/extension_dict.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/extension_dict.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/field_mask.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/field_mask.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/message_listener.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/message_listener.py
Executable file → Normal file
2
.venv/lib/python3.10/site-packages/google/protobuf/internal/python_edition_defaults.py
Executable file → Normal file
2
.venv/lib/python3.10/site-packages/google/protobuf/internal/python_edition_defaults.py
Executable file → Normal file
@@ -2,4 +2,4 @@
|
||||
This file contains the serialized FeatureSetDefaults object corresponding to
|
||||
the Pure Python runtime. This is used for feature resolution under Editions.
|
||||
"""
|
||||
_PROTOBUF_INTERNAL_PYTHON_EDITION_DEFAULTS = b"\n\025\030\204\007\"\000*\016\010\001\020\002\030\002 \003(\0010\0028\002\n\025\030\347\007\"\000*\016\010\002\020\001\030\001 \002(\0010\0018\002\n\025\030\350\007\"\014\010\001\020\001\030\001 \002(\0010\001*\0028\002 \346\007(\350\007"
|
||||
_PROTOBUF_INTERNAL_PYTHON_EDITION_DEFAULTS = b"\n\023\030\204\007\"\000*\014\010\001\020\002\030\002 \003(\0010\002\n\023\030\347\007\"\000*\014\010\002\020\001\030\001 \002(\0010\001\n\023\030\350\007\"\014\010\001\020\001\030\001 \002(\0010\001*\000 \346\007(\350\007"
|
||||
|
||||
33
.venv/lib/python3.10/site-packages/google/protobuf/internal/python_message.py
Executable file → Normal file
33
.venv/lib/python3.10/site-packages/google/protobuf/internal/python_message.py
Executable file → Normal file
@@ -29,7 +29,6 @@ __author__ = 'robinson@google.com (Will Robinson)'
|
||||
|
||||
import datetime
|
||||
from io import BytesIO
|
||||
import math
|
||||
import struct
|
||||
import sys
|
||||
import warnings
|
||||
@@ -523,11 +522,7 @@ def _AddInitMethod(message_descriptor, cls):
|
||||
if _IsMapField(field):
|
||||
if _IsMessageMapField(field):
|
||||
for key in field_value:
|
||||
item_value = field_value[key]
|
||||
if isinstance(item_value, dict):
|
||||
field_copy[key].__init__(**item_value)
|
||||
else:
|
||||
field_copy[key].MergeFrom(item_value)
|
||||
field_copy[key].MergeFrom(field_value[key])
|
||||
else:
|
||||
field_copy.update(field_value)
|
||||
else:
|
||||
@@ -721,14 +716,14 @@ def _AddPropertiesForNonRepeatedScalarField(field, cls):
|
||||
|
||||
def field_setter(self, new_value):
|
||||
# pylint: disable=protected-access
|
||||
# Testing the value for truthiness captures all of the implicit presence
|
||||
# defaults (0, 0.0, enum 0, and False), except for -0.0.
|
||||
# Testing the value for truthiness captures all of the proto3 defaults
|
||||
# (0, 0.0, enum 0, and False).
|
||||
try:
|
||||
new_value = type_checker.CheckValue(new_value)
|
||||
except TypeError as e:
|
||||
raise TypeError(
|
||||
'Cannot set %s to %.1024r: %s' % (field.full_name, new_value, e))
|
||||
if not field.has_presence and decoder.IsDefaultScalarValue(new_value):
|
||||
if not field.has_presence and not new_value:
|
||||
self._fields.pop(field, None)
|
||||
else:
|
||||
self._fields[field] = new_value
|
||||
@@ -1197,6 +1192,8 @@ def _AddMergeFromStringMethod(message_descriptor, cls):
|
||||
return length # Return this for legacy reasons.
|
||||
cls.MergeFromString = MergeFromString
|
||||
|
||||
local_ReadTag = decoder.ReadTag
|
||||
local_SkipField = decoder.SkipField
|
||||
fields_by_tag = cls._fields_by_tag
|
||||
message_set_decoders_by_tag = cls._message_set_decoders_by_tag
|
||||
|
||||
@@ -1218,7 +1215,7 @@ def _AddMergeFromStringMethod(message_descriptor, cls):
|
||||
self._Modified()
|
||||
field_dict = self._fields
|
||||
while pos != end:
|
||||
(tag_bytes, new_pos) = decoder.ReadTag(buffer, pos)
|
||||
(tag_bytes, new_pos) = local_ReadTag(buffer, pos)
|
||||
field_decoder, field_des = message_set_decoders_by_tag.get(
|
||||
tag_bytes, (None, None)
|
||||
)
|
||||
@@ -1229,17 +1226,23 @@ def _AddMergeFromStringMethod(message_descriptor, cls):
|
||||
if field_des is None:
|
||||
if not self._unknown_fields: # pylint: disable=protected-access
|
||||
self._unknown_fields = [] # pylint: disable=protected-access
|
||||
field_number, wire_type = decoder.DecodeTag(tag_bytes)
|
||||
# pylint: disable=protected-access
|
||||
(tag, _) = decoder._DecodeVarint(tag_bytes, 0)
|
||||
field_number, wire_type = wire_format.UnpackTag(tag)
|
||||
if field_number == 0:
|
||||
raise message_mod.DecodeError('Field number 0 is illegal.')
|
||||
# TODO: remove old_pos.
|
||||
old_pos = new_pos
|
||||
(data, new_pos) = decoder._DecodeUnknownField(
|
||||
buffer, new_pos, end, field_number, wire_type
|
||||
) # pylint: disable=protected-access
|
||||
buffer, new_pos, wire_type) # pylint: disable=protected-access
|
||||
if new_pos == -1:
|
||||
return pos
|
||||
# TODO: remove _unknown_fields.
|
||||
new_pos = local_SkipField(buffer, old_pos, end, tag_bytes)
|
||||
if new_pos == -1:
|
||||
return pos
|
||||
self._unknown_fields.append(
|
||||
(tag_bytes, buffer[pos + len(tag_bytes) : new_pos].tobytes())
|
||||
)
|
||||
(tag_bytes, buffer[old_pos:new_pos].tobytes()))
|
||||
pos = new_pos
|
||||
else:
|
||||
_MaybeAddDecoder(cls, field_des)
|
||||
|
||||
5
.venv/lib/python3.10/site-packages/google/protobuf/internal/testing_refleaks.py
Executable file → Normal file
5
.venv/lib/python3.10/site-packages/google/protobuf/internal/testing_refleaks.py
Executable file → Normal file
@@ -37,9 +37,6 @@ class LocalTestResult(unittest.TestResult):
|
||||
def addSkip(self, test, reason):
|
||||
pass
|
||||
|
||||
def addDuration(self, test, duration):
|
||||
pass
|
||||
|
||||
|
||||
class ReferenceLeakCheckerMixin(object):
|
||||
"""A mixin class for TestCase, which checks reference counts."""
|
||||
@@ -62,7 +59,7 @@ class ReferenceLeakCheckerMixin(object):
|
||||
super(ReferenceLeakCheckerMixin, self).run(result=result)
|
||||
super(ReferenceLeakCheckerMixin, self).run(result=result)
|
||||
|
||||
oldrefcount = 0 # pylint: disable=unused-variable but needed for refcounts.
|
||||
oldrefcount = 0
|
||||
local_result = LocalTestResult(result)
|
||||
num_flakes = 0
|
||||
|
||||
|
||||
5
.venv/lib/python3.10/site-packages/google/protobuf/internal/type_checkers.py
Executable file → Normal file
5
.venv/lib/python3.10/site-packages/google/protobuf/internal/type_checkers.py
Executable file → Normal file
@@ -231,7 +231,6 @@ class Uint64ValueChecker(IntValueChecker):
|
||||
# The max 4 bytes float is about 3.4028234663852886e+38
|
||||
_FLOAT_MAX = float.fromhex('0x1.fffffep+127')
|
||||
_FLOAT_MIN = -_FLOAT_MAX
|
||||
_MAX_FLOAT_AS_DOUBLE_ROUNDED = 3.4028235677973366e38
|
||||
_INF = float('inf')
|
||||
_NEG_INF = float('-inf')
|
||||
|
||||
@@ -270,12 +269,8 @@ class FloatValueChecker(DoubleValueChecker):
|
||||
converted_value = super().CheckValue(proposed_value)
|
||||
# This inf rounding matches the C++ proto SafeDoubleToFloat logic.
|
||||
if converted_value > _FLOAT_MAX:
|
||||
if converted_value <= _MAX_FLOAT_AS_DOUBLE_ROUNDED:
|
||||
return _FLOAT_MAX
|
||||
return _INF
|
||||
if converted_value < _FLOAT_MIN:
|
||||
if converted_value >= -_MAX_FLOAT_AS_DOUBLE_ROUNDED:
|
||||
return _FLOAT_MIN
|
||||
return _NEG_INF
|
||||
|
||||
return TruncateToFourByteFloat(converted_value)
|
||||
|
||||
6
.venv/lib/python3.10/site-packages/google/protobuf/internal/well_known_types.py
Executable file → Normal file
6
.venv/lib/python3.10/site-packages/google/protobuf/internal/well_known_types.py
Executable file → Normal file
@@ -26,7 +26,7 @@ from typing import Union
|
||||
|
||||
FieldMask = field_mask.FieldMask
|
||||
|
||||
_TIMESTAMPFORMAT = '%Y-%m-%dT%H:%M:%S'
|
||||
_TIMESTAMPFOMAT = '%Y-%m-%dT%H:%M:%S'
|
||||
_NANOS_PER_SECOND = 1000000000
|
||||
_NANOS_PER_MILLISECOND = 1000000
|
||||
_NANOS_PER_MICROSECOND = 1000
|
||||
@@ -68,7 +68,7 @@ class Any(object):
|
||||
def TypeName(self):
|
||||
"""Returns the protobuf type name of the inner message."""
|
||||
# Only last part is to be used: b/25630112
|
||||
return self.type_url.rpartition('/')[2]
|
||||
return self.type_url.split('/')[-1]
|
||||
|
||||
def Is(self, descriptor):
|
||||
"""Checks if this Any represents the given protobuf type."""
|
||||
@@ -142,7 +142,7 @@ class Timestamp(object):
|
||||
raise ValueError(
|
||||
'time data \'{0}\' does not match format \'%Y-%m-%dT%H:%M:%S\', '
|
||||
'lowercase \'t\' is not accepted'.format(second_value))
|
||||
date_object = datetime.datetime.strptime(second_value, _TIMESTAMPFORMAT)
|
||||
date_object = datetime.datetime.strptime(second_value, _TIMESTAMPFOMAT)
|
||||
td = date_object - datetime.datetime(1970, 1, 1)
|
||||
seconds = td.seconds + td.days * _SECONDS_PER_DAY
|
||||
if len(nano_value) > 9:
|
||||
|
||||
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/wire_format.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/internal/wire_format.py
Executable file → Normal file
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',
|
||||
|
||||
26
.venv/lib/python3.10/site-packages/google/protobuf/message.py
Executable file → Normal file
26
.venv/lib/python3.10/site-packages/google/protobuf/message.py
Executable file → Normal file
@@ -13,9 +13,6 @@
|
||||
|
||||
__author__ = 'robinson@google.com (Will Robinson)'
|
||||
|
||||
_INCONSISTENT_MESSAGE_ATTRIBUTES = ('Extensions',)
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
"""Base error type for this module."""
|
||||
pass
|
||||
@@ -59,29 +56,6 @@ class Message(object):
|
||||
clone.MergeFrom(self)
|
||||
return clone
|
||||
|
||||
def __dir__(self):
|
||||
"""Provides the list of all accessible Message attributes."""
|
||||
message_attributes = set(super().__dir__())
|
||||
|
||||
# TODO: Remove this once the UPB implementation is improved.
|
||||
# The UPB proto implementation currently doesn't provide proto fields as
|
||||
# attributes and they have to added.
|
||||
if self.DESCRIPTOR is not None:
|
||||
for field in self.DESCRIPTOR.fields:
|
||||
message_attributes.add(field.name)
|
||||
|
||||
# The Fast C++ proto implementation provides inaccessible attributes that
|
||||
# have to be removed.
|
||||
for attribute in _INCONSISTENT_MESSAGE_ATTRIBUTES:
|
||||
if attribute not in message_attributes:
|
||||
continue
|
||||
try:
|
||||
getattr(self, attribute)
|
||||
except AttributeError:
|
||||
message_attributes.remove(attribute)
|
||||
|
||||
return sorted(message_attributes)
|
||||
|
||||
def __eq__(self, other_msg):
|
||||
"""Recursively compares two messages by value and structure."""
|
||||
raise NotImplementedError
|
||||
|
||||
63
.venv/lib/python3.10/site-packages/google/protobuf/message_factory.py
Executable file → Normal file
63
.venv/lib/python3.10/site-packages/google/protobuf/message_factory.py
Executable file → Normal file
@@ -142,6 +142,69 @@ class MessageFactory(object):
|
||||
"""Initializes a new factory."""
|
||||
self.pool = pool or descriptor_pool.DescriptorPool()
|
||||
|
||||
def GetPrototype(self, descriptor):
|
||||
"""Obtains a proto2 message class based on the passed in descriptor.
|
||||
|
||||
Passing a descriptor with a fully qualified name matching a previous
|
||||
invocation will cause the same class to be returned.
|
||||
|
||||
Args:
|
||||
descriptor: The descriptor to build from.
|
||||
|
||||
Returns:
|
||||
A class describing the passed in descriptor.
|
||||
"""
|
||||
warnings.warn(
|
||||
'MessageFactory class is deprecated. Please use '
|
||||
'GetMessageClass() instead of MessageFactory.GetPrototype. '
|
||||
'MessageFactory class will be removed after 2024.',
|
||||
stacklevel=2,
|
||||
)
|
||||
return GetMessageClass(descriptor)
|
||||
|
||||
def CreatePrototype(self, descriptor):
|
||||
"""Builds a proto2 message class based on the passed in descriptor.
|
||||
|
||||
Don't call this function directly, it always creates a new class. Call
|
||||
GetMessageClass() instead.
|
||||
|
||||
Args:
|
||||
descriptor: The descriptor to build from.
|
||||
|
||||
Returns:
|
||||
A class describing the passed in descriptor.
|
||||
"""
|
||||
warnings.warn(
|
||||
'Directly call CreatePrototype is wrong. Please use '
|
||||
'GetMessageClass() method instead. Directly use '
|
||||
'CreatePrototype will raise error after July 2023.',
|
||||
stacklevel=2,
|
||||
)
|
||||
return _InternalCreateMessageClass(descriptor)
|
||||
|
||||
def GetMessages(self, files):
|
||||
"""Gets all the messages from a specified file.
|
||||
|
||||
This will find and resolve dependencies, failing if the descriptor
|
||||
pool cannot satisfy them.
|
||||
|
||||
Args:
|
||||
files: The file names to extract messages from.
|
||||
|
||||
Returns:
|
||||
A dictionary mapping proto names to the message classes. This will include
|
||||
any dependent messages as well as any messages defined in the same file as
|
||||
a specified message.
|
||||
"""
|
||||
warnings.warn(
|
||||
'MessageFactory class is deprecated. Please use '
|
||||
'GetMessageClassesForFiles() instead of '
|
||||
'MessageFactory.GetMessages(). MessageFactory class '
|
||||
'will be removed after 2024.',
|
||||
stacklevel=2,
|
||||
)
|
||||
return GetMessageClassesForFiles(files, self.pool)
|
||||
|
||||
|
||||
def GetMessages(file_protos, pool=None):
|
||||
"""Builds a dictionary of all the messages available in a set of files.
|
||||
|
||||
39
.venv/lib/python3.10/site-packages/google/protobuf/proto.py
Executable file → Normal file
39
.venv/lib/python3.10/site-packages/google/protobuf/proto.py
Executable file → Normal file
@@ -8,7 +8,7 @@
|
||||
"""Contains the Nextgen Pythonic protobuf APIs."""
|
||||
|
||||
import io
|
||||
from typing import Text, Type, TypeVar
|
||||
from typing import Type, TypeVar
|
||||
|
||||
from google.protobuf.internal import decoder
|
||||
from google.protobuf.internal import encoder
|
||||
@@ -114,40 +114,3 @@ def parse_length_prefixed(
|
||||
'{2}.'.format(size, parsed_size, message.DESCRIPTOR.name)
|
||||
)
|
||||
return message
|
||||
|
||||
|
||||
def byte_size(message: Message) -> int:
|
||||
"""Returns the serialized size of this message.
|
||||
|
||||
Args:
|
||||
message: A proto message.
|
||||
|
||||
Returns:
|
||||
int: The number of bytes required to serialize this message.
|
||||
"""
|
||||
return message.ByteSize()
|
||||
|
||||
|
||||
def clear_message(message: Message) -> None:
|
||||
"""Clears all data that was set in the message.
|
||||
|
||||
Args:
|
||||
message: The proto message to be cleared.
|
||||
"""
|
||||
message.Clear()
|
||||
|
||||
|
||||
def clear_field(message: Message, field_name: Text) -> None:
|
||||
"""Clears the contents of a given field.
|
||||
|
||||
Inside a oneof group, clears the field set. If the name neither refers to a
|
||||
defined field or oneof group, :exc:`ValueError` is raised.
|
||||
|
||||
Args:
|
||||
message: The proto message.
|
||||
field_name (str): The name of the field to be cleared.
|
||||
|
||||
Raises:
|
||||
ValueError: if the `field_name` is not a member of this message.
|
||||
"""
|
||||
message.ClearField(field_name)
|
||||
|
||||
0
.venv/lib/python3.10/site-packages/google/protobuf/proto_builder.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/proto_builder.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/proto_json.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/proto_json.py
Executable file → Normal file
@@ -1,129 +0,0 @@
|
||||
# Protocol Buffers - Google's data interchange format
|
||||
# Copyright 2025 Google Inc. All rights reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file or at
|
||||
# https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
"""Contains the Nextgen Pythonic Protobuf Text Format APIs."""
|
||||
from typing import AnyStr, Callable, Optional, Text, Type, Union
|
||||
|
||||
from google.protobuf import text_format
|
||||
from google.protobuf.descriptor_pool import DescriptorPool
|
||||
from google.protobuf.message import Message
|
||||
|
||||
_MsgFormatter = Callable[[Message, Union[int, bool], bool], Optional[Text]]
|
||||
|
||||
|
||||
def serialize(
|
||||
message: Message,
|
||||
as_utf8: bool = True,
|
||||
as_one_line: bool = False,
|
||||
use_short_repeated_primitives: bool = False,
|
||||
pointy_brackets: bool = False,
|
||||
use_index_order: bool = False,
|
||||
float_format: Optional[str] = None,
|
||||
double_format: Optional[str] = None,
|
||||
use_field_number: bool = False,
|
||||
descriptor_pool: Optional[DescriptorPool] = None,
|
||||
indent: int = 0,
|
||||
message_formatter: Optional[_MsgFormatter] = None,
|
||||
print_unknown_fields: bool = False,
|
||||
force_colon: bool = False,
|
||||
) -> str:
|
||||
"""Convert protobuf message to text format.
|
||||
|
||||
Double values can be formatted compactly with 15 digits of
|
||||
precision (which is the most that IEEE 754 "double" can guarantee)
|
||||
using double_format='.15g'. To ensure that converting to text and back to a
|
||||
proto will result in an identical value, double_format='.17g' should be used.
|
||||
|
||||
Args:
|
||||
message: The protocol buffers message.
|
||||
as_utf8: Return unescaped Unicode for non-ASCII characters.
|
||||
as_one_line: Don't introduce newlines between fields.
|
||||
use_short_repeated_primitives: Use short repeated format for primitives.
|
||||
pointy_brackets: If True, use angle brackets instead of curly braces for
|
||||
nesting.
|
||||
use_index_order: If True, fields of a proto message will be printed using
|
||||
the order defined in source code instead of the field number, extensions
|
||||
will be printed at the end of the message and their relative order is
|
||||
determined by the extension number. By default, use the field number
|
||||
order.
|
||||
float_format (str): If set, use this to specify float field formatting (per
|
||||
the "Format Specification Mini-Language"); otherwise, shortest float that
|
||||
has same value in wire will be printed. Also affect double field if
|
||||
double_format is not set but float_format is set.
|
||||
double_format (str): If set, use this to specify double field formatting
|
||||
(per the "Format Specification Mini-Language"); if it is not set but
|
||||
float_format is set, use float_format. Otherwise, use ``str()``
|
||||
use_field_number: If True, print field numbers instead of names.
|
||||
descriptor_pool (DescriptorPool): Descriptor pool used to resolve Any types.
|
||||
indent (int): The initial indent level, in terms of spaces, for pretty
|
||||
print.
|
||||
message_formatter (function(message, indent, as_one_line) -> unicode|None):
|
||||
Custom formatter for selected sub-messages (usually based on message
|
||||
type). Use to pretty print parts of the protobuf for easier diffing.
|
||||
print_unknown_fields: If True, unknown fields will be printed.
|
||||
force_colon: If set, a colon will be added after the field name even if the
|
||||
field is a proto message.
|
||||
|
||||
Returns:
|
||||
str: A string of the text formatted protocol buffer message.
|
||||
"""
|
||||
return text_format.MessageToString(
|
||||
message=message,
|
||||
as_utf8=as_utf8,
|
||||
as_one_line=as_one_line,
|
||||
use_short_repeated_primitives=use_short_repeated_primitives,
|
||||
pointy_brackets=pointy_brackets,
|
||||
use_index_order=use_index_order,
|
||||
float_format=float_format,
|
||||
double_format=double_format,
|
||||
use_field_number=use_field_number,
|
||||
descriptor_pool=descriptor_pool,
|
||||
indent=indent,
|
||||
message_formatter=message_formatter,
|
||||
print_unknown_fields=print_unknown_fields,
|
||||
force_colon=force_colon,
|
||||
)
|
||||
|
||||
|
||||
def parse(
|
||||
message_class: Type[Message],
|
||||
text: AnyStr,
|
||||
allow_unknown_extension: bool = False,
|
||||
allow_field_number: bool = False,
|
||||
descriptor_pool: Optional[DescriptorPool] = None,
|
||||
allow_unknown_field: bool = False,
|
||||
) -> Message:
|
||||
"""Parses a text representation of a protocol message into a message.
|
||||
|
||||
Args:
|
||||
message_class: The message meta class.
|
||||
text (str): Message text representation.
|
||||
message (Message): A protocol buffer message to merge into.
|
||||
allow_unknown_extension: if True, skip over missing extensions and keep
|
||||
parsing
|
||||
allow_field_number: if True, both field number and field name are allowed.
|
||||
descriptor_pool (DescriptorPool): Descriptor pool used to resolve Any types.
|
||||
allow_unknown_field: if True, skip over unknown field and keep parsing.
|
||||
Avoid to use this option if possible. It may hide some errors (e.g.
|
||||
spelling error on field name)
|
||||
|
||||
Returns:
|
||||
Message: A new message passed from text.
|
||||
|
||||
Raises:
|
||||
ParseError: On text parsing problems.
|
||||
"""
|
||||
new_message = message_class()
|
||||
text_format.Parse(
|
||||
text=text,
|
||||
message=new_message,
|
||||
allow_unknown_extension=allow_unknown_extension,
|
||||
allow_field_number=allow_field_number,
|
||||
descriptor_pool=descriptor_pool,
|
||||
allow_unknown_field=allow_unknown_field,
|
||||
)
|
||||
return new_message
|
||||
0
.venv/lib/python3.10/site-packages/google/protobuf/pyext/__init__.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/pyext/__init__.py
Executable file → Normal file
Binary file not shown.
Binary file not shown.
0
.venv/lib/python3.10/site-packages/google/protobuf/pyext/cpp_message.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/pyext/cpp_message.py
Executable file → Normal file
49
.venv/lib/python3.10/site-packages/google/protobuf/reflection.py
Executable file → Normal file
49
.venv/lib/python3.10/site-packages/google/protobuf/reflection.py
Executable file → Normal file
@@ -34,3 +34,52 @@ from google.protobuf import symbol_database
|
||||
GeneratedProtocolMessageType = message_factory._GENERATED_PROTOCOL_MESSAGE_TYPE
|
||||
|
||||
MESSAGE_CLASS_CACHE = {}
|
||||
|
||||
|
||||
# Deprecated. Please NEVER use reflection.ParseMessage().
|
||||
def ParseMessage(descriptor, byte_str):
|
||||
"""Generate a new Message instance from this Descriptor and a byte string.
|
||||
|
||||
DEPRECATED: ParseMessage is deprecated because it is using MakeClass().
|
||||
Please use MessageFactory.GetMessageClass() instead.
|
||||
|
||||
Args:
|
||||
descriptor: Protobuf Descriptor object
|
||||
byte_str: Serialized protocol buffer byte string
|
||||
|
||||
Returns:
|
||||
Newly created protobuf Message object.
|
||||
"""
|
||||
warnings.warn(
|
||||
'reflection.ParseMessage() is deprecated. Please use '
|
||||
'MessageFactory.GetMessageClass() and message.ParseFromString() instead. '
|
||||
'reflection.ParseMessage() will be removed in Jan 2025.',
|
||||
stacklevel=2,
|
||||
)
|
||||
result_class = MakeClass(descriptor)
|
||||
new_msg = result_class()
|
||||
new_msg.ParseFromString(byte_str)
|
||||
return new_msg
|
||||
|
||||
|
||||
# Deprecated. Please NEVER use reflection.MakeClass().
|
||||
def MakeClass(descriptor):
|
||||
"""Construct a class object for a protobuf described by descriptor.
|
||||
|
||||
DEPRECATED: use MessageFactory.GetMessageClass() instead.
|
||||
|
||||
Args:
|
||||
descriptor: A descriptor.Descriptor object describing the protobuf.
|
||||
Returns:
|
||||
The Message class object described by the descriptor.
|
||||
"""
|
||||
warnings.warn(
|
||||
'reflection.MakeClass() is deprecated. Please use '
|
||||
'MessageFactory.GetMessageClass() instead. '
|
||||
'reflection.MakeClass() will be removed in Jan 2025.',
|
||||
stacklevel=2,
|
||||
)
|
||||
# Original implementation leads to duplicate message classes, which won't play
|
||||
# well with extensions. Message factory info is also missing.
|
||||
# Redirect to message_factory.
|
||||
return message_factory.GetMessageClass(descriptor)
|
||||
|
||||
6
.venv/lib/python3.10/site-packages/google/protobuf/runtime_version.py
Executable file → Normal file
6
.venv/lib/python3.10/site-packages/google/protobuf/runtime_version.py
Executable file → Normal file
@@ -27,9 +27,9 @@ class Domain(Enum):
|
||||
# the Protobuf release process. Do not edit them manually.
|
||||
# These OSS versions are not stripped to avoid merging conflicts.
|
||||
OSS_DOMAIN = Domain.PUBLIC
|
||||
OSS_MAJOR = 6
|
||||
OSS_MINOR = 30
|
||||
OSS_PATCH = 2
|
||||
OSS_MAJOR = 5
|
||||
OSS_MINOR = 29
|
||||
OSS_PATCH = 4
|
||||
OSS_SUFFIX = ''
|
||||
|
||||
DOMAIN = OSS_DOMAIN
|
||||
|
||||
0
.venv/lib/python3.10/site-packages/google/protobuf/service_reflection.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/service_reflection.py
Executable file → Normal file
8
.venv/lib/python3.10/site-packages/google/protobuf/source_context_pb2.py
Executable file → Normal file
8
.venv/lib/python3.10/site-packages/google/protobuf/source_context_pb2.py
Executable file → Normal file
@@ -2,7 +2,7 @@
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# NO CHECKED-IN PROTOBUF GENCODE
|
||||
# source: google/protobuf/source_context.proto
|
||||
# Protobuf Python Version: 6.30.2
|
||||
# Protobuf Python Version: 5.29.4
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
@@ -11,9 +11,9 @@ from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf.internal import builder as _builder
|
||||
_runtime_version.ValidateProtobufRuntimeVersion(
|
||||
_runtime_version.Domain.PUBLIC,
|
||||
6,
|
||||
30,
|
||||
2,
|
||||
5,
|
||||
29,
|
||||
4,
|
||||
'',
|
||||
'google/protobuf/source_context.proto'
|
||||
)
|
||||
|
||||
8
.venv/lib/python3.10/site-packages/google/protobuf/struct_pb2.py
Executable file → Normal file
8
.venv/lib/python3.10/site-packages/google/protobuf/struct_pb2.py
Executable file → Normal file
@@ -2,7 +2,7 @@
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# NO CHECKED-IN PROTOBUF GENCODE
|
||||
# source: google/protobuf/struct.proto
|
||||
# Protobuf Python Version: 6.30.2
|
||||
# Protobuf Python Version: 5.29.4
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
@@ -11,9 +11,9 @@ from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf.internal import builder as _builder
|
||||
_runtime_version.ValidateProtobufRuntimeVersion(
|
||||
_runtime_version.Domain.PUBLIC,
|
||||
6,
|
||||
30,
|
||||
2,
|
||||
5,
|
||||
29,
|
||||
4,
|
||||
'',
|
||||
'google/protobuf/struct.proto'
|
||||
)
|
||||
|
||||
18
.venv/lib/python3.10/site-packages/google/protobuf/symbol_database.py
Executable file → Normal file
18
.venv/lib/python3.10/site-packages/google/protobuf/symbol_database.py
Executable file → Normal file
@@ -51,6 +51,24 @@ class SymbolDatabase():
|
||||
"""Initializes a new SymbolDatabase."""
|
||||
self.pool = pool or descriptor_pool.DescriptorPool()
|
||||
|
||||
def GetPrototype(self, descriptor):
|
||||
warnings.warn('SymbolDatabase.GetPrototype() is deprecated. Please '
|
||||
'use message_factory.GetMessageClass() instead. '
|
||||
'SymbolDatabase.GetPrototype() will be removed soon.')
|
||||
return message_factory.GetMessageClass(descriptor)
|
||||
|
||||
def CreatePrototype(self, descriptor):
|
||||
warnings.warn('Directly call CreatePrototype() is wrong. Please use '
|
||||
'message_factory.GetMessageClass() instead. '
|
||||
'SymbolDatabase.CreatePrototype() will be removed soon.')
|
||||
return message_factory._InternalCreateMessageClass(descriptor)
|
||||
|
||||
def GetMessages(self, files):
|
||||
warnings.warn('SymbolDatabase.GetMessages() is deprecated. Please use '
|
||||
'message_factory.GetMessageClassedForFiles() instead. '
|
||||
'SymbolDatabase.GetMessages() will be removed soon.')
|
||||
return message_factory.GetMessageClassedForFiles(files, self.pool)
|
||||
|
||||
def RegisterMessage(self, message):
|
||||
"""Registers the given message type in the local database.
|
||||
|
||||
|
||||
0
.venv/lib/python3.10/site-packages/google/protobuf/testdata/__init__.py
vendored
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/testdata/__init__.py
vendored
Executable file → Normal file
Binary file not shown.
0
.venv/lib/python3.10/site-packages/google/protobuf/text_encoding.py
Executable file → Normal file
0
.venv/lib/python3.10/site-packages/google/protobuf/text_encoding.py
Executable file → Normal file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user