Current File : //usr/lib/python3/dist-packages/cloudinit/distros/parsers/__pycache__/sys_conf.cpython-312.pyc |
�
x[h7 � �\ � d dl Z d dlZd dlmZ d dlZdZd� Z G d� dej � Zy)� N)�StringIOz[a-zA-Z_]+[a-zA-Z0-9_]*c � � t j dt z � t j d� t j d� fD ] }|j | � s� y y)Nz\$z\$[0-9#\?\-@\*]z\$\{.+\}TF)�re�compile�SHELL_VAR_RULE�search)�text�rs �D/usr/lib/python3/dist-packages/cloudinit/distros/parsers/sys_conf.py�_contains_shell_variabler sV � � �
�
�5�>�)�*�
�
�
�%�&� �
�
�;�� � ��
�8�8�D�>��� � c �* � e Zd ZdZd� Zd� Zdd�Zd� Zy)�SysConfa A configobj.ConfigObj subclass specialised for sysconfig files.
:param contents:
The sysconfig file to parse, in a format accepted by
``configobj.ConfigObj.__init__`` (i.e. "a filename, file like object,
or list of lines").
c �J � t j j | |dd�� y )NFT)�
interpolation�write_empty_values)� configobj� ConfigObj�__init__)�self�contentss r r zSysConf.__init__3 s$ � ����$�$��(�%�D� %�
r
c � � | j � }t � }t |t t f� r0|j dj |� � |j � S |j t
|� � |j � S )N�
)�writer �
isinstance�list�tuple�join�str�getvalue)r r �out_contentss r �__str__zSysConf.__str__8 sm � ��:�:�<���z���h��u�
�.����t�y�y��2�3� �$�$�&�&�
���s�8�}�-��$�$�&�&r
c �� � � t |t � st d|z � �|syd }|d dv r|d dv rt |� dk( r�� fd�}n�|j � j d� r |j � j
d � rnSt j d
|� r=t |� r"t j d|� r� fd�}n� fd
�}nt j }|s|S ||� S )NzValue "%s" is not a string� r )�"�'���� c �, �� �j | � | z S �N��_get_single_quote��xr s �r �<lambda>z SysConf._quote.<locals>.<lambda>J s �� �d�4�4�Q�7�!�;� r
z$(�)z [\t\r\n ]z[\n\"']c �, �� �j | � | z S r* )�_get_triple_quoter- s �r r/ z SysConf._quote.<locals>.<lambda>X � �� �$�*@�*@��*C�a�*G� r
c �, �� �j | � | z S r* r+ r- s �r r/ z SysConf._quote.<locals>.<lambda>\ r3 r
)r r �
ValueError�len�strip�
startswith�endswithr r r �shlex�quote)r �value� multiline� quot_funcs ` r �_quotezSysConf._quoteA s� �� ��%��%��9�U�C�D�D���� ���8�z�!�e�B�i�:�&=��5�z�Q��;� �
�{�{�}�'�'��-�%�+�+�-�2H�2H��2M���9�9�\�5�1�/��6� �9�9�Z��7� G� &�
!H� &� %*�K�K� ���L����r
c � � | j | j |� � }| j | j |� � }| j |� }|�|�d�|�|��S )N�=)�_decode_elementr? )r �
indent_string�entry�
this_entry�comment�val�key�cmnts r �_write_linezSysConf._write_lined s_ � � �"�"�4�;�;�z�#:�;���"�"�4�;�;�u�#5�6���#�#�G�,�������
�
r
N)F)�__name__�
__module__�__qualname__�__doc__r r"