3
8Ad]&	  ã               @   s2   d Z ddlmZ ddlZddlmZ ddd„ZdS )	zV Generates a file containing definitions for editors defined in the various
backends.
é    )Úabsolute_importN)Úopenú
editors.pyc             C   sÈ   t j dƒ}g }xP|D ]H}|jdƒ}t|tƒ dd�}x(t|ƒD ]}d|kr<|jt||ƒƒ q<W qW t| dƒ}xP|D ]H}d|jdƒd  }	|j	|	ƒ d}
|
dd|  7 }
|j	|
ƒ |j	dƒ qpW |j
ƒ  dS )aŽ   Generates a file containing definitions for editors defined in the
       various backends.

    The idea is that if a new editor has been declared in any of the backends,
    the author needs to create a file called '<myeditor>_definition' in the
    Traits package (in traitsui). This function will be run each time
    the user runs the setup.py file, and the new editor's definition will be
    appended to the editors.py file.

    The structure of the <myeditor>_definition file should be as follows::

        myeditor_definition = '<file name in the backend package>:
                         <name of the Editor or the EditorFactory class'
    z*_definition.pyz.pyé   )ÚglobalsÚlevelZ_definitionÚaz
def %s( *args, **traits ):
ú:ú é   z#from toolkit import toolkit_object
z.return toolkit_object("%s")( *args, **traits )z

Nz    z'    from toolkit import toolkit_object
z    )ÚglobÚrstripÚ
__import__r   ÚdirÚappendÚgetattrr   ÚsplitÚwriteÚclose)Ztarget_filenameZdefinition_filesZnew_editorsÚfileZimport_pathÚmodÚnameÚtarget_fileZeditor_nameÚfunctionÚ	func_code© r   úp/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/traitsui-6.1.2-py3.6.egg/traitsui/editors_gen.pyÚgen_editor_definitions   s&    







r   )r   )Ú__doc__Ú
__future__r   r   Úior   r   r   r   r   r   Ú<module>   s   