3
ËœŸW�  ã               @   sî   d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ d
dlmZ dd„ ZG dd„ de
ƒZG dd„ de
ƒZxHejD ]>Zeejƒdkr¨ejejedœZeejefeƒZ e e!ƒ ej< q¨W dS )z)An action to open various source files.

é    )Úisfile)ÚInstanceÚStr)Ú
FileDialogÚOK)ÚAction)Úget_imayavi)Úerror)ÚMetadata)Úregistryé   )Ú	new_classc             C   s&   | j j}|dkr"| j jƒ  | j j}|S )zgGiven a mayavi script instance, get the current scene.  If none
    is available create a new one.
    N)ÚengineÚcurrent_sceneZ	new_scene)ÚmayaviÚs© r   úX/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/action/sources.pyÚ	get_scene   s
    
r   c               @   s(   e Zd ZdZdZdZedƒZdd„ ZdS )ÚOpenFilezN An action that opens a data file depending on the supported
    extensions.  zOpen a supported data filezOpen any supported data filezMenuBar/File/LoadDataMenuc             C   sÒ   t | jƒ}t|ƒ}|dkrdS d}xLtjD ]B}t|jƒdkr*|jdƒsR|jj	dƒr^||j7 }q*|d|j 7 }q*W | jj
}t|dd|d�}|jƒ tkrÎt|jƒs²td|j |ƒ dS |j|jƒ}|dk	rÎ||j_dS )	z Performs the action. NzAll files (*.*)|*.*r   ú|zOpen supported data fileÚopen)ÚparentÚtitleÚactionÚwildcardzFile '%s' does not exist!)r   Úwindowr   r   ÚsourcesÚlenÚ
extensionsÚendswithr   Ú
startswithÚcontrolr   r   r   r   Úpathr	   r   Úcurrent_selection)ÚselfÚeventÚmvr   r   Úsrcr   Zdialogr   r   r   Úperform7   s,    



zOpenFile.performN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚtooltipÚdescriptionr   r#   r)   r   r   r   r   r   )   s
   r   c               @   s   e Zd ZeeƒZdd„ ZdS )ÚSourceActionc             C   sD   t | jƒ}t|ƒ}|d krd S | jjƒ }|ƒ }|j|ƒ ||j_d S )N)r   r   r   ÚmetadataÚget_callableZ
add_sourcer   r$   )r%   r&   r'   r   ÚcallableÚobjr   r   r   r)   _   s    


zSourceAction.performN)r*   r+   r,   r   r
   r1   r)   r   r   r   r   r0   Z   s   r0   )r.   r/   r1   N)"r-   Úos.pathr   Ú
traits.apir   r   Ú
pyface.apir   r   Úpyface.action.apir   Zmayavi.plugins.scriptr   Úmayavi.core.commonr	   Úmayavi.core.metadatar
   Úmayavi.core.registryr   Úfiltersr   r   r   r0   r   r(   r   r   r.   ÚdescÚdÚidr   Úglobalsr   r   r   r   Ú<module>   s&   1