File: //lib/python3.10/__pycache__/zipapp.cpython-310.pyc
o
    E�ho  �                   @   s�   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZg d�ZdZej	�
d�r+dZne�� ZG dd� de
�Ze jdd	� �Zd
d� Zddd
�Z		ddd�Zdd� Zddd�Zedkr`e�  dS dS )�    N)�ZipAppError�create_archive�get_interpreterz8# -*- coding: utf-8 -*-
import {module}
{module}.{fn}()
�win�utf-8c                   @   s   e Zd ZdS )r   N)�__name__�
__module__�__qualname__� r
   r
   �/usr/lib/python3.10/zipapp.pyr   !   s    r   c                 c   sR   � t | ttjf�r$t| |��}|V  W d   � d S 1 sw   Y  d S | V  d S �N)�
isinstance�str�os�PathLike�open)�archive�mode�fr
   r
   r   �_maybe_open%   s   �"�
r   c                 C   s(   |rd|� t� d }| �|� dS dS )zWrite a shebang line.�   #!�   
N)�encode�shebang_encoding�write)r   �interpreter�shebangr
   r
   r   �_write_file_prefix.   s   �r   c              	   C   s�   t | d��<}|�d�}|dkrd}|��  t |d��}t||� |�|� t�||� W d  � n1 s5w   Y  W d  � n1 sDw   Y  |r_t|t�rat	�
|t	�|�jtj
B � dS dS dS )z8Copy an application archive, modifying the shebang line.�rb�   r   �    �wbN)r   �read�readliner   r   �shutil�copyfileobjr
   r   r   �chmod�stat�st_mode�S_IEXEC)r   �new_archiver   �src�first_2�dstr
   r
   r   �
_copy_archive5   s   
����r.   Fc              	   C   s  d}t | d�rt | d�rd}nt�| �} | �� rd}|r$t| ||� dS | �� s,td��| d �� }|r:|r:td��|sB|sBtd	��d}|r{|�d
�\}	}
}tdd� |	�	d
�D ��}tdd� |�	d
�D ��}
|
d
krn|rn|
sttd| ��t
j|	|d�}|du r�| �d�}n
t |d�s�t�|�}t
|d��U}t||� |r�tjntj}tj|d|d��0}| �d�D ]}|�| �}|du s�||�r�|�||�� � q�|r�|�d|�d�� W d  � n1 s�w   Y  W d  � n1 s�w   Y  |�rt |d��s	|�|�� jtjB � dS dS dS )ab  Create an application archive from SOURCE.
    The SOURCE can be the name of a directory, or a filename or a file-like
    object referring to an existing archive.
    The content of SOURCE is packed into an application archive in TARGET,
    which can be a filename or a file-like object.  If SOURCE is a directory,
    TARGET can be omitted and will default to the name of SOURCE with .pyz
    appended.
    The created application archive will have a shebang line specifying
    that it should run with INTERPRETER (there will be no shebang line if
    INTERPRETER is None), and a __main__.py which runs MAIN (if MAIN is
    not specified, an existing __main__.py will be used).  It is an error
    to specify MAIN for anything other than a directory source with no
    __main__.py, and it is an error to omit MAIN if the directory has no
    __main__.py.
    Fr"