File: //lib64/python3.9/site-packages/rct/__pycache__/manifest_commands.cpython-39.pyc
a
X�Zh�9 � @ s� d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlm Z d dl
mZ d dlm
Z
d dlmZ d dlmZ d d lmZ d
d� ZG dd
� d
e�ZG dd� de�ZG dd� de�ZG dd� de�ZdS )� N)�BytesIO)�ZipFile�
BadZipfile)�certificate)�
RCTCliCommand)�xstr)�InvalidCLIOptionError)�ourjson)�ugettextc C s0 | }|� d�D ]}||v r$|| }q dS q|S )N�.� )�split)Z json_dict�path�current�item� r �;/usr/lib64/python3.9/site-packages/rct/manifest_commands.py� get_value s
r c @ sX e Zd ZdZdZdd� Zdd� Zddd �Zd
d� Zdd
� Z dd� Z
dd� Zddd�ZdS )�
ZipExtractAlla� extend ZipFile with a safer extractall
Zipfile() does not support extractall on python2.4, and the 2.6 versions
are known to be unsafe in how they extract files. 2.6 version does not
validate that files are within the archive root, or check that files are
created safely.
Contains helper methods for manipulating and reading
the zipfile more easily in memoryNc O sJ zt j| g|�R i |�� W n( tyD ttd�� t�d� Y n0 dS )z(
Validates the zip file
zManifest zip is invalid.� N)r �__init__r �print�_�sys�exit)�self�args�kwargsr r r r 7 s
zZipExtractAll.__init__c C s, | j d u r&t| �tj��}t|d�| _ | j S �N�r)� inner_zipr �read�RCTManifestCommand�
INNER_FILEr )r �outputr r r �_get_inner_zipA s
zZipExtractAll._get_inner_zipFc C s~ z"t | �|��}|�� }|�� W nV tyx z|r:t�| �� �|d�}W n& tyr ttd�j |d���Y n0 Y n0 |S )NTz.Unable to find file "{file_path}" in manifest.)� file_path)
r r! �getvalue�close�KeyErrorr% �
_read_file� Exceptionr �format)r r&