o
    bi=                     @   s,   d dl Z d dlmZ G dd de jjZdS )    N)cached_propertyc                   @   s`   e Zd ZdZedd Zdd Zdd Zdd	 Zd
d Z	dd Z
dd Zdd Zedd ZdS )MapCompositezA view around a mutable sequence in protocol buffers.

    This implements the full Python MutableMapping interface, but all methods
    modify the underlying field container directly.
    c                 C   s   t | j  jS )z2Return the protocol buffer type for this sequence.)typepbZGetEntryClassvalueself r	   X/home/kim/smarthome/.venv/lib/python3.10/site-packages/proto/marshal/collections/maps.py_pb_type   s   zMapComposite._pb_typec                C   s   || _ || _dS )zInitialize a wrapper around a protobuf map.

        Args:
            sequence: A protocol buffers map.
            marshal (~.MarshalRegistry): An instantiated marshal, used to
                convert values going to and from this map.
        N)_pb_marshal)r   sequencemarshalr	   r	   r
   __init__!   s   
zMapComposite.__init__c                 C   s   |t |  v S N)tuplekeysr   keyr	   r	   r
   __contains__,   s   zMapComposite.__contains__c                 C   s&   || vrt || j| j| j| S r   )KeyErrorr   Z	to_pythonr   r   r   r	   r	   r
   __getitem__4   s   zMapComposite.__getitem__c                 C   s6   | j j| j|dd}| j|   | j| | d S )NT)strict)r   Zto_protor   r   ZClearZ	MergeFrom)r   r   r   Zpb_valuer	   r	   r
   __setitem__;   s   zMapComposite.__setitem__c                 C   s   | j | d S r   )r   popr   r	   r	   r
   __delitem__F   s   zMapComposite.__delitem__c                 C   
   t | jS r   )lenr   r   r	   r	   r
   __len__I      
zMapComposite.__len__c                 C   r   r   )iterr   r   r	   r	   r
   __iter__L   r    zMapComposite.__iter__c                 C   s   | j S r   )r   r   r	   r	   r
   r   O   s   zMapComposite.pbN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r"   propertyr   r	   r	   r	   r
   r      s    
r   )collectionsZproto.utilsr   abcMutableMappingr   r	   r	   r	   r
   <module>   s   