3
:Ad]!6  ã            
   @   sì  d Z ddlmZ ddlZddlZddlmZ ddlmZmZm	Z	 ddl
Z
ddlmZ ddlmZ dd	lmZ eZejZeefZeefZee
jeeeeeeeef
Zd
ZdZdZ G dd„ de!ƒZ"e"ƒ Z dZ#G dd„ de!ƒZ$e$ƒ Z#ddlm%Z% e%j&e#e ƒ G dd„ de!ƒZ'e'ƒ Z'G dd„ de!ƒZ(e(ƒ Z(dd„ Z)ee
jeeeefZ*edeefedeefedeeefe
jde
jefiZ+dd„ Z,dd„ Z-dd„ Z.da/dd„ Z0d d!„ Z1d5d#d$„Z2d6d%d&„Z3e#fd'd(„Z4d)d*„ Z5d+d,„ Z6d-d.„ Z7d/d0„ Z8d1d2„ Z9d3d4„ Z:dS )7zF Defines common, low-level capabilities needed by the Traits package.
é    )Úabsolute_importN)Úgetcwd)ÚdirnameÚexistsÚjoiné   )Ú_py2to3)Ú	LONG_TYPE)Ú	ETSConfigZ__trait_notifier__Z_traits_cache_c               @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	Ú_Uninitializedzò The singleton value of this class represents the uninitialized state
        of a trait and is specified as the 'old' value in the trait change
        notification that occurs when the value of a trait is read before being
        set.
    c             C   s   t d k	rt S tj| ƒ}|S d S )N)ÚUninitializedÚobjectÚ__new__)ÚclsÚself© r   úx/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/traits-5.1.2-py3.6-linux-x86_64.egg/traits/trait_base.pyr   U   s    
z_Uninitialized.__new__c             C   s   dS )Nz<uninitialized>r   )r   r   r   r   Ú__repr__\   s    z_Uninitialized.__repr__c             C   s   t f fS )N)r   )r   Úprotocolr   r   r   Ú__reduce_ex___   s    z_Uninitialized.__reduce_ex__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   N   s   r   c               @   s@   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dS )Ú
_UndefinedzN Singleton 'Undefined' object (used as undefined trait name and/or value)
    c             C   s   t d k	rt S tj| ƒ}|S d S )N)Ú	Undefinedr   r   )r   r   r   r   r   r   w   s    
z_Undefined.__new__c             C   s   dS )Nz<undefined>r   )r   r   r   r   r   ~   s    z_Undefined.__repr__c             C   s   t f fS )N)r   )r   r   r   r   r   r   �   s    z_Undefined.__reduce_ex__c             C   s   t | ƒt |ƒkS )N)Útype)r   Úotherr   r   r   Ú__eq__„   s    z_Undefined.__eq__c             C   s   t t| ƒƒS )N)Úhashr   )r   r   r   r   Ú__hash__‡   s    z_Undefined.__hash__c             C   s   t | ƒt |ƒk	S )N)r   )r   r   r   r   r   Ú__ne__Š   s    z_Undefined.__ne__N)
r   r   r   r   r   r   r   r   r    r!   r   r   r   r   r   s   s   r   )Úctraitsc               @   s   e Zd ZdZdd„ ZdS )ÚMissingzJ Singleton 'Missing' object (used as missing method argument marker).
    c             C   s   dS )Nz	<missing>r   )r   r   r   r   r   ¤   s    zMissing.__repr__N)r   r   r   r   r   r   r   r   r   r#       s   r#   c               @   s   e Zd ZdZdd„ ZdS )ÚSelfzM Singleton 'Self' object (used as object reference to current 'object').
    c             C   s   dS )Nz<self>r   )r   r   r   r   r   µ   s    zSelf.__repr__N)r   r   r   r   r   r   r   r   r   r$   ±   s   r$   c             C   s   t | tƒrt| ƒS t‚dS )zq Wraps the built-in str() function to raise a TypeError if the
    argument is not of a type in StringTypes.
    N)Ú
isinstanceÚStringTypesÚstrÚ	TypeError)Úargr   r   r   ÚstrxÁ   s    
r*   é   c             C   s    t | tjƒrt| ƒS t| jjƒS )z§ Returns a string containing the class name of an object with the
    correct indefinite article ('a' or 'an') preceding it (e.g., 'an Image',
    'a PlotValue').
    )r%   ÚsixÚstring_typesÚadd_articleÚ	__class__r   )r   r   r   r   Úclass_ofâ   s    r0   c             C   s$   | dd… j ƒ dkrd|  S d|  S )zt Returns a string containing the correct indefinite article ('a' or 'an')
    prefixed to the specified string.
    Nr   Zaeiouzan za )Úlower)Únamer   r   r   r.   ó   s    r.   c             C   sN   | j ddƒ} d}d}x0| D ](}|jƒ r2|r2|d7 }|jƒ }||7 }qW |jƒ S )zÞ Returns a "user-friendly" version of a string, with the first letter
    capitalized and with underscore characters replaced by spaces. For example,
    ``user_name_for('user_name_for')`` returns ``'User name for'``.
    Ú_ú Ú F)ÚreplaceÚisupperÚislowerÚ
capitalize)r2   ÚresultZ
last_lowerÚcr   r   r   Úuser_name_for  s    
r<   c               C   s   t dkrtttjdƒƒa t S )z1 Gets the path to the Traits home directory.
    NÚtraits)Ú_traits_homeÚverify_pathr   r
   Zapplication_datar   r   r   r   Útraits_home  s    r@   c          	   C   s(   t | ƒs$ytj| ƒ W n   Y nX | S )z] Verify that a specified path exists, and try to create it if it
        does not exist.
    )r   ÚosÚmkdir)Úpathr   r   r   r?   +  s    r?   é   c             C   s   t j| ƒjjddƒS )zL Returns the name of the module that the caller's caller is located in.
    r   Ú__main__)ÚsysÚ	_getframeÚ	f_globalsÚget)Úlevelr   r   r   Úget_module_name=  s    rK   c          
   C   sü   t j| ƒjjddƒ}d}|dkrHyttt jj|ƒdƒƒ}W n   Y nX |dkrxx&tt jd ƒtƒ gD ]}t	|ƒrfP qfW tt ddƒ}|røt
t dƒršt j}n:|d	kr®tjd
 }n&|dkrÆtjjt jƒ}ntjjt jƒ}d|krø|jdƒ\}}tjj||ƒ}|S )z@Returns a resource path calculated from the caller's stack.
    r   rE   NÚ__file__r   ÚfrozenFÚ_MEIPASSZ
macosx_appZRESOURCEPATHÚdllÚwindows_exeÚconsole_exez.zip/)rO   rP   rQ   )rF   rG   rH   rI   r   ÚgetattrÚmodulesÚargvr   r   ÚhasattrrN   rA   ÚenvironrC   Ú
executableÚsplitr   )rJ   ÚmodulerC   rM   ÚrootÚzippathZ
image_pathr   r   r   Úget_resource_pathH  s0    	
r\   c             C   sr   |j dƒ}x@|dd… D ]0}|tkr0t| |ƒ} qt| |dƒ} | dkr|S qW |tkrbt| |d ƒS t| |d |ƒS )zj Returns the value of an extended object attribute name of the form:
        name[.name2[.name3...]].
    Ú.Nr   éÿÿÿÿr^   r^   )rX   r   rR   )r   ÚxnameÚdefaultÚnamesr2   r   r   r   Úxgetattr|  s    
rb   c             C   s>   |j dƒ}x|dd… D ]}t| |ƒ} qW t| |d |ƒ dS )zg Sets the value of an extended object attribute name of the form:
        name[.name2[.name3...]].
    r]   Nr   r^   r^   )rX   rR   Úsetattr)r   r_   Úvaluera   r2   r   r   r   Úxsetattr•  s    
re   c             C   s   | d kS )Nr   )rd   r   r   r   Úis_none¥  s    rf   c             C   s   | d k	S )Nr   )rd   r   r   r   Únot_none©  s    rg   c             C   s   | dk	S )NFr   )rd   r   r   r   Ú	not_false­  s    rh   c             C   s   | dkS )NÚeventr   )rd   r   r   r   Ú	not_event±  s    rj   c             C   s   t | tjƒS )N)r%   r,   r-   )rd   r   r   r   Úis_strµ  s    rk   )rD   )rD   );r   Ú
__future__r   rA   rF   r   Úos.pathr   r   r   r,   r5   r   r	   Zetsconfig.apir
   Ú	enumerateZ
ClassTypesÚlistÚtupleZSequenceTypesÚfloatÚintZComplexTypesr'   Ú	text_typeÚcomplexÚdictÚboolZ	TypeTypesZTraitNotifierZTraitsCacher   r   r   r   r   r"   Ú
_undefinedr#   r$   r*   r&   ZCoercableTypesr0   r.   r<   r>   r@   r?   rK   r\   rb   re   rf   rg   rh   rj   rk   r   r   r   r   Ú<module>   st   !
	

	

4