3
^,                 @   sh  d dl Z d dlZd dlZd dlZd dlZd dlmZmZ d dlj	Z
d dlZd dlmZmZ d dlmZmZmZmZmZmZmZ d dlmZ dd Zdd	 Zejfd
dZdddZdddZdddZ e!dkrdee"Z#ee"Z$ee$\Z%Z&Z'Z(Z)Z*Z+e,de%de'd	e) e&dk	r*d dl-Z-e,e-j-j.e& e*dk	r@e,de*  e+dk	rVe,de+  e#e(ksdt/dS )    N)unpackpack)PYTHON3PYTHON_VERSION)IS_PYPY3PYTHON_MAGIC_INT	int2magicmagic_int2float	magic2intmagicint2versionversions)fix_dropbox_pycc             C   s   | j dry*dd l}|jj| dd}tj|r2|S W n4   ydd l}|j| dd W n   Y nX Y nX tj| dd }tr| }n
| j	d}t
j|d	 d
ddd } tj|| dd | j d
 r| j d rtd|  | S )Nz.pyr    )optimizationF)debug_override   zutf-8-z.pyc)prefixsuffixtext   T)cfiledoraisez.pyoz)path %s must point to a .py or .pyc file
)endswith	importlibutilcache_from_sourceospexistsimpbasenamer   decodetempfilemkstemp
py_compilecompile
ValueError)pathr   bytecode_pathr    r!   Zspath r*   F/home/psgendb/BIRCHDEV/python/lib/python3.6/site-packages/xdis/load.pycheck_object_path"   s,    


r,   c             C   s   | dt  kS )Ni     il  
  s  )r.   r/   )r   )	magic_intr*   r*   r+   is_pypy>   s    r1   c             C   sv   t | d}z\|j }y*tdk r,t|| d}nt|| ddd}W n$ tk
rb   |jd|    Y nX W d|j  X |S )a.  
    load a Python source file and compile it to byte-code
    _load_file(filename: string): code_object
    filename:	name of file containing Python source code
                (normally a .py)
    code_object: code_object compiled from this source code
    This function does NOT write any file!
    rbg@execT)dont_inheritz>>Syntax error in %s
N)openreadr   r&   SyntaxErrorwriteclose)filenameoutfpsourcecor*   r*   r+   	load_fileB   s    	

r?   FTc             C   s|   t j| std|  n<t j| s0td|  n$t j| dk rTtd| t j| f t| d}t|| |||dS Q R X dS )ah  load a module without importing it.
    Parameters:
       filename:    name of file containing Python byte-code object
                    (normally a .pyc)

       code_objects: list of additional code_object from this
                     file. This might be a types.CodeType or one of
                     the portable xdis code types, e.g. Code38, Code3,
                     Code2, etc. This can be empty

       get_code:     bool. Parsing the code object takes a bit of
                     parsing time, but sometimes all you want is the
                     module info, time string, code size, python
                     version, etc. For that, set `get_code` to
                     `False`.

    Return values are as follows:
        float_version: float; the floating-point version number for the given magic_int,
                       e.g. 2.7 or 3.4
        timestamp: int; the seconds since EPOCH of the time of the bytecode creation, or None
                        if no timestamp was stored
        magic_int: int, a more specific than version number. The actual byte code version of the
                   code object
        co         : code object
        ispypy     : True if this was a PyPy code object
        source_size: The size of the source code mod 2**32, if that was stored in the bytecode.
                     None otherwise.
        sip_hash   : the SIP Hash for the file (only in Python 3.7 or greater), if the file
                     was created with a SIP hash or None otherwise. Note that if the sip_hash is not
                     none, then the timestamp and source_size will be invalid.
    zFile name: '%s' doesn't existzFile name: '%s' isn't a file2   z>File name: '%s (%d bytes)' is too short to be a valid pyc filer2   )r:   code_objects	fast_loadget_codeN)r   r   ImportErrorisfilegetsizer5   load_module_from_file_object)r:   rA   rB   rC   r<   r*   r*   r+   load_module[   s    "

rH   	<unknown>c          )   C   s  |dkri }d}z| j d}t|}|dd d7kr>td8}yt|}W nn tk
r   |d9krjtdt|dkrtdt|dd dt|dd   |f ntd| Y nX |d:k rtd)|t| t|f n@|d*k r| j	d t
| S |d+kr td,|t| t|f yLt}	t|}t|}
d}d}d}| j d}|
d-kr|d; }td.krrt|}|d@ s|d/krtd0| j d1d }n(td2| j dd }td2| j dd }nRtd2|d }d3|  kod4k n  r|
d5ks|tkrtd2| j dd }|rh|	|kr<| j  }tj|}n*|rVtjj| t| }ntjj| ||}nd}W nB   tj dd \}}ddl}|j  td6|||f Y nX W d| j  X ||||t|||fS )<zsload a module from a file object without importing it.

    See :func:load_module for a list of return values.
    Nr      r   0   0il  r-   a
  zV  z/This smells like Pyston which is not supported.   zUnknown magic number %s in %s   zBad magic number: '%s'                !        E              +  w          zd%s is interim Python %s (%d) bytecode which is not supported.
Final released versions are supported.i  i  zh%s is a dropbox-hacked Python %s (bytecode %d).
See https://github.com/kholia/dedrop for how to decrypt.g@g@iA  z<Q   z<Ii  iN  g      ?z"Ill-formed bytecode file %s
%s; %s)rK   rL   is  )rM   rN   )rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   re   rf   rg   rh   ri   )r6   r
   r   r	   KeyErrorrD   lenordr   seekr   r   r   r   r   marshalloadsxdisZmarshloadr   Z	unmarshalZ	load_codesysexc_info	traceback	print_excr9   r1   )r<   r:   rA   rB   rC   	timestampmagicr0   Zfloat_versionZmy_magic_intversionsource_sizesip_hashtsZpep_bitsbytecoder>   kindmsgrv   r*   r*   r+   rG      s    
.                         









rG   c             C   s   t | d}ztr&|jtd|dd n|jtd|dd |jtdttj  d|  kodd	k n  rz|jtd| |jtj| W d
|j  X d
S )zWrite bytecode file _bytecode_path_, with code for having Python
    magic_int (i.e. bytecode associated with some version of Python)
    wbz<Hcc      

z<Ii  iN  N)	r5   r   r8   r   inttimerp   dumpsr9   )r)   coder0   filesizer<   r*   r*   r+   write_bytecode_file)  s    
r   __main__rz   z	magic intzsource size mod 2**32: %dzSip Hash: 0x%x)NFT)rI   NFT)r   )0rp   r%   rt   r#   r   structr   r   os.pathr(   r   Zxdis.unmarshalrr   Zxdis.version_infor   r   Zxdis.magicsr   r   r   r	   r
   r   r   Zxdis.dropbox.decrypt25r   r,   r1   stdoutr?   rH   rG   r   __name____file__r>   Zobj_pathrz   rx   r0   Zco2Zpypyr{   r|   printdatetimefromtimestampAssertionErrorr*   r*   r*   r+   <module>   s6   (
$	
7
 




