o
    *b                     @   s`   d dl mZ d dlZd dlZG dd deZG dd deZG dd deZG d	d
 d
eZdS )    )SoSObfuscationArchiveNc                   @   s:   e Zd ZdZdZdZddgddg dd	Zed
d ZdS )SoSReportArchivezThis is the class representing an sos report, or in other words the
    type the archive the SoS project natively generates
    reportzsos report archivezsos_commands/host/hostnamez	etc/hostsz"sos_commands/networking/ip_-o_addrz%sos_commands/networking/ip_-d_address)z(sos_commands/login/lastlog_-u_1000-60000z)sos_commands/login/lastlog_-u_60001-65536z.sos_commands/login/lastlog_-u_65537-4294967295zsos_commands/login/lastzetc/cron.allowzetc/cron.deny)ZhostnameZipZmacZusernamec                 C   *   z
t |o	d|v W S  ty   Y dS w )N
sosreport-Ftarfile
is_tarfile	Exceptionclsarc_path r   :/usr/lib/python3/dist-packages/sos/cleaner/archives/sos.pycheck_is_type,   
   zSoSReportArchive.check_is_typeN)	__name__
__module____qualname____doc__	type_namedescriptionZ
prep_filesclassmethodr   r   r   r   r   r      s    r   c                   @   $   e Zd ZdZdZdZedd ZdS )SoSReportDirectoryzThis is the archive class representing a build directory, or in other
    words what `sos report --clean` will end up using for in-line obfuscation
    Z
report_dirzsos report directoryc                 C   s   t j|rdt |v S dS )NZsos_logsFospathisdirlistdirr   r   r   r   r   <   s   z SoSReportDirectory.check_is_typeNr   r   r   r   r   r   r   r   r   r   r   r   r   4       r   c                   @   s0   e Zd ZdZdZdZdZedd Zdd Z	d	S )
SoSCollectorArchivezArchive class representing the tarball created by ``sos collect``. It
    will not provide prep files on its own, however it will provide a list
    of SoSReportArchive's which will then be used to prep the parsers
    Zcollectzsos collect tarballTc                 C   r   )Nzsos-collectFr   r   r   r   r   r   M   r   z!SoSCollectorArchive.check_is_typec                 C   s\   | j dd | j}g }t|D ]}tj||}d|v r+t|r+|t	|| j
 q|S )NT)quietr   )extractZextracted_pathr   r   r   joinr   r	   appendr   Ztmpdir)self_pathZarchivesfnameZarc_namer   r   r   get_nested_archivesT   s   z'SoSCollectorArchive.get_nested_archivesN)
r   r   r   r   r   r   Z	is_nestedr   r   r*   r   r   r   r   r"   C   s    
r"   c                   @   r   )SoSCollectorDirectoryz{The archive class representing the temp directory used by ``sos
    collect`` when ``--clean`` is used during runtime.
    Zcollect_dirzsos collect directoryc                 C   s.   t j|rt |D ]	}d|v r dS qdS )Nzsos-collector-TFr   )r   r   r)   r   r   r   r   g   s   z#SoSCollectorDirectory.check_is_typeNr    r   r   r   r   r+   _   r!   r+   )Zsos.cleaner.archivesr   r   r   r   r   r"   r+   r   r   r   r   <module>   s   "