a
    «ˆc2  ã                   @   s8   d dl mZmZmZmZ d dlmZ G dd„ deƒZdS )é    )Ú	HasTraitsÚListÚStrÚInstance)ÚPreferencesHelperc                   @   s8   e Zd ZdZeeƒZeeƒZ	dd„ Z
dd„ Zdd„ ZdS )	ÚPreferencesMirrorz¼
    This class mirrors preferences from a PreferencesHelper such that
    users can use them and change them but nothing is saved to disk till
    the user asks for an explicit save.
    c                 C   s$   | j D ]}t| j|t| |ƒƒ qdS )zRUpdates the actual preferences and thereby persists them to
        disk.
        N)Ú_trait_namesÚsetattrÚpreferencesÚgetattr)ÚselfÚname© r   úb/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/tools/preferences_mirror.pyÚsave   s    
zPreferencesMirror.savec                 C   sh   g }| j }| ¡  ¡ D ]F\}}|dvr|  ||¡ t| |t||ƒƒ | |¡ | | j|¡ q|| _	dS )zRSetup traits of our own based on those of the mayavi
        preferences.
        )Ztrait_addedZtrait_modifiedr
   Zpreferences_pathN)
r
   ZtraitsÚitemsZ	add_traitr	   r   ÚappendZon_trait_changeÚ_updater   )r   Ztrait_namesÚoptsÚkeyÚvaluer   r   r   Ú_preferences_changed'   s    
z&PreferencesMirror._preferences_changedc                 C   s   t | ||ƒ d S )N)r	   )r   Úobjr   ÚoldÚnewr   r   r   r   6   s    zPreferencesMirror._updateN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r
   r   r   r   r   r   r   r   r   r   r   r      s   
r   N)Z
traits.apir   r   r   r   Zapptools.preferences.apir   r   r   r   r   r   Ú<module>   s   