관리-도구
편집 파일: python_message.cpython-311.pyc
� P�Dg�� � �r � d Z dZddlmZ ddlZddlZddlZddlmZ ddlm Z ddlm Z ddlmZ dd lmZ dd lm Z ddlmZ ddlmZ dd lmZ ddlmZ ddlmZ ddlmZ ddlmZ ej ZdZe j Z G d� de� � Zd� Zd� Z d� Z!d� Z"d� Z#d� Z$d� Z%d� Z&d� Z'd� Z(d� Z)d � Z*d!� Z+d"� Z,d#� Z- G d$� d%e.� � Z/d&� Z0d'� Z1d(� Z2d)� Z3d*� Z4d+� Z5d,� Z6d-� Z7d.� Z8d/� Z9d0� Z:d1� Z;d2� Z<d3� Z=d4� Z>d5� Z?d6� Z@d7� ZAd8� ZBd9� ZCd:� ZDd;� ZEd<� ZFd=� ZGd>� ZHd?� ZId@� ZJdA� ZKdB� ZLdC� ZMdD� ZN G dE� dFeO� � ZP G dG� dHeP� � ZQdS )Ia Contains a metaclass and helper functions used to create protocol message classes from Descriptor objects at runtime. Recall that a metaclass is the "type" of a class. (A class is to a metaclass what an instance is to a class.) In this case, we use the GeneratedProtocolMessageType metaclass to inject all the useful functionality into the classes output by the protocol compiler at compile-time. The upshot of all this is that the real implementation details for ALL pure-Python protocol buffers are *here in this file*. z#robinson@google.com (Will Robinson)� )�BytesION)�api_implementation)� containers)�decoder)�encoder)�enum_type_wrapper)�extension_dict)�message_listener)� type_checkers)�well_known_types)�wire_format)� descriptor)�message)�text_formatzgoogle.protobuf.Anyc �0 � � e Zd ZdZdZ� fd�Z� fd�Z� xZS )�GeneratedProtocolMessageTypeaQ Metaclass for protocol message classes created at runtime from Descriptors. We add implementations for all methods described in the Message class. We also create properties to allow getting/setting all fields in the protocol message. Finally, we create slots to prevent users from accidentally "setting" nonexistent fields in the protocol message, which then wouldn't get serialized / deserialized properly. The protocol compiler currently uses this metaclass to create protocol message classes at runtime. Clients can also manually create their own classes at runtime, as in this example: mydescriptor = Descriptor(.....) factory = symbol_database.Default() factory.pool.AddDescriptor(mydescriptor) MyProtoClass = factory.GetPrototype(mydescriptor) myproto_instance = MyProtoClass() myproto.foo_field = 23 ... � DESCRIPTORc � �� |t j }t |t � � rt d� � �t |dd� � }|r|S |j t j v r|t j |j fz }t ||� � t ||� � t t | � � }|� | |||� � }|S )ak Custom allocation for runtime-generated class types. We override __new__ because this is apparently the only place where we can meaningfully set __slots__ on the class we're creating(?). (The interplay between metaclasses and slots is not very well-documented). Args: name: Name of the class (ignored, but required by the metaclass protocol). bases: Base classes of the class we're constructing. (Should be message.Message). We ignore this field, but it's required by the metaclass protocol dictionary: The class dictionary of the class we're constructing. dictionary[_DESCRIPTOR_KEY] must contain a Descriptor object describing this protocol message type. Returns: Newly-allocated class. Raises: RuntimeError: Generated code only work with python cpp extension. z\The generated code only work with python cpp extension, but it is using pure python runtime.�_concrete_classN) r �_DESCRIPTOR_KEY� isinstance�str�RuntimeError�getattr� full_namer �WKTBASES�&_AddClassAttributesForNestedExtensions� _AddSlots�super�__new__)�cls�name�bases� dictionaryr � new_class� superclass� __class__s ���/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib64/python3.11/site-packages/google/protobuf/internal/python_message.pyr z$GeneratedProtocolMessageType.__new__h s� �� �0 �8�H�I�J��*�c�"�"� L�� K� L� L� L� � �$5�t�<�<�I�� � ����/�8�8�8�� �)�*�*>�?�A�A�e�*�:�z�B�B�B� �j�*�%�%�%��3�S�9�9�J��"�"�3��e�Z�@�@�I��� c � �� |t j }t |dd� � }|r|| u sJ d|j z � � �dS i | _ |j rA|� � � j r(t j |� � df| j t j <