B
    ud              
   @   sx  d dl mZ d dlZd dlZd dlZd dlmZmZmZ erJd dl	m
Z
 nd dlm
Z
 erd dlZd dlm
Z
 dd Zd dlmZ dd	 Zd
d Zd dlmZ dd ZeZyd dlmZ W n  ek
r   d dlmZ Y nX eZeZeZnVd dl Z d dl	m
Z
 e jZe jZe jZe j!Z!e jZe jZe jZe jZe jZe jZe jZerPdddZ!erpdd	ddddddddg
Z"ng Z"dS )    )unicode_literalsN)PY2PY3exec_)Mappingc             O   s
   | ||S )N )fargskwr   r   _/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/past/builtins/misc.pyapply   s    r   )strc             C   s   t t| fS )zU
        Return a byte-string of one character with ordinal i; 0 <= i <= 256
        )oldstrbytes)ir   r   r   chr   s    r   c          
      sl  t  trt trtdyt  tjrft rft tjsTtdjtdt t	rbdS dS t tjrtrt  tjstdjt dt  t	rdS dS  k k  S  tk
rf    krdS td	tjt
ttttfg}d	 }}x6t|D ]*\}}t  |r|}t |r|}qW t||dkr\t  trlt trlt d
S t trt  trt d
S t  trx0t D ]"\}}t||}	|	dkr|	S qW dS t  t
r\t tkrtt tS t fdd D }
t fddD }|
|krJt|
|S t |
 | S t||S X d	S )z
        cmp(x, y) -> integer

        Return negative if x<y, zero if x==y, positive if x>y.
        Python2 had looser comparison allowing cmp None and non Numerical types and collections.
        Try to match the old behavior
        zcannot compare sets using cmp()z.cannot compare float("nan"), {type_y} with cmp)Ztype_y   z.cannot compare {type_x}, float("nan") with cmp)Ztype_xr   Nasciic             3   s*   | ]"}|ks | | kr|V  qd S )Nr   ).0a)xyr   r   	<genexpr>X   s    zcmp.<locals>.<genexpr>c             3   s*   | ]"}| ks | | kr|V  qd S )Nr   )r   b)r   r   r   r   r   Y   s    )
isinstanceset	TypeErrornumbersNumbermathisnanformattypeintdictlistr   r   	enumeratecmpdecodeziplenmin)r   r   Z
type_orderZx_type_indexZy_type_indexr   Z
type_matchZx_elemZy_elemZelem_cmp_valZx_keyZy_keyr   )r   r   r   r(      sd    








r(   )internc             C   s   dt | dd  S )zUoct(number) -> string

        Return the octal representation of an integer
        0   N)builtinsoct)numberr   r   r   r1   b   s    r1   )reloadc          	   C   s   |dkr*t  d }|d j}|d j}n|dkr6|}t|tsHtdt|tsZtdt| d}| }W dQ R X t	|| d}t
||| dS )z
        Read and execute a Python script from a file in the given namespaces.
        The globals and locals are dictionaries, defaulting to the current
        globals and locals. If only globals is given, locals defaults to it.
        Nr   r   zglobals must be a mappingzlocals must be a mappingrbexec)inspectstack	f_globalsf_localsr   r   r   openreadcompiler   )filenameZ	myglobalsZmylocalscaller_frameZfinsourcecoder   r   r   execfile   s    


rA   r-   	raw_inputr3   unichrunicodexrange)NN)#
__future__r   r6   r    r   Zfuture.utilsr   r   r   collectionsr   collections.abcr0   r   Zpast.builtinsr   r   r   r(   sysr-   r1   inputrB   	importlibr3   ImportErrorimprD   rC   rangerE   __builtin__rA   __all__r   r   r   r   <module>   sV   C
