3
AAd]l  ã               @   s¤   d Z ddlmZmZmZmZmZmZmZm	Z	m
Z
 ddlmZ eedd�Zdd„ Zd	d
„ Zedd�Zedd�Zedd�Zedd�Zdd„ Zdd„ ZG dd„ de	ƒZdS )z? Trait definitions useful when creating templatizable classes.
é    )	ÚInstanceÚIntÚFloatÚStrÚListÚBoolÚRangeÚ	TraitTypeÚ	Undefinedé   )ÚITemplateDataSourceZ
datasource)Útemplatec              O   s   d|d< t | |ŽS )NÚinstancer   )r   )ÚargsÚkw© r   ú}/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/apptools-4.4.0-py3.6.egg/apptools/template/template_traits.pyÚ	TInstance"   s    r   c              O   s   d|d< t | |ŽS )Nr   r   )r   )r   r   r   r   r   ÚTList'   s    r   Úcopyc              O   s   d|d< t | |ŽS )Nr   r   )r   )r   r   r   r   r   ÚTRange1   s    r   c              O   s   d|d< t | |ŽS )Nr   r   )ÚEnum)r   r   r   r   r   ÚTEnum5   s    r   c               @   s*   e Zd ZdZdddœZdd„ Zdd„ Zd	S )
ÚTDeriveda)   Defines a trait property for handling attributes whose value depends
        upon the templatizable traits of an object.

        Note that the implementation of the *activate_template* method is not
        allowed to read the value of any **TDerived** traits, it may only set
        them.
    ZderivedT)r   Z	transientc             C   sR   |d7 }|j j|tƒ}|tk	r"|S |jƒ  |j j|tƒ}|tk	rD|S d |j |< d S )NÚ_)Ú__dict__Úgetr
   Zactivate_template)ÚselfÚobjectÚnameÚvaluer   r   r   r   J   s    
zTDerived.getc             C   s:   |d }|j j|tƒ}||k	r6||j |< |j|||ƒ d S )Nr   )r   r   r
   Ztrait_property_changed)r   r   r   r    ZxnameÚoldr   r   r   ÚsetY   s
    
zTDerived.setN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úmetadatar   r"   r   r   r   r   r   =   s
   r   N)r&   Z
traits.apir   r   r   r   r   r   r   r	   r
   Zitemplate_data_sourcer   ZTDataSourcer   r   ZTIntZTFloatZTStrZTBoolr   r   r   r   r   r   r   Ú<module>   s   ,



