B
    d                 @   s   d dl mZmZmZ d dlZd dlZejdd ZG dd deZ	edk rze	Z[	yd dl
Z
ee
_W q~ ek
rv   Y q~X neZG dd deZd	d
 Zedk re  dS )    )absolute_importdivisionprint_functionN   c               @   s<   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zg Z	dS )	newobjectz
  A magical object class that provides Python 2 compatibility methods::
      next
      __unicode__
      __nonzero__

  Subclasses of this class can merely define the Python 3 methods (__next__,
  __str__, and __bool__).
  c             C   s$   t | drt| | S tdd S )N__next__znewobject is not an iterator)hasattrtyper   	TypeError)self r   {/mnt/filia/a/genomebrowser/www/genomebrowser/fleming/tools/molprobity/modules/cctbx_project/libtbx/forward_compatibility.pynext   s    
znewobject.nextc             C   s>   t | drt| | }nt| }t|tr0|S |dS d S )N__str__zutf-8)r   r	   r   str
isinstanceZunicodedecode)r   sr   r   r   __unicode__   s    

znewobject.__unicode__c             C   s4   t | drt| | S t | dr0t| | S dS )N__bool____len__T)r   r	   r   r   )r   r   r   r   __nonzero__&   s
    

znewobject.__nonzero__c             C   s   t | dstS |  S )N__int__)r   NotImplementedr   )r   r   r   r   __long__5   s    
znewobject.__long__c             C   s   t | S )z9
      Hook for the future.utils.native() function
      )object)r   r   r   r   
__native__O   s    znewobject.__native__N)
__name__
__module____qualname____doc__r   r   r   r   r   	__slots__r   r   r   r   r      s   	r   )   r   c               @   s   e Zd Zdd Zdd ZdS )_advertise_subprocessc             C   s   || _ || _d S )N)function_idtarget)r   r$   r%   r   r   r   __init__g   s    z_advertise_subprocess.__init__c             O   s\   dt jkrPdd l}|jjs$|j rPdd }| sPddlm} |d| j dd | j	||S )	NZLIBTBX_BUILDr   c              S   s   ddl m}  d}xy| |}W n tk
r4   P Y qX |jj}xtj|\}}t|dksht|dkrjP |	 }|
ds|dkrtj|sdS xPdD ] }tjtj||d sP qW dS n"|d	krtjtj|d
rdS |}q@W |d7 }qW dS )Nr   )	_getframe   ZpythonlibT)osStringIOUserDictUserList
UserStringz.pyZsconszSConsign.pyF)sysr'   
ValueErrorf_codeco_filenamer*   pathsplitlenlower
startswithisdirisfilejoin)r'   Zframes_backfpdbnr   r   r   is_exceptionp   s6       

z4_advertise_subprocess.__call__.<locals>.is_exception)warnzL%s is not safe: please use the subprocess module or libtbx.easy_run instead.r   )message
stacklevel)
r*   environZlibtbx.load_envenvZfull_testingZis_development_environmentwarningsrA   r$   r%   )r   argskwargslibtbxr@   rA   r   r   r   __call__k   s    

z_advertise_subprocess.__call__N)r   r   r   r&   rJ   r   r   r   r   r#   e   s   r#   c              C   sF   x@dD ]8} t t| d }|d k	rtd|  d |d}tt| | qW d S )N)systempopenZpopen2Zpopen3Zpopen4spawnlspawnlespawnlpspawnlpespawnvspawnvespawnvpspawnvpezos.z())r$   r%   )getattrr*   r#   setattr)fnr;   wr   r   r   _install_advertise_subprocess   s
    
rY   )
__future__r   r   r   r/   r*   version_infoZ
_vers_infor   r   builtinsImportErrorr#   rY   r   r   r   r   <module>   s"   P
.
