3
:Ad].
  ã               @   s"  d Z ddlmZmZ ddlZddlZejr0eZne	ZejrPddl
Z
e
jZe
jZnejZejZejr”ddlmZmZ dd„ Zdd„ Zd	d
„ Zdd„ Zn dd„ Zdd„ Zdd
„ Zdd„ ZejrÐddlmZ dd„ ZneZejrðddlmZ eefZnefZej�rdd„ ZnejZG dd„ deƒZdS )zl Helper module, providing a common API for tasks that require a different implementation in python 2 and 3.
é    )ÚdivisionÚabsolute_importN)ÚInstanceTypeÚ	ClassTypec             C   s   t | ƒtkS )N)Útyper   )Úobj© r   úu/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/traits-5.1.2-py3.6-linux-x86_64.egg/traits/_py2to3.pyÚis_old_style_instance!   s    r
   c             C   s   t | ƒtkS )N)r   r   )r   r   r   r	   Úis_old_style_class$   s    r   c             C   s   | t kS )N)r   )r   r   r   r	   Úis_InstanceType'   s    r   c             C   s   | t kS )N)r   )r   r   r   r	   Úis_ClassType*   s    r   c             C   s   dS )NFr   )r   r   r   r	   r
   0   s    c             C   s   dS )NFr   )r   r   r   r	   r
   3   s    c             C   s   dS )NFr   )r   r   r   r	   r   6   s    c             C   s   dS )NFr   )r   r   r   r	   r   9   s    )r   c             C   s   t | ƒ}|tkr| j}|S )N)r   r   Ú	__class__)r   Zthe_typer   r   r	   Útype_w_old_style@   s    r   )r   c              G   s
   t j| Ž S )N)Ú
contextlibÚnested)Úargsr   r   r	   Únested_context_mgrsS   s    r   c                   s(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )r   a†   Emulation of python 2's :py:class:`contextlib.nested`.

        It has gone from python 3 due to it's deprecation status
        in python 2.

        Note that :py:class:`contextlib.nested` was deprecated for
        a reason: It has issues with context managers that fail
        during init. The same caveats also apply here.
        So do not use this unless really necessary!
        c                s   t t| ƒjƒ  || _d S )N)Úsuperr   Ú__init__Ú
_ctxt_mgrs)Úselfr   )r   r   r	   r   d   s    znested_context_mgrs.__init__c          
   C   sH   g }y$x| j D ]}|j| j|ƒƒ qW W n   | jƒ  ‚ Y nX t|ƒS )N)r   ÚappendÚenter_contextÚcloseÚtuple)r   ÚretZmgrr   r   r	   Ú	__enter__h   s    znested_context_mgrs.__enter__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__r   r   )r   r	   r   X   s   
)r!   Ú
__future__r   r   r   ÚsixÚPY2ÚlongZ	LONG_TYPEÚintÚstringÚfindZstr_findÚrfindZ	str_rfindÚstrÚtypesr   r   r
   r   r   r   r   r   Z
ClassTypesr   Ú	ExitStackr   r   r   r	   Ú<module>   sD   



