File: //usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/__init__.cpython-310.pyc
o
���b| � @ s� d Z ddlmZmZmZmZmZmZmZm Z m
Z
mZmZm
Z
mZmZmZmZ ddlmZ ddlZddlZddlZddlZddlmZ ddlZddlZddlZddlZddlmZ dd� Zd d
� Zdd� Z e�!d
ej"�Z#dZ$G dd� de%�Z&G dd� de%�Z'G dd� d�Z(G dd� d�Z)G dd� d�Z*G dd� de*�Z+G dd� de*�Z,G dd� de*�Z-G dd � d e*�Z.G d!d"� d"e*�Z/G d#d$� d$e*�Z0G d%d&� d&e*�Z1G d'd(� d(e*�Z2G d)d*� d*e+�Z3d-d+d,�Z4dS ).z; This exports methods available for use by plugins for sos � )�sos_get_command_output�
import_module�grep�fileobj�tail�
is_executable�TIMEOUT_DEFAULT�path_exists�
path_isdir�path_isfile�path_islink�listdir� path_join�bold�file_is_binary�recursive_dict_values_by_key)�P_FILEN)�time)�datetimec C s\ z"t |��}t�| |�� tj�W d � W S 1 sw Y W dS ty- g Y S w )z=Return a list of all non overlapping matches in the string(s)N)r �re�findall�read� MULTILINE�AttributeError)�regex�fname�f� r �=/usr/lib/python3/dist-packages/sos/report/plugins/__init__.py�
regex_findall! s
(��r c C s@ t �dd| �}t �dd|�}t �dd|��d�}|d|� }|S ) Nz^/(usr/|)(bin|sbin)/� z[^\w\-\.\/]+�_�/�.z ._-r )r �sub�strip)�command�name_max�manglednamer r r �_mangle_command* s
r) c C sL t jdft jdft jdft jdfg}|D ]}|d | j�r#|d S qdS )z� return a string indicating the type of special node represented by
the stat buffer st (block, character, fifo, socket).
zblock devicezcharacter devicez
named pipe�socketr � N)�stat�S_ISBLK�S_ISCHR�S_ISFIFO�S_ISSOCK�st_mode)�st�_types�tr r r �
_node_type2 s ���r5 z-*BEGIN.*?-*ENDz
-----SCRUBBEDc @ s� e Zd ZdZdZdZg Zg Zg Zg Z g Z
d%dd�Zdd� Zd d
� Z
dd� Zd
d� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Zdg g g g g i fd#d$�ZdS )&�SoSPredicatea� A class to implement collection predicates.
A predicate gates the collection of data by an sos plugin. For any
`add_cmd_output()`, `add_copy_spec()` or `add_journal()` call, the
passed predicate will be evaulated and collection will proceed if
the result is `True`, and not otherwise.
Predicates may be used to control conditional data collection
without the need for explicit conditional blocks in plugins.
:param owner: The ``Plugin`` object creating the predicate
:type owner: ``Plugin``
:param dry_run: Is sos running in dry_run mode?
:type dry_run: ``bool``
:param kmods: Kernel module name(s) to check presence of
:type kmods: ``list``, or ``str`` of single name
:param services: Service name(s) to check if running
:type services: ``list``, or ``str`` of single name
:param packages: Package name(s) to check presence of
:type packages: ``list``, or ``str`` of single name
:param cmd_outputs: Command to run, with output string to check
:type cmd_outputs: ``list`` of ``dict``s, or single ``dict`` taking form
{'cmd': <command to run>,
'output': <string that output should contain>}
:param arch: Architecture(s) that the local system is matched
against
:type arch: ``list``, or ``str`` of single architecture
:param required: For each parameter provided, should the checks
require all items, no items, or any items provided
:type required: ``dict``, with keys matching parameter names and values
being either 'any', 'all', or 'none. Default 'any'.
NFr c
s d� d| j }| j}|r� fdd�|D �n|}|dd�|� 7 }| j}|r.� fdd�|D �n|}|dd�|� 7 }| j}|rG� fd d�|D �n|}|d
d�|� 7 }� fdd�| jD �}|dd�|� 7 }| j} |rs� fd
d�| D �n| } |dd�| � 7 }|| | S )zxReturn a string representation of this SoSPredicate with
optional prefix, suffix and value quoting.
z"%s"zdry_run=%s, c � g | ]}� | �qS r r )�.0�k��quotesr r �
<listcomp>� � z&SoSPredicate.__str.<locals>.<listcomp>zkmods=[%s], �,c r7 r r �r8 �sr: r r r<