3
8ßL]	  ã               @   sD   d Z ddlZddlmZmZmZmZ ddlmZ G dd„ deƒZ	dS )z< An offer to provide adapters from one protocol to another. é    N)ÚAnyÚBoolÚ	HasTraitsÚProperty)Úimport_symbolc               @   s¬   e Zd ZdZdd„ ZeeƒZeeƒZeeƒZ	dd„ Z
eeƒZeeƒZdd„ ZeZedƒZd	d
„ Zdd„ ZeZedƒZdd„ Zdd„ ZeZedƒZdd„ Zdd„ Zdd„ ZdS )ÚAdaptationOfferzÑ An offer to provide adapters from one protocol to another.

    An adaptation offer consists of a factory that can create adapters, and the
    protocols that define what the adapters adapt from and to.

    c             C   s   d}| j }| j}|j||d�S )z/ Return a string representation of the object. z&<AdaptationOffer: '{from_}' -> '{to}'>)Úfrom_Úto)Úfrom_protocol_nameÚto_protocol_nameÚformat)ÚselfÚtemplater   r	   © r   úF/tmp/pip-install-5sebvq2j/traits/traits/adaptation/adaptation_offer.pyÚ__repr__    s    zAdaptationOffer.__repr__c             C   s   | j | jƒS )N)Ú_get_type_nameÚ_from_protocol)r   r   r   r   Ú_get_from_protocol_name@   s    z'AdaptationOffer._get_from_protocol_namec             C   s   | j | jƒS )N)r   Ú_to_protocol)r   r   r   r   Ú_get_to_protocol_nameL   s    z%AdaptationOffer._get_to_protocol_nameFc             C   s,   | j s&t| jtjƒr t| jƒ| _d| _ | jS )z Trait property getter. T)Ú_factory_loadedÚ
isinstanceÚ_factoryÚsixÚstring_typesr   )r   r   r   r   Ú_get_factoryU   s
    zAdaptationOffer._get_factoryc             C   s
   || _ dS )z Trait property setter. N)r   )r   Úfactoryr   r   r   Ú_set_factory`   s    zAdaptationOffer._set_factoryc             C   s,   | j s&t| jtjƒr t| jƒ| _d| _ | jS )z Trait property getter. T)Ú_from_protocol_loadedr   r   r   r   r   )r   r   r   r   Ú_get_from_protocolk   s
    z"AdaptationOffer._get_from_protocolc             C   s
   || _ dS )z Trait property setter. N)r   )r   Úfrom_protocolr   r   r   Ú_set_from_protocolv   s    z"AdaptationOffer._set_from_protocolc             C   s,   | j s&t| jtjƒr t| jƒ| _d| _ | jS )z Trait property getter. T)Ú_to_protocol_loadedr   r   r   r   r   )r   r   r   r   Ú_get_to_protocol�   s
    z AdaptationOffer._get_to_protocolc             C   s
   || _ dS )z Trait property setter. N)r   )r   Úto_protocolr   r   r   Ú_set_to_protocolŒ   s    z AdaptationOffer._set_to_protocolc             C   s(   t |tjƒr|}ndj|j|jd�}|S )a   Returns the full dotted path for a type.

        For example:
        from traits.api import HasTraits
        _get_type_name(HasTraits) == 'traits.has_traits.HasTraits'

        If the type is given as a string (e.g., for lazy loading), it is just
        returned.

        z{module}.{name})ÚmoduleÚname)r   r   r   r   Ú
__module__Ú__name__)r   Ztype_or_type_nameÚ	type_namer   r   r   r   “   s    
zAdaptationOffer._get_type_nameN)r*   r)   Ú__qualname__Ú__doc__r   r   r   r   r!   r
   r   r%   r   r   r   r   r   r   r   r   r   r    r"   r   r#   r$   r&   r   r   r   r   r   r      s,   	r   )
r-   r   Z
traits.apir   r   r   r   Ztraits.util.apir   r   r   r   r   r   Ú<module>   s   