Current File : //proc/3/root/proc/2/cwd/opt/alt/python35/lib64/python3.5/__pycache__/zipapp.cpython-35.opt-2.pyc
�\��@sddlZddlZddlZddlZddlZddlZddlZdddgZdZej j
d�r�dZnej�ZGdd�de
�Zejd d
��Zdd�Zdd
d�Zddddd�Zdd�Zddd�Zedkre�dS)�N�ZipAppError�create_archive�get_interpreterz8# -*- coding: utf-8 -*-
import {module}
{module}.{fn}()
�winzutf-8c@seZdZdS)rN)�__name__�
__module__�__qualname__�r r �+/opt/alt/python35/lib64/python3.5/zipapp.pyr!sc csWt|tj�rt|�}t|t�rNt||��}|VWdQRXn|VdS)N)�
isinstance�pathlib�Path�str�open)�archive�mode�fr r r
�_maybe_open%srcCs.|r*d|jt�d}|j|�dS)Ns#!s
)�encode�shebang_encoding�write)r�interpreterZshebangr r r
�_write_file_prefix0srcCs�t|d��u}|jd�}|dkr=d}|j�t|d��1}t||�|j|�tj||�WdQRXWdQRX|r�t|t�r�t j
|t j|�jtj
B�dS)N�rb�s#!��wb)r�read�readlinerr�shutil�copyfileobjrr�os�chmod�stat�st_mode�S_IEXEC)rZnew_archiver�srcZfirst_2�dstr r r
�
_copy_archive7s
r(cCs�d}t|d�r-t|d�r-d}n!tj|�}|j�rNd}|rht|||�dS|j�s�td��|dj�}|r�|r�td��|p�|s�td��d}|rh|jd �\}}} td
d�|j d�D��}
td
d�| j d�D��}|d ko=|
o=|sPtd|��t
jd|d| �}|dkr�|jd�}nt|d�s�tj|�}t
|d���}t||�tj|d��z}
tj|�}xB|jd�D]1}t|j|��}|
jt|�|�q�W|rK|
jd|jd��WdQRXWdQRX|r�t|d�r�|j|j�jtjB�dS)NFrrTzSource does not existz__main__.pyz8Cannot specify entry point if the source has __main__.pyzArchive has no entry point�:css|]}|j�VqdS)N)�isidentifier)�.0�partr r r
� <genexpr>|sz!create_archive.<locals>.<genexpr>�.css|]}|j�VqdS)N)r*)r+r,r r r
r-}szInvalid entry point: �module�fnz.pyzrr�w�*zutf-8)�hasattrrr
�is_filer(�existsr� partition�all�split�
MAIN_TEMPLATE�formatZwith_suffixrr�zipfile�ZipFileZrglobrZrelative_torZwritestrrr"r#r$r%)�source�targetr�mainZsource_is_fileZhas_mainZmain_py�mod�sepr0Zmod_okZfn_ok�fd�z�rootZchildZarcnamer r r
rNsP ""
'c CsKt|d��5}|jd�dkr@|j�j�jt�SWdQRXdS)Nrrs#!)rrr�strip�decoder)rrr r r
r�scCs�ddl}|j�}|jdddddd�|jdddddd �|jd
ddddd�|jd
dddddd�|jddd�|j|�}|jrtjj|j�s�t d��t
|j�}tdj|p�d��t
jd�tjj|j�r�|jdks`tjj|j�rltjj|j|j�rlt d��|jr�t d��t|j|jd|jd|j�dS)Nrz--outputz-o�default�helpzAThe name of the output archive. Required if SOURCE is an archive.z--pythonz-pzEThe name of the Python interpreter to use (default: no shebang line).z--mainz-mzLThe main function of the application (default: use an existing __main__.py).z--infoF�action�
store_truez)Display the interpreter from the archive.r=z'Source directory (or existing archive).z%Can only get info for an archive filezInterpreter: {}z<none>z-In-place editing of archives is not supportedz,Cannot change the main function when copyingrr?)�argparse�ArgumentParser�add_argument�
parse_args�infor!�path�isfiler=�
SystemExitr�printr:�sys�exit�outputr5�samefiler?r�python)�argsrK�parserrr r r
r?�s6
$ r?�__main__)�
contextlibr!rrr#rTr;�__all__r9�platform�
startswithr�getfilesystemencoding�
ValueErrorr�contextmanagerrrr(rrr?rr r r r
�<module>s( G-