B
    :Ra\!                 @   s   d d Z edkre   dS )c                 s  dd l 	dd ldd lydd l
W n tk
r@   dd l
Y nX dd ldd ldd ldd l	dd l
m  m  m dd ldd ldd lG dd dt} G 
fddd| G fddd|  dd	 G  	f
d
ddt}	fddjd }jd }jd }t }|dt|d |dkrV|||}jdd= || |dkr|  d S )N    c               @   s   e Zd Zdd ZdS )z/__rope_start_everything.<locals>._MessageSenderc             S   s   d S )N )selfdatar   r   2lib/python3.7/site-packages/rope/base/oi/runmod.py	send_data   s    z9__rope_start_everything.<locals>._MessageSender.send_dataN)__name__
__module____qualname__r   r   r   r   r   _MessageSender   s   r
   c                   s4   e Zd Z fddZ fddZdd ZdS )z.__rope_start_everything.<locals>._SocketSenderc                s:    jj}|d|f |d| _ || _d S )Nz	127.0.0.1wb)socketZAF_INETZSOCK_STREAMZconnectZmakefilemy_fileZ	b64decodekey)r   portr   s)base64r   r   r   __init__   s    z7__rope_start_everything.<locals>._SocketSender.__init__c                sT   | j jsP |j}| j|j }| j 	 |d | d  d S )N   :   
)
r   closedZ	b64encodedumpsZHIGHEST_PROTOCOLnewr   Zsha256Zdigestwrite)r   r   Zpickled_dataZdgst)r   hashlibhmacpickler   r   r      s    z8__rope_start_everything.<locals>._SocketSender.send_datac             S   s   | j   d S )N)r   close)r   r   r   r   r   &   s    z4__rope_start_everything.<locals>._SocketSender.closeN)r   r   r	   r   r   r   r   )r   r   r   r   r   r   r   _SocketSender   s   r   c                   s(   e Zd Zdd Z fddZdd ZdS )z,__rope_start_everything.<locals>._FileSenderc             S   s   t |d| _d S )Nr   )openr   )r   	file_namer   r   r   r   +   s    z5__rope_start_everything.<locals>._FileSender.__init__c                s   | j js || j  d S )N)r   r   dump)r   r   )marshalr   r   r   .   s    z6__rope_start_everything.<locals>._FileSender.send_datac             S   s   | j   d S )N)r   r   )r   r   r   r   r   2   s    z2__rope_start_everything.<locals>._FileSender.closeN)r   r   r	   r   r   r   r   )r!   r   r   _FileSender)   s   r"   c                s   i   fdd}|S )Nc                s&   | kr | S | |}| |< |S )Nr   )r   argresult)cachefuncr   r   newfunc8   s
    
z9__rope_start_everything.<locals>._cached.<locals>.newfuncr   )r&   r'   r   )r%   r&   r   _cached5   s    z(__rope_start_everything.<locals>._cachedc                   s   e Zd Z fddZdd Zdd ZfddZfd	d
ZfddZfddZ		fddZ
fddZdd ZfddZdS )z8__rope_start_everything.<locals>._FunctionCallDataSenderc                sb   | _ |d  r4|dd\}}t|| _n
| _ fdd}| | d S )Nr   :   c                s     | r jS d S )N)_is_an_interesting_callon_function_call)frameeventr#   )r   r   r   global_traceJ   s    
zW__rope_start_everything.<locals>._FunctionCallDataSender.__init__.<locals>.global_trace)project_rootisdigitsplitintsendersettrace)r   	send_infor0   r   r   r/   )r"   r   sys	threading)r   r   r   B   s    

zA__rope_start_everything.<locals>._FunctionCallDataSender.__init__c       
   
   S   s   |dkrd S g }d}|j }xZ|jd |j D ]F}y| |j| }|| W q, ttfk
rp   |d Y q,X q,W y| |}W n ttfk
r   Y nX y&| |j t||f}	| j	
|	 W n tk
r   Y nX | jS )Nreturn)unknown)f_codeco_varnamesco_argcount_object_to_persisted_formf_localsappend	TypeErrorAttributeErrortupler4   r   r,   )
r   r-   r.   r#   argsZreturnedcodeargnameZargvaluer   r   r   r   r,   R   s.    
zI__rope_start_everything.<locals>._FunctionCallDataSender.on_function_callc             S   s(   |  |js$|jr |  |jjs$dS dS )NFT)_is_code_inside_projectr;   f_back)r   r-   r   r   r   r+   k   s
    zP__rope_start_everything.<locals>._FunctionCallDataSender._is_an_interesting_callc                s0   |  |j}|d k	o.j|o. || jS )N)_pathco_filenamepathexists
startswithr0   )r   rE   source)	_realpathosr   r   rG   v   s    zP__rope_start_everything.<locals>._FunctionCallDataSender._is_code_inside_projectc                s4   |  |j}j|s tdd |t|jfS )Nz	no sourcedefined)rI   rJ   rK   rL   rA   strco_firstlineno)r   object_rN   )rO   rP   r   r   _get_persisted_code{   s    zL__rope_start_everything.<locals>._FunctionCallDataSender._get_persisted_codec          	      s4   yd  ||jfS  ttfk
r.   dS X d S )NrQ   )r:   )Zgetsourcefiler   rA   rB   )r   rT   )rO   inspectr   r   _get_persisted_class   s
    zM__rope_start_everything.<locals>._FunctionCallDataSender._get_persisted_classc                s<  t | jrdS t |trBd }t|dkr2|d }dd| |fS t |trd }d }t|dkr~dd | D d }|| }dd| || |fS t |trg }t|dk rx2|D ]}|| | qW n|| |d  tdd	g| S t |t	r8d }t|dkr(x|D ]}|}P qW dd
| |fS dS )N)builtinrR   r   rX   listc             S   s   g | ]}|d kr|qS )Z
__locals__r   ).0r   r   r   r   
<listcomp>   s    zc__rope_start_everything.<locals>._FunctionCallDataSender._get_persisted_builtin.<locals>.<listcomp>dict   rC   set)r:   )

isinstancestring_typesrY   lenr>   r\   keysrC   r@   r^   )r   rT   Zholdingrb   valuesZobjectso)pycompatr   r   _get_persisted_builtin   sB    




zO__rope_start_everything.<locals>._FunctionCallDataSender._get_persisted_builtinc                s   |d krdS t |jr"| |S t |jr:| |jS t |jrT| |jjS t |jrj| |S t | j	t
tttf r| |S t |tr| |S d| t|fS )N)Znoneinstance)r_   CodeTyperU   FunctionType__code__
MethodType__func__
ModuleType_get_persisted_moduler`   rY   r\   rC   r^   rf   typerW   )r   rT   )re   typesr   r   r>      s    




zR__rope_start_everything.<locals>._FunctionCallDataSender._object_to_persisted_formc                s,   |  |j}|r(j|r(d |fS dS )NrQ   )r:   )rI   __file__rK   rL   )r   rT   rK   )rO   rP   r   r   rn      s    zN__rope_start_everything.<locals>._FunctionCallDataSender._get_persisted_modulec             S   s(   | dr|d d }| dr$|S d S )Nz.pycz.py)endswith)r   rK   r   r   r   rI      s    

z>__rope_start_everything.<locals>._FunctionCallDataSender._pathc                s   | j    d  d S )N)r4   r   r5   )r   )r7   r   r   r      s    
z>__rope_start_everything.<locals>._FunctionCallDataSender.closeN)r   r   r	   r   r,   r+   rG   rU   rW   rf   r>   rn   rI   r   r   )
r"   r   r(   rO   rV   rP   re   r7   r8   rp   r   r   _FunctionCallDataSender@   s   &rt   c                s    j  j  j | S )N)rK   realpathabspath
expanduser)rK   )rP   r   r   rO      s    z*__rope_start_everything.<locals>._realpathr*      r]   __main__)r   __builtins__rq   -   )rP   r7   r   ZcPickleImportErrorr   r!   rV   rp   r8   Zrope.base.utils.pycompatbaseZutilsre   r   r   r   objectargvglobalsupdaterz   Zexecfiler   )r
   rt   r6   r0   Zfile_to_runrun_globalsZdata_senderr   )r"   r   r(   rO   r   r   r   rV   r!   rP   r   re   r   r7   r8   rp   r   __rope_start_everything   sF    & 






r   ry   N)r   r   r   r   r   r   <module>   s    e