HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //snap/certbot/4965/lib/python3.12/site-packages/augeas/__pycache__/__init__.cpython-312.pyc
�

N�h�k����dZddlmZddlmZmZdZdZedk\Z	dZ
e	reZne
Zd�Zd	�ZGd
�de�ZGd�d
e�ZGd�de�ZGd�de�ZGd�de�ZddgZy)a�
Augeas is a library for programmatically editing configuration files.
Augeas parses configuration files into a tree structure, which it exposes
through its public API. Changes made through the API are written back to
the initially read files.

The transformation works very hard to preserve comments and formatting
details. It is controlled by *lens* definitions that describe the file
format and the transformation into a tree.
�)�version_info)�ffi�libz/Nathaniel McCallum <nathaniel@natemccallum.com>z�Jeff Schroeder <jeffschroeder@computer.org>
Harald Hoyer <harald@redhat.com> - initial python bindings, packaging
Nils Philippsen <nils@redhat.com>
)��utf8c�2�|r|jt�Sy�N�)�encode�AUGENC��sts �/build/snapcraft-certbot-c9561b03ef7f16aa90eb6754ca5f17a1/parts/certbot/install/lib/python3.12/site-packages/augeas/__init__.py�encr3���	��y�y�� � �r
c�2�|r|jt�Syr	)�decoderr
s r�decr:rr
c���eZdZ�fd�Z�xZS)�
AugeasIOErrorc�t��||_tt|�|g|���||_||_||_||_y�N)�message�superr�__init__�error�msg�minor�details��self�ec�fullmessagerrr�args�	__class__s       �rrzAugeasIOError.__init__Bs:���"���
�m�T�+�K�?�$�?���
������
���r
��__name__�
__module__�__qualname__r�
__classcell__�r%s@rrrA�
����r
rc���eZdZ�fd�Z�xZS)�AugeasRuntimeErrorc�t��||_tt|�|g|���||_||_||_||_yr)rrr.rrrrrr s       �rrzAugeasRuntimeError.__init__Ls;���"���
� �$�0��D�t�D���
������
���r
r&r+s@rr.r.Kr,r
r.c���eZdZ�fd�Z�xZS)�AugeasValueErrorc�t��||_tt|�|g|���||_||_||_||_yr)rrr1rrrrrr s       �rrzAugeasValueError.__init__Vs;���"���
���.�{�B�T�B���
������
���r
r&r+s@rr1r1Ur,r
r1c��eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZdZdZdZdZd
ZdZdZdZdZdZdZdZdZd�Zd�Zddefd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d �Z&d!�Z'd"�Z(d#�Z)d.d$�Z*d%�Z+d&�Z,d'�Z-d(�Z.d)�Z/d*�Z0d/d+�Z1d0d,�Z2d-�Z3y)1�Augeasz/
    Class wrapper for the Augeas library.
    r������ �@�r����	�
���
�c�f�|tjk(ryttj|��Sr)r�NULLr�string)r!�cffistrs  r�
_optffistringzAugeas._optffistring�s%���c�h�h����s�z�z�'�*�+�+r
c���tj|j�}|tjk(r
t��|j
tj|j��}|dz|z|z}|j
tj|j��}|r|d|zz
}|j
tj|j��}|r|d|zz
}||||||��)Nz: )
r�	aug_error�_Augeas__handler4�
AUG_ENOMEM�MemoryErrorrJ�aug_error_message�aug_error_minor_message�aug_error_details)	r!�
errorclass�errmsgr$r"rr#rrs	         r�_raise_errorzAugeas._raise_error�s���
�]�]�4�=�=�
)��
��"�"�"��-��� � ��!6�!6�t�}�}�!E�F����}�s�*�d�2���"�"�3�#>�#>�t�}�}�#M�N����4�%�<�'�K��$�$�S�%:�%:�4�=�=�%I�J����4�'�>�)�K���[�#�u�g�>�>r
Nc���t|t�s
|�td��t|t�s
|�td��t|t�std��|rt	|�nt
j}|rt	|�nt
j}tjtj|||��fd���_
�jstd��y)a�
        Initialize the library.

        :param root: the filesystem root. If `root` is :py:obj:`None`, use the
                     value of the environment variable :envvar:`AUGEAS_ROOT`.
                     If that doesn't exist either, use :samp:`/`.
        :type root: str or None

        :param loadpath: a colon-separated list of directories that modules
                         should be searched in. This is in addition to the
                         standard load path and the directories in
                         :envvar:`AUGEAS_LENS_LIB`.
        :type loadpath: str or None

        :param flags: a combination of values of :attr:`SAVE_BACKUP`,
                      :attr:`SAVE_NEWFILE`, :attr:`TYPE_CHECK`,
                      :attr:`NO_STDINC`, :attr:`SAVE_NOOP`, :attr:`NO_LOAD`,
                      :attr:`NO_MODL_AUTOLOAD`, and :attr:`ENABLE_SPAN`.
        :type flags: int or :attr:`NONE`
        Nzroot MUST be a string or None!z"loadpath MUST be a string or None!zflag MUST be a flag!c����jSr)�close)�xr!s �r�<lambda>z!Augeas.__init__.<locals>.<lambda>�s������r
zUnable to create Augeas object!)�
isinstance�string_types�	TypeError�intrrrG�gcr�aug_initrM�RuntimeError)r!�root�loadpath�flagss`   rrzAugeas.__init__�s����.�$��-�$�2B��<�=�=��(�L�1�h�6J��@�A�A��%��%��2�3�3� �s�4�y�c�h�h��$,�3�x�=�#�(�(�����s�|�|�D�(�E�B�3�5��
��}�}��@�A�A�r
c�D�t|t�std��|jst	d��tjdd�}tj|jt|�|�}|dkr|jtd�|j|d�S)z�
        Lookup the value associated with `path`.
        It is an error if more than one node matches `path`.

        :returns: the value at the path specified
        :rtype: str
        �path MUST be a string!�*The Augeas object has already been closed!�char*[]r5rzAugeas.get() failed)
r[r\r]rMrar�newr�aug_getrrUr1rJ�r!�path�value�rets    r�getz
Augeas.get�s����$��-��4�5�5��}�}��K�L�L����	�1�%���k�k�$�-�-��T��E�:����7����.�0E�F��!�!�%��(�+�+r
c�D�t|t�std��|jst	d��tjdd�}tj|jt|�|�}|dkr|jtd�|j|d�S)z�
        Lookup the label associated with `path`.
        It is an error if more than one node matches `path`.

        :returns: the label of the path specified
        :rtype: str
        rfrgrhr5rzAugeas.label() failed)
r[r\r]rMrarrir�	aug_labelrrUr1rJ)r!rl�labelrns    rrrzAugeas.label�s����$��-��4�5�5��}�}��K�L�L����	�1�%���m�m�D�M�M�3�t�9�e�<����7����.�0G�H��!�!�%��(�+�+r
c�@�t|t�std��t|t�s
|�td��|jst	d��tj|jt|�t|��}|dk7r|jtd�yy)z�
        Set the value associated with `path` to `value`.
        Intermediate entries are created if they don't exist.
        It is an error if more than one node matches `path`.
        rfN�value MUST be a string or None!rgrzAugeas.set() failed)
r[r\r]rMrar�aug_setrrUr1rks    r�setz
Augeas.set�s����$��-��4�5�5��%��.�5�3D��=�>�>��}�}��K�L�L��k�k�$�-�-��T��C��J�?���!�8����.�0E�F�r
c��t|�tk7rtd��t|�tk7r
|�td��t|�tk7r
|�td��|jst	d��tj|jt|�t|�t|��}|dkr|jtd�|S)a5
        Set the value of multiple nodes in one operation.
        Find or create a node matching `sub` by interpreting `sub`
        as a path expression relative to each node matching `base`.
        `sub` may be :py:obj:`None`, in which case all the nodes matching
        `base` will be modified.
        zbase MUST be a string!zsub MUST be a string or None!rtrgrzAugeas.setm() failed)
�type�strr]rMrar�aug_setmrrUr1)r!�base�subrmrns     r�setmzAugeas.setm	s�����:����4�5�5���9������;�<�<���;�#��%�"3��=�>�>��}�}��K�L�L��l�l��M�M�3�t�9�c�#�h��E�
�<����7����.�0F�G��
r
c��t|t�std��t|t�std��t|t�std��|jst	d��tj|jt|�t|�t|��}|dk7r|jtd�|S)z�
        Use the value of node `node` as a string and transform it into a tree
        using the lens `lens` and store it in the tree at `path`, which will be
        overwritten. `path` and `node` are path expressions.
        �lens MUST be a string!znode MUST be a string!rfrgrzAugeas.text_store() failed)
r[r\r]rMrar�aug_text_storerrUr1)r!�lens�noderlrns     r�
text_storezAugeas.text_store#s����$��-��4�5�5��$��-��4�5�5��$��-��4�5�5��}�}��K�L�L�� � ��M�M�3�t�9�c�$�i��T��<���!�8����.�0L�M��
r
c	���t|t�std��t|t�std��t|t�std��t|t�std��|jst	d��tj|jt|�t|�t|�t|��}|dk7r|jtd�|S)a
        Transform the tree at `path` into a string using lens `lens` and store
        it in the node `node_out`, assuming the tree was initially generated
        using the value of node `node_in`. `path`, `node_in`, and `node_out`
        are path expressions.
        rznode_in MUST be a string!rfznode_out MUST be a string!rgrzAugeas.text_retrieve() failed)
r[r\r]rMrar�aug_text_retrieverrUr1)r!r��node_inrl�node_outrns      r�
text_retrievezAugeas.text_retrieve;s����$��-��4�5�5��'�<�0��7�8�8��$��-��4�5�5��(�L�1��8�9�9��}�}��K�L�L��#�#��M�M�3�t�9�c�'�l�C��I�s�8�}�N���!�8����.�=�
?��
r
c�H�t|�tk7rtd��t|�tk7r
|�td��|jst	d��tj|jt|�t|��}|dkr|jtd�|S)a�
        Define a variable `name` whose value is the result of
        evaluating `expr`. If a variable `name` already exists, its
        name will be replaced with the result of evaluating `expr`.

        If `expr` is :py:obj:`None`, the variable `name` will be removed if it
        is defined.

        Path variables can be used in path expressions later on by
        prefixing them with :samp:`$`.
        �name MUST be a string!zexpr MUST be a string or None!rgrzAugeas.defvar() failed)
rxryr]rMrar�
aug_defvarrrUr1)r!�name�exprrns    r�defvarz
Augeas.defvarWs�����:����4�5�5���:����!1��<�=�=��}�}��K�L�L��n�n�T�]�]�C��I�s�4�y�A����7����.�0H�I��
r
c��t|�tk7rtd��t|�tk7rtd��t|�tk7rtd��|jst	d��tj|jt|�t|�t|�tj�}|dkr|jtd�|S)a�
        Define a variable `name` whose value is the result of
        evaluating `expr`, which must not be :py:obj:`None` and evaluate to a
        nodeset. If a variable `name` already exists, its name will
        be replaced with the result of evaluating `expr`.

        If `expr` evaluates to an empty nodeset, a node is created,
        equivalent to calling ``set(expr, value)`` and `name` will be the
        nodeset containing that single node.
        r�zexpr MUST be a string!zvalue MUST be a string!rgrzAugeas.defnode() failed)rxryr]rMrar�aug_defnoderrrGrUr1)r!r�r�rmrns     r�defnodezAugeas.defnoders�����:����4�5�5���:����4�5�5���;�#���5�6�6��}�}��K�L�L��o�o��M�M�3�t�9�c�$�i��U��S�X�X�G����7����.�0I�J��
r
c�<�t|t�std��t|t�std��|jst	d��tj|jt|�t|��}|dk7r|jtd�yy)ap
        Move the node `src` to `dst`. `src` must match exactly one node
        in the tree. `dst` must either match exactly one node in the
        tree, or may not exist yet. If `dst` exists already, it and all
        its descendants are deleted before moving `src` there. If `dst`
        does not exist yet, it and all its missing ancestors are created.
        �src MUST be a string!�dst MUST be a string!rgrzAugeas.move() failedN)
r[r\r]rMrar�aug_mvrrUr1�r!�src�dstrns    r�movezAugeas.move�����#�|�,��3�4�4��#�|�,��3�4�4��}�}��K�L�L��j�j�����C��#�c�(�;���!�8����.�0F�G�r
c�<�t|t�std��t|t�std��|jst	d��tj|jt|�t|��}|dk7r|jtd�yy)aq
        Copy the node `src` to `dst`. `src` must match exactly one node
        in the tree. `dst` must either match exactly one node in the
        tree, or may not exist yet. If `dst` exists already, it and all
        its descendants are deleted before copying `src` there. If `dst`
        does not exist yet, it and all its missing ancestors are created.
        r�r�rgrzAugeas.copy() failedN)
r[r\r]rMrar�aug_cprrUr1r�s    r�copyzAugeas.copy�r�r
c�<�t|t�std��t|t�std��|jst	d��tj|jt|�t|��}|dkr|jtd�|S)zH
        Rename the label of all nodes matching `src` to `dst`.
        r�r�rgrzAugeas.rename() failed)
r[r\r]rMrar�
aug_renamerrUr1r�s    r�renamez
Augeas.rename�s����#�|�,��3�4�4��#�|�,��3�4�4��}�}��K�L�L��n�n�T�]�]�C��H�c�#�h�?����7����.�0H�I��
r
c�N�t|t�std��t|t�std��|jst	d��tj|jt|�t|�|xrdxsd�}|dk7r|jtd�yy)a�
        Create a new sibling `label` for `path` by inserting into the tree
        just before `path` (if `before` is :py:obj:`True`) or just after `path`
        (if `before` is :py:obj:`False`).

        `path` must match exactly one existing node in the tree, and `label`
        must be a label, i.e. not contain a :samp:`/`, :samp:`*` or end with
        a bracketed index :samp:`[N]`.
        rfzlabel MUST be a string!rgr5rzAugeas.insert() failedN)
r[r\r]rMrar�
aug_insertrrUr1)r!rlrr�beforerns     r�insertz
Augeas.insert�s����$��-��4�5�5��%��.��5�6�6��}�}��K�L�L��n�n�T�]�]�C��I� ��Z���A�):��<���!�8����.�0H�I�r
c��t|t�std��|jst	d��tj|jt|��S)z�
        Remove `path` and all its children. Returns the number of entries
        removed. All nodes that match `path`, and their descendants, are
        removed.
        rfrg)r[r\r]rMrar�aug_rmr)r!rls  r�removez
Augeas.remove�sH���$��-��4�5�5��}�}��K�L�L��z�z�$�-�-��T��3�3r
c�:�t|t�std��|jst	d��tjd�}tj|jt|�|�}|dkr|jtd|�|d}g}t|�D]c}||t
jk7s�tj||�}|jt!|��tj"||��etj"|�|S)a�
        Return the matches of the path expression `path`. The returned paths
        are sufficiently qualified to make sure that they match exactly one
        node in the current tree.

        Path expressions use a very simple subset of XPath: the path `path`
        consists of a number of segments, separated by :samp:`/`; each segment
        can either be a :samp:`*`, matching any tree node, or a string,
        optionally followed by an index in brackets, matching tree nodes
        labelled with exactly that string. If no index is specified, the
        expression matches all nodes with that label; the index can be a
        positive number N, which matches exactly the *N*-th node with that
        label (counting from 1), or the special expression :samp:`last()` which
        matches the last node with the given label. All matches are done in
        fixed positions in the tree, and nothing matches more than one path
        segment.
        rfrgzchar***rzAugeas.match() failed: %s)r[r\r]rMrarrir�	aug_matchrrUr.�rangerGrH�appendr�free)r!rl�parrayrn�array�matches�i�items        r�matchzAugeas.match�s���(�$��-��4�5�5��}�}��K�L�L�����#���m�m�D�M�M�3�t�9�f�=����7����0�9�4�
A��q�	�����s��	#�A��Q�x�3�8�8�#��z�z�%��(�+�����s�4�y�)�����q��"�	#�	������r
c���t|t�std��|jst	d��tjd�}tjd�}tjd�}tjd�}tjd�}tjd�}tjd�}tj|jt|�|||||||�	}	|	dkr|jtd�|j|d�}
|
t|d�t|d�t|d�t|d�t|d�t|d�fS)a�
        Get the span according to input file of the node associated with
        `path`. If the node is associated with a file, a tuple of 7 elements is
        returned: ``(filename, label_start, label_end, value_start, value_end,
        span_start, span_end)``. If the node associated with `path` doesn't
        belong to a file or is doesn't exists, :py:obj:`ValueError` is raised.

        :rtype: tuple(str, int, int, int, int, int, int)
        rfrgzchar **zunsigned int *rzAugeas.span() failed)r[r\r]rMrarrir�aug_spanrrUr1rJr^)r!rl�filename�label_start�	label_end�value_start�	value_end�
span_start�span_endrn�fnames           r�spanzAugeas.span#sB���$��-��4�5�5��}�}��K�L�L��7�7�9�%���g�g�.�/���G�G�,�-�	��g�g�.�/���G�G�,�-�	��W�W�-�.�
��7�7�+�,���l�l�4�=�=�#�d�)�X�&�	�&�	�%�x�1��
�!�G����.�0F�G��"�"�8�A�;�/���s�;�q�>�*�C�	�!��,=��K��N�#�S��1��%6��J�q�M�"�C����$4�6�	6r
c��|jstd��tj|j�}|dk7r|j	t
d�yy)a
        Write all pending changes to disk. Only files that had any changes
        made to them are written.

        If :attr:`SAVE_NEWFILE` is set in the creation `flags`, create changed
        files as new files with the extension :samp:`.augnew`, and leave the
        original file unmodified.

        Otherwise, if :attr:`SAVE_BACKUP` is set in the creation `flags`, move
        the original file to a new file with extension :samp:`.augsave`.

        If neither of these flags is set, overwrite the original file.
        rgrzAugeas.save() failedN)rMrar�aug_saverUr�r!rns  r�savezAugeas.saveIsH�� �}�}��K�L�L��l�l�4�=�=�)���!�8����m�-C�D�r
c��|jstd��tj|j�}|dk7r|j	t
d�yy)aM
        Load files into the tree. Which files to load and what lenses to use
        on them is specified under :samp:`/augeas/load` in the tree; each entry
        :samp:`/augeas/load/NAME` specifies a 'transform', by having itself
        exactly one child 'lens' and any number of children labelled 'incl' and
        'excl'. The value of :samp:`NAME` has no meaning.

        The 'lens' grandchild of :samp:`/augeas/load` specifies which lens to
        use, and can either be the fully qualified name of a lens
        :samp:`Module.lens` or :samp:`@Module`. The latter form means that the
        lens from the transform marked for autoloading in MODULE should be
        used.

        The 'incl' and 'excl' grandchildren of :samp:`/augeas/load` indicate
        which files to transform. Their value are used as glob patterns. Any
        file that matches at least one 'incl' pattern and no 'excl' pattern is
        transformed. The order of 'incl' and 'excl' entries is irrelevant.

        When AUG_INIT is first called, it populates :samp:`/augeas/load` with
        the transforms marked for autoloading in all the modules it finds.

        Before loading any files, :func:`load` will remove everything
        underneath :samp:`/augeas/files` and :samp:`/files`, regardless of
        whether any entries have been modified or not.
        rgrzAugeas.load() failedN)rMrar�aug_loadrUr.r�s  r�loadzAugeas.loadasG��8�}�}��K�L�L��l�l�4�=�=�)���!�8����0�2H�I�r
c�&�|jd�y)z�
        Clear all transforms beneath :samp:`/augeas/load`. If :func:`load` is
        called right after this, there will be no files beneath :samp:`/files`.
        z/augeas/load/*N)r��r!s r�clear_transformszAugeas.clear_transforms�s��
	
���$�%r
c�H�|rddl}|jdtd��t|t�r|g}t|t�r|g}tt
|��D]}|j|||d��tt
|��D]}|j|||d��y)a�
        Add a transform beneath :samp:`/augeas/load`.

        :param lens: the (file)name of the lens to use
        :type lens: str
        :param incl: one or more glob patterns for the files to transform
        :type incl: str or list(str)
        :param name: deprecated parameter
        :param excl: zero or more glob patterns of files to exclude from
                     transforming
        :type excl: str or list(str)
        rNz'name is now deprecated in this functionr6��
stacklevelFT)�warnings�warn�DeprecationWarningr[r\r��len�	transform)r!r��inclr��exclr�r�s       r�
add_transformzAugeas.add_transform�s������M�M�C�,��
�
<��d�L�)��6�D��d�L�)��6�D��s�4�y�!�	1�A��N�N�4��a��%�0�	1��s�4�y�!�	0�A��N�N�4��a��$�/�	0r
c�t�t|t�std��t|t�std��t|t�std��|jstd��t
j|jt|�t|�|�}|dk7r|jtd�yy)aB
        Add a transform for `file` using `lens`.

        `excl` specifies if this the file is to be included (:py:obj:`False`)
        or excluded (:py:obj:`True`) from the `lens`.
        The `lens` may be a module name or a full lens name.
        If a module name is given, then lns will be the lens assumed.
        rzfile MUST be a string!zexcl MUST be a boolean!rgrzAugeas.transform() failedN)r[r\r]�boolrMrar�
aug_transformrrUr.)r!r��filer�rns     rr�zAugeas.transform�s����$��-��4�5�5��$��-��4�5�5��$��%��5�6�6��}�}��K�L�L�����
�
�s�4�y�#�d�)�T�J���!�8����0�2M�N�r
c��|jr|jtjk(rytj|j�d|_y)z�
        Close this Augeas instance and free any storage associated with it.
        After this call, this Augeas instance is invalid and can not be used
        for any more operations.
        N)rMrrGr�	aug_closer�s rrXzAugeas.close�s8���}�}��
�
���� 9��	�
�
�d�m�m�$���
r
)T)N�)F)4r'r(r)�__doc__�NONE�SAVE_BACKUP�SAVE_NEWFILE�
TYPE_CHECK�	NO_STDINC�	SAVE_NOOP�NO_LOAD�NO_MODL_AUTOLOAD�ENABLE_SPAN�AUG_NOERRORrN�
AUG_EINTERNAL�
AUG_EPATHX�AUG_ENOMATCH�AUG_EMMATCH�AUG_ESYNTAX�AUG_ENOLENS�	AUG_EMXFM�AUG_ENOSPAN�AUG_EMVDESC�AUG_ECMDRUN�AUG_EBADARG�
AUG_ELABEL�AUG_ECPDESCrJrUrrorrrvr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rXr�r
rr4r4_s���
�D��K��L��J��I��I��G����K��K��J��M��J��L��K��K��K��I��K��K��K��K��J��K�,�?�!�4�t�%B�N,�2,�2G�(�4�0�8�6�:H�,H�,�&J�24� *�X$6�LE�0!J�F&�0�8O�.r
r4c�"��eZdZdZ�fd�Z�xZS)�augeaszN
    Compat class, obsolete. Use class Augeas directly.

    :deprecated:
    c�d��ddl}|jdtd��tt|�|i|��y)Nrzuse Augeas instead of augeasr6r�)r�r�r�rr�r)r!�p�kr�r%s    �rrzaugeas.__init__�s4�����
�
�4�6H�!"�	�	$�
�f�d�$�a�-�1�-r
)r'r(r)r�rr*r+s@rr�r��s����.�.r
r�N)r��sysr�_pyver�
augeas.ffirr�
__author__�__credits__�PY3rryr\�
basestringrr�IOErrorrrar.�
ValueErrorr1�objectr4r��__all__r�r
r�<module>rs���	�@'��
>�
���
��n��	����L��L����G������z��n	�V�n	�f.�V�.��X�
�r