HOME


Mini Shell 1.0
DIR: /lib/python3/dist-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/sos/report/plugins/__pycache__/jars.cpython-312.pyc
�

i��d{��d�ddlZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
Gd�dee	�Zy)�N)�partial)�Plugin�RedHatPlugin�	PluginOptc��eZdZdZdZdZedded��edd	d
��gZdZ	d
Z
d�Zed��Z
ed��Zed��Zy)�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��dgi}g}ttj�}|jd�r|ttj�z
}|jd�}|r||jd�z
}|D]`}t
j|�D]F\}}}|D];}	|j||	�}
tj|
�s�+|j|
��=�H�b|D]K}tj|�}tj|�}
|s|
s�2||
|d�}|dj|��Mtj|dd��}|j|d	d
��y)Nr	rr�:)�path�sha1�maven_id�)�,z: )�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_strs                �9/usr/lib/python3/dist-packages/sos/report/plugins/jars.py�setupz
Jars.setup1sU���2�,���	���+�+�,�	��?�?�0�1���d�6�6�7�7�I����);�<�����-�-�c�2�2�I�"�	/�H�)+����):�
/�%���I� )�/�H��>�>�'�8�<�D��{�{�4�(�!�(�(��.�/�
/�	/�"�	/�H��(�(��2�H��_�_�X�.�F��6�"*�"(�&.������&�&�v�.�	/��j�j���{�K������[�4��H�c�<�tjj|�rRtj|�r=	tj
|�5}d|j
�vr
	ddd�y	ddd�yy#1swYyxYw#ttjf$rYywxYw)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.MFNTF)	r r�isfile�zipfile�
is_zipfile�ZipFile�namelist�IOError�
BadZipfile)r�fs  r8r#zJars.is_jarTs����7�7�>�>�$��G�$6�$6�t�$<�
��_�_�T�*�$�a�-�����=�#�$�$�=�$�
�$�
���W�/�/�0�
���
�s5�A?�A3�A?�)A?�3A<�8A?�<A?�?B�Bc��i}	tj|�5}tjd�}|j	�D�cgc]}|j|�s�|��}}t
|�dk7r
	ddd�y|j|d�5}|j�D]|}|j�}|jd�r�%	|jd�\}}	|jd�j�}|	jd�j�}	|	||<�~	ddd�ddd�|Scc}w#t$rYddd�ddd�ywxYw#1swY�8xYw#1swY|SxYw#t$rY|SwxYw)z�Extract Maven coordinates from a given JAR file, if possible.

        JARs build by Maven (most popular Java build system) contain
        'pom.properties' file. We can extract Maven coordinates
         from there.
        z*META-INF/maven/[^/]+/[^/]+/pom.properties$�Nr�#�=�utf8)r=r?�re�compiler@�match�len�open�	readlines�strip�
startswithr�decode�
ValueErrorrA)
r4�propsrC�r�x�result�props_f�line�key�values
          r8r%zJars.get_maven_iddsl����	�����*�
,�a��J�J�K�L��%&�Z�Z�\�@��Q�W�W�Q�Z�!�@��@��v�;�!�#��	
,�
,�
�V�V�F�1�I�&�
,�'� '� 1� 1� 3�	,��#�z�z�|��#���t�4�,�/3�z�z�$�/?���e�&)�j�j��&8�&>�&>�&@��(-���V�(<�(B�(B�(D��-2��c�
�	,�
,�
,�$���!A��$.�,�'+�
,�
,�
,�,��
,�
,��
,�$����	����	�s��E+�(E�D-�D-�E�-E+�6E�
5E�AD2�E�E�#E+�-E�2	E	�;E�=E�E+�E	�E�E	�E�E(�#E+�(E+�+	E8�7E8c�&�d}	t|d��5}tj�}tt	|j
d�d�D]}|j
|��	ddd�j�}|S#1swY�xYw#t$rY|SwxYw)zHCompute JAR id.

        Returns sha1 hash of a given JAR file.
        r�rb)�modeir:N)	rM�hashlibr�iterr�read�update�	hexdigestrA)r4r5rC�m�bufs     r8r&zJars.get_jar_id�s�����	��h�T�*�
"�a��L�L�N�������� 5�s�;�"�C��H�H�S�M�"�
"��[�[�]�F��
�
"�
"��
�	���
�	�s)�
B�AA7�B�7B�<B�	B�BN)�__name__�
__module__�__qualname__�
short_desc�plugin_name�profilesr�str�option_listrrr9�staticmethodr#r%r&�r:r8rrs���D�J��K��H��$�b�3�E�	G��'��-�	/��K��M���!I�F�
��
�����:���r:r)r^r'r rIr=�	functoolsr�sos.report.pluginsrrrrrnr:r8�<module>rqs/����	�	���>�>�}�6�<�}r: