3
6ßL]ó  ã               @   s*   d Z ddlmZ G dd„ deƒZeƒ ZdS )z The naming manager. é    )Ú	HasTraitsc               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚNamingManagerz The naming manager. c             C   sF   ddl m} |j|j }x(|D ]}|j|||ƒ}|dk	rP qW |}|S )aº   Returns the state of an object for binding.

        The naming manager asks the context for its list of STATE factories
        and then calls them one by one until it gets a non-None result
        indicating that the factory recognised the object and created state
        information for it.

        If none of the factories recognize the object (or if the context
        has no factories) then the object itself is returned.

        é   )ÚContextN)Úcontextr   ÚenvironmentZSTATE_FACTORIESÚget_state_to_bind)ÚselfÚobjÚnamer   r   Zstate_factoriesZstate_factoryÚstate© r   úD/tmp/pip-install-5sebvq2j/apptools/apptools/naming/naming_manager.pyr      s    
zNamingManager.get_state_to_bindc             C   sF   ddl m} |j|j }x(|D ]}|j|||ƒ}|dk	rP qW |}|S )aÐ   Creates an object using the specified state information.

        The naming manager asks the context for its list of OBJECT factories
        and calls them one by one until it gets a non-None result, indicating
        that the factory recognised the information and created an object.

        If none of the factories recognize the state information (or if the
        context has no factories) then the state information itself is
        returned.

        r   )r   N)r   r   r   ZOBJECT_FACTORIESÚget_object_instance)r	   Úinfor   r   r   Zobject_factoriesZobject_factoryr
   r   r   r   r   9   s    
z!NamingManager.get_object_instanceN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r      s   r   N)r   Z
traits.apir   r   Znaming_managerr   r   r   r   Ú<module>   s   C