3
<Ad]K  ã               @   sF   d Z ddlZddlmZmZ ddlmZ ejeƒZ	G dd„ deƒZ
dS )z: The node manager looks after a collection of node types. é    N)ÚHasPrivateTraitsÚListé   )ÚNodeTypec                   sL   e Zd ZdZeeƒZeZ‡ fdd„Zdd„ Z	dd„ Z
dd	„ Zd
d„ Z‡  ZS )ÚNodeManagerz: The node manager looks after a collection of node types. c                s   t t| ƒjf |Ž i | _dS )z Creates a new tree model. N)Úsuperr   Ú__init__Ú_node_to_type_map)ÚselfÚtraits)Ú	__class__© úr/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/pyface-6.1.2-py3.6.egg/pyface/tree/node_manager.pyr   .   s    zNodeManager.__init__c             C   s   | |_ | jj|ƒ dS )z& Adds a new node type to the manager. N)Únode_managerÚ
node_typesÚappend)r
   Ú	node_typer   r   r   Úadd_node_typeC   s    zNodeManager.add_node_typec             C   sh   | j |ƒ}| jj|dƒ}|dkrJx(| jD ]}|j|ƒr(|| j|< P q(W d}|dkrdtjdt|ƒ ƒ |S )zq Returns the node's type.

        Returns None if none of the manager's node types recognize the node.

        Nzno node type for %s)Úget_keyr	   Úgetr   Zis_type_forÚloggerÚwarnÚstr)r
   ÚnodeÚkeyr   r   r   r   Úget_node_typeK   s    


zNodeManager.get_node_typec          	   C   s&   yt |ƒ}W n   t|ƒ}Y nX |S )zt Generates a unique key for a node.

        In this case,  'unique' means unqiue within the node manager.

        )ÚhashÚid)r
   r   r   r   r   r   r   l   s
    
zNodeManager.get_keyc             C   s   x|D ]
}| |_ qW dS )z= Called when the entire list of node types has been changed. N)r   )r
   Únewr   r   r   r   Ú_node_types_changed‚   s    

zNodeManager._node_types_changed)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Zsystem_actionsr   r   r   r   r   Ú__classcell__r   r   )r   r   r      s   !r   )r#   ÚloggingZ
traits.apir   r   r   r   Ú	getLoggerr    r   r   r   r   r   r   Ú<module>   s
   
