3
8ßL]_  ã               @   sX   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ dd„ ZdS )	z[ Generates a file containing definitions for all of the editors defined in
the WX backend.
é    )Úabsolute_importN)ÚEditor)ÚEditorFactory)Úopenc             C   s.  t | dƒ}tjjtjjtƒƒ}g }xDtj|ƒD ]6\}}}d|krJ|jdƒ |jt	j	tjj
|dƒƒƒ q.W �x¶|D �]¬}tjj|ƒtjj|ƒjdƒ }}	d|j|dƒjtjdƒ d |	 }
t|
ƒ tj|
 }g }x°t|ƒD ]¤}yPtt||ƒtƒoô|dk�r|j|ƒ n&tt||ƒtƒ�r*|d
k�r*|j|ƒ W qØ   y4tt||ƒtƒ�sZtt||ƒtƒ�rf|jd|ƒ W n   Y nX Y qØX qØW t|ƒdkrpd|k�rœd}n,dj
dd„ |	jdƒD ƒƒ}||k�rÈ|d }dtƒ  }|j|ƒ |jdƒ ddtƒ   d }|ddtƒ   7 }|j|ƒ |jdƒ qpW |jƒ  dS )zc Generates a file containing definitions for all of the editors
    defined in the Qt backend.
    Úwz.svnz*_editor.pyz.pyztraitsui.wxÚ Ú.r   ÚBasicEditorFactoryr   r   ZToolkitEditorFactoryc             S   s   g | ]}|j ƒ ‘qS © )Ú
capitalize)Ú.0Únamer
   r
   ú=/tmp/pip-install-5sebvq2j/traitsui/traitsui/wx/editors_gen.pyú
<listcomp>D   s    z*gen_editor_definitions.<locals>.<listcomp>Ú_z"def %(filename)s(*args, **traits):Ú
ú é   z import %(import_path)s as editorz-return editor.%(class_name)s(*args, **traits)z

N)r   r	   z    z    )r   ÚosÚpathÚdirnameÚabspathÚ__file__ÚwalkÚremoveÚextendÚglobÚjoinÚbasenameÚrstripÚreplaceÚsepÚ
__import__ÚsysÚmodulesÚdirÚ
issubclassÚgetattrr   Úappendr   Ú
isinstanceÚinsertÚlenÚsplitÚlocalsÚwriteÚclose)Ztarget_filenameZtarget_fileÚdirpathZeditor_filesÚrootÚdirsÚfilesZabsfilenamer   ÚfilenameZimport_pathÚmoduleZclass_namesr   Ú
class_nameÚfunctionÚ	func_coder
   r
   r   Úgen_editor_definitions   sZ    


"









r9   )Ú__doc__Ú
__future__r   r   r   r#   Ztraitsui.apir   Ztraitsui.editor_factoryr   Úior   r9   r
   r
   r
   r   Ú<module>   s   