File: //lib/python3/dist-packages/sos/report/plugins/__pycache__/jars.cpython-310.pyc
o
-�_g� � @ s^ d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZm Z m
Z
G dd� dee �ZdS )� N)�partial)�Plugin�RedHatPlugin� PluginOptc @ s^ e Zd ZdZdZdZeddedd�edd d
d�gZdZ d
Z
dd� Zdd� Zdd� Z
dd� ZdS )�Jarsz1Collect information about available Java archives�jars)�java�append-locations� z,colon-delimited list of additional JAR paths)�default�val_type�desc�all-known-locationsFzscan all known paths)r r
)z/usr/share/javaz
/usr/lib/java)z/optz
/usr/localz/var/libc C s� dg i}g }t tj�}| �d�r|t tj�7 }| �d�}|r%||�d�7 }|D ]"}t�|�D ]\}}}|D ]} | �|| �}
| � |
�rG|�
|
� q5q.q'|D ]}| �|�}| �|�}
|s\|
ri||
|d�}|d �
|� qLt
j|ddd�}| j|d d
d� d S )Nr r r �:)�path�sha1�maven_id� )�,�: )�indent�
separatorsz jars.jsonT)�plug_dir)�listr �
jar_locations�
get_option�extra_jar_locations�split�os�walk� path_join�is_jar�append�get_maven_id�
get_jar_id�json�dumps�add_string_as_file)�self�results� jar_paths� locations�user_locations�location�dirpath�_� filenames�filenamer �jar_pathr �jar_id�record�results_str� r6 �9/usr/lib/python3/dist-packages/sos/report/plugins/jars.py�setup1 s:
���
��z
Jars.setupc
C s� t j�|�rWt�|�rWz*t�|��}d|�� v r" W d � W dS W d � W dS 1 s.w Y W dS ttjfyV } z| � d|� d|� �� W Y d}~dS d}~ww dS )z�Check whether given file is a JAR file.
JARs are ZIP files which usually include a manifest
at the canonical location 'META-INF/MANIFEST.MF'.
zMETA-INF/MANIFEST.MFNTzCould not determine if z is a JAR: F)
r r �isfile�zipfile�
is_zipfile�ZipFile�namelist�IOError�
BadZipfile� _log_info)r( r �file�errr6 r6 r7 r! T s&