| Current Path : /lib/python3/dist-packages/sos/cleaner/archives/__pycache__/ |
| Current File : //lib/python3/dist-packages/sos/cleaner/archives/__pycache__/__init__.cpython-38.pyc |
U
���b�9 � @ sb d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm Z dd� Z
G dd� d�ZdS )� N)�ProcessPoolExecutor)�file_is_binaryc C sN t �| �}tj�|d�}|�|� |�� tj�||j�d�d �d�d �S )NZcleaner�/����.tarr ) �tarfile�open�os�path�joinZ
extractall�close�name�split)�archive_path�tmpdir�archiver
� r �?/usr/lib/python3/dist-packages/sos/cleaner/archives/__init__.py�extract_archive s
r c @ s e Zd ZdZg ZdZdZdZdZdZ g Z
i Zdd� Ze
dd� �Zd d
� Zdd� Zd
d� Zdd� Zdd� Zdd� Zdd� Zdd� Zedd� �Zdd� Zdd� Zdd � Zd>d!d"�Zd#d$� Zd%d&� Zd'd(� Zd)d*� Z d+d,� Z!d-d.� Z"d/d0� Z#d1d2� Z$d3d4� Z%d5d6� Z&d7d8� Z'd9d:� Z(d;d<� Z)d=S )?�SoSObfuscationArchivea A representation of an extracted archive or an sos archive build
directory which is used by SoSCleaner.
Each archive that needs to be obfuscated is loaded into an instance of this
class. All report-level operations should be contained within this class.
r ZundeterminedFc C s� || _ | j | _|| _| j �d�d �d�d | _| j| _t�d�| _t�d�| _ | �
� | _d| _| �
� d| _| �d | j | jf � d S )
Nr r r r ZsosZsos_uiF� zLoaded %s as type %s)r �final_archive_pathr r �archive_name�ui_name�loggingZ getLogger�soslog�ui_log�_load_skip_list� skip_list�is_extracted�
_load_self�archive_root�log_info�description)�selfr r r r r �__init__2 s
��zSoSObfuscationArchive.__init__c C s dS )z=Check if the archive is a well-known type we directly supportFr )�clsZarc_pathr r r �
check_is_typeC s z#SoSObfuscationArchive.check_is_typec C s | j rt�| j�| _d S �N)�
is_tarfiler r r �tarobj�r$ r r r r H s z SoSObfuscationArchive._load_selfc C s g S )a/ Return a list of ObfuscationArchives that represent additional
archives found within the target archive. For example, an archive from
`sos collect` will return a list of ``SoSReportArchive`` objects.
This should be overridden by individual types of ObfuscationArchive's
r r+ r r r �get_nested_archivesL s z)SoSObfuscationArchive.get_nested_archivesc C s0 | j r"| jj}|�� r|jS tjS tj�| j �S )z|Set the root path for the archive that should be prepended to any
filenames given to methods in this class.
)
r) r* Zfirstmember�isdirr
r �sepr
�abspathr )r$ Ztoplevelr r r �get_archive_rootU s z&SoSObfuscationArchive.get_archive_rootc C s | j �d�| jd |�� dS )z9Helper to easily format ui messages on a per-report basisz {:<50} {}z :N)r �info�formatr �r$ �msgr r r �
report_msga s z SoSObfuscationArchive.report_msgc C s d| j |f S )Nz[cleaner:%s] %s)r r3 r r r �_fmt_log_msge s z"SoSObfuscationArchive._fmt_log_msgc C s | j �| �|�� d S r( )r �debugr6 r3 r r r � log_debugh s zSoSObfuscationArchive.log_debugc C s | j �| �|�� d S r( )r r1 r6 r3 r r r r"