관리-도구
편집 파일: kwconfig.cpython-311.pyc
� IMgA � �@ � d dl Z d dlmZ d dlmZ G d� d� � ZdS )� N)�Optional)�atomic_rewritec �r � e Zd ZdZdxZxZZdZd d�Zde e fd�Zde e fd�Zde e fd �Z dS )�KWConfigz� Basic class for working with key-value configuration files Subclasses must define SEARCH_PATTERN and WRITE_PATTERN attributes � TNc � � | j sJ �t j | j � |� � t j � � | _ |p| j | _ || _ d S �N) �SEARCH_PATTERN�re�compile�format� MULTILINE�_pattern�DEFAULT_FILENAME� _filename�_name)�self�name�filenames �S/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils/kwconfig.py�__init__zKWConfig.__init__ sX � ��"�"�"�"�� ���&�&�t�,�,�b�l� � �� � "�:�T�%:����� � � � �returnc �� � | j sJ �t | j � � 5 }|� � � }d d d � � n# 1 swxY w Y | � |� � }|�*|d| j � | j |� � z dz z }n9| j � | j � | j |� � |� � }t | j || j �� � |S )N� )�allow_empty_content)� WRITE_PATTERN�openr �read�_parser r r �subr �ALLOW_EMPTY_CONFIG)r �value�f�content� old_values r �setzKWConfig.set s) � ��!�!�!�!� �$�.� !� !� �Q��f�f�h�h�G� � � � � � � � � � � ���� � � � � �K�K��(�(� �����t�)�0�0���U�C�C�C�d�J� �G�G� �m�'�'��"�)�)�$�*�e�<�<�g�� �G� ��N�� $� 7� � � � � �s �?�A�Ac � � t | j � � 5 }|� � � }d d d � � n# 1 swxY w Y | � |� � S r )r r r r )r r$ r% s r �getzKWConfig.get2 s� � � �$�.� !� !� �Q��f�f�h�h�G� � � � � � � � � � � ���� � � � ��{�{�7�#�#�#s �6�:�:c �d � | j � |� � }|o|� d� � S )N� )r �search�group)r r% �matchs r r zKWConfig._parse7 s, � �� �$�$�W�-�-���'����Q���'r r )�__name__� __module__�__qualname__�__doc__r r r r"