3
6ßL]_  ã               @   sX   d dl mZmZmZ d dlmZ ddlmZ dadd„ Z	dd	„ Z
d
d„ Zefdd„ZdS )é    )ÚAnyÚPropertyÚ	Undefined)Ú
trait_casté   )Úget_script_managerTc                s.   ‡ fdd„}ˆ j |_ ˆ j|_|jjˆ jƒ |S )zb This is the decorator applied to functions and methods to mark them as
    being scriptable.
    c           
      s~   t rpda tƒ }ˆ jdkrT|j| d t| d ƒ| dd… |ƒ zˆ | |Ž}W dda X qzz|jˆ | |ƒ}W dda X n
ˆ | |Ž}|S )zY This is the wrapper that is returned in place of the scriptable
        method.
        FÚ__init__r   r   NT)Ú_outermost_callr   Ú__name__Z
new_objectÚtypeZrecord_method)ÚargsÚkwargsÚsmÚresult)Úfunc© úF/tmp/pip-install-5sebvq2j/apptools/apptools/appscripting/scriptable.pyÚ	_scripter"   s    
$
zscriptable.<locals>._scripter)r
   Ú__doc__Ú__dict__Úupdate)r   r   r   )r   r   Ú
scriptable   s
    !r   c             C   sP   t }da z(t| d| dƒ}|dkr.| j|ƒj}W d|a X |rLtƒ j| ||ƒ |S )z$ The getter for a scriptable trait. FÚ_N)r	   ÚgetattrÚtraitÚdefaultr   Zrecord_trait_get)ÚobjÚnameZsaved_outermostr   r   r   r   Ú_scriptable_getJ   s    r   c             C   sN   t rtƒ j| ||ƒ d| }t| |tƒ}||k	rJt| ||ƒ | j|||ƒ dS )z$ The setter for a scriptable trait. r   N)r	   r   Zrecord_trait_setr   r   ÚsetattrZtrait_property_changed)r   r   ÚvalueÚ_nameÚ	old_valuer   r   r   Ú_scriptable_set`   s    r#   c             K   s.   t | ƒ} | jƒ d |d< tttfd| i|—ŽS )a€   Scriptable is a wrapper around another trait that makes it scriptable,
    ie. changes to its value can be recorded.  If a trait is read, but the
    value isn't set to another scriptable trait or passed to a scriptable
    method then the read will not be included in the recorded script.  To make
    sure a read is always recorded set the 'has_side_effects' argument to True.
    r   r   r   )r   Údefault_valuer   r   r#   )r   Úmetadatar   r   r   Ú
Scriptablen   s    r&   N)Z
traits.apir   r   r   Ztraits.traitsr   Zpackage_globalsr   r	   r   r   r#   r&   r   r   r   r   Ú<module>   s   -