o
    2.a3
                     @   s    G d d dZ G dd dZdS )c                   @   sV   e Zd ZdZdZdddZdd Zdd	 Zd
d Ze	dd Z
e	dd Zdd ZdS )ModelzF
    A base class for representing a single object on the server.
    IdNc                 C   s*   || _ || _|| _| jd u ri | _d S d S N)client
collectionattrs)selfr   r   r    r   8/usr/lib/python3/dist-packages/docker/models/resource.py__init__   s   

zModel.__init__c                 C   s   d| j j d| j dS )N<z: >)	__class____name__short_idr   r   r   r	   __repr__      zModel.__repr__c                 C   s   t || jo| j|jkS r   )
isinstancer   id)r   otherr   r   r	   __eq__   r   zModel.__eq__c                 C   s   t | jj d| j S )N:)hashr   r   r   r   r   r   r	   __hash__   r   zModel.__hash__c                 C   s   | j | jS )z'
        The ID of the object.
        )r   getid_attributer   r   r   r	   r         zModel.idc                 C   s   | j dd S )zC
        The ID of the object, truncated to 10 characters.
        N
   )r   r   r   r   r	   r   #   r   zModel.short_idc                 C   s   | j | j}|j| _dS )zh
        Load this object from the server again and update ``attrs`` with the
        new data.
        N)r   r   r   r   )r   	new_modelr   r   r	   reload*   s   zModel.reload)NNN)r   
__module____qualname____doc__r   r
   r   r   r   propertyr   r   r   r   r   r   r	   r      s    


r   c                   @   sH   e Zd ZdZdZdddZdd Zdd Zd	d
 ZdddZ	dd Z
dS )
Collectionz[
    A base class for representing all objects of a particular type on the
    server.
    Nc                 C   s
   || _ d S r   )r   )r   r   r   r   r	   r
   <   s   
zCollection.__init__c                 O   s   t d| jj)Nzk'{}' object is not callable. You might be trying to use the old (pre-2.0) API - use docker.APIClient if so.)	TypeErrorformatr   r   )r   argskwargsr   r   r	   __call__A   s   
zCollection.__call__c                 C      t r   NotImplementedErrorr   r   r   r	   listG      zCollection.listc                 C   r*   r   r+   )r   keyr   r   r	   r   J   r.   zCollection.getc                 C   r*   r   r+   r   r   r   r   r	   createM   r.   zCollection.createc                 C   sL   t |tr| j|_| |_|S t |tr| j|| j| dS td| jj|f )z:
        Create a model from a set of attributes.
        )r   r   r   zCan't create %s from %s)r   r   r   r   dictmodel	Exceptionr   r0   r   r   r	   prepare_modelP   s   


zCollection.prepare_modelr   )r   r    r!   r"   r3   r
   r)   r-   r   r1   r5   r   r   r   r	   r$   3   s    

r$   N)r   r$   r   r   r   r	   <module>   s    2