U
    K7\P
                     @   s$   G d d de ZG dd de 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.
    ZIdNc                 C   s&   || _ || _|| _| jd kr"i | _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| jf S )Nz<%s: %s>)	__class____name__short_idr   r   r   r   __repr__   s    zModel.__repr__c                 C   s   t || jo| j|jkS r   )
isinstancer
   id)r   otherr   r   r   __eq__   s    zModel.__eq__c                 C   s   t d| jj| jf S )Nz%s:%s)hashr
   r   r   r   r   r   r   __hash__   s    zModel.__hash__c                 C   s   | j | jS )z'
        The ID of the object.
        )r   getid_attributer   r   r   r   r      s    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   $   s    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   Z	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d S )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__B   s
    zCollection.__call__c                 C   s   t d S r   NotImplementedErrorr   r   r   r   listH   s    zCollection.listc                 C   s   t d S r   r#   )r   keyr   r   r   r   K   s    zCollection.getc                 C   s   t d S r   r#   r   r   r   r   r   createN   s    zCollection.createc                 C   sP   t |tr| j|_| |_|S t |tr8| j|| j| dS td| jj|f dS )z:
        Create a model from a set of attributes.
        )r   r   r   zCan't create %s from %sN)r   r   r   r   dictmodel	Exceptionr   r'   r   r   r   prepare_modelQ   s    


zCollection.prepare_model)N)N)r   r   r   r   r*   r	   r"   r%   r   r(   r,   r   r   r   r   r   4   s   

r   N)objectr   r   r   r   r   r   <module>   s   2