class documentation
class DescriptorWrap(ABC, Generic[
Constructor: DescriptorWrap(name, file_descriptor, expected_type)
Lazy resolver for protobuf descriptors by fully qualified name.
Instances are callable; the first call resolves and caches the descriptor.
| Parameters | |
| name | Fully qualified descriptor name. Leading . is allowed. |
| file | Protobuf file descriptor to search within. |
| expected | Descriptor type expected by the caller. |
| Method | __call__ |
Retrieve the descriptor of the specified type using the fully qualified name. |
| Method | __init__ |
Create a descriptor wrapper. |
| Method | _find |
Recursively search for a descriptor by name. |
| Instance Variable | _descriptor |
Cached resolved descriptor. |
| Instance Variable | _expected |
Expected descriptor class. |
| Instance Variable | _file |
Root file descriptor used for lookup. |
| Instance Variable | _name |
Normalized fully qualified name. |
def _find_descriptor(self, container:
pb.FileDescriptor | pb.Descriptor, name: str) -> pb.Descriptor | pb.EnumDescriptor | pb.OneofDescriptor | pb.ServiceDescriptor | None:
(source)
¶
Recursively search for a descriptor by name.
| Parameters | |
container:pb.FileDescriptor | pb.Descriptor | File or message descriptor to search within. |
name:str | Fully qualified name to resolve. |
| Returns | |
pb.Descriptor | pb.EnumDescriptor | pb.OneofDescriptor | pb.ServiceDescriptor | None | Matching descriptor or None if not found. |
| Raises | |
ValueError | If the protobuf pool returns an unexpected type. |