%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/__pycache__/augeas.cpython-312.pyc

�

�XT\���dZdZdZddlZddlZddlZddlmZddl	m
Z
edk\ZdZere
ZneZd	�Zd
�Zd�ZGd�d
e�ZGd�de�Zy)a�Pure python bindings for the augeas library

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.

z/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>
�N)�version_info)�reduce)��utf8c�2�|r|jt�Sy�N)�encode�AUGENC��sts �(/usr/lib/python3/dist-packages/augeas.py�encr:���	��y�y�� � �
�c�2�|r|jt�Syr)�decoder
rs r
�decr?rrc���|D�cgc]!}tjj|���#c}D�cgc]}|s�|��	}}td�|d�}|st	d|dz��|Scc}wcc}w)z]Search for one of the libraries given as arguments and load it.
    Returns the library.
    c�H�|xstjj|�Sr)�ctypes�cdll�LoadLibrary)�x�ys  r
�<lambda>z_dlopen.<locals>.<lambda>Is��q�>�F�K�K�$;�$;�A�$>�rNzUnable to import lib%s!r)r�util�find_libraryr�ImportError)�args�a�l�libs�libs     r
�_dlopenr$Dsi��?C�D�����1�1�!�4�D�J�!��A�J�D�J��>��d�K�C���3�d�1�g�=�>�>��J��	E��Js�&A!�A&�A&c��eZdZdZed�Zejej_	dZ
dZdZdZ
dZdZd	Zd
ZdZdde
fd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd#d�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d$d �Z&d%d!�Z'd"�Z(y)&�Augeasz$Class wrapper for the augeas library�augeasr������ �@�Nc��t|t�s|dk7rtd��t|t�s|dk7rtd��t|t�std��tj
j
t|�t|�|�|_|jstd��tj|j�|_y)a�Initialize the library.

        Use 'root' as the filesystem root. If 'root' is None, use the value of
        the environment variable AUGEAS_ROOT. If that doesn't exist either,
        use "/".

        'loadpath' is a colon-spearated list of directories that modules
        should be searched in. This is in addition to the standard load path
        and the directories in AUGEAS_LENS_LIB.

        'flags' is a bitmask made up of values from AUG_FLAGS.Nzroot MUST be a string or None!z"loadpath MUST be a string or None!zflag MUST be a flag!zUnable to create Augeas object!)�
isinstance�string_types�	TypeError�intr&�
_libaugeas�aug_initr�_Augeas__handle�RuntimeErrorr�c_void_p)�self�root�loadpath�flagss    r
�__init__zAugeas.__init__`s����$��-�$�$�,��<�=�=��(�L�1�h�$�6F��@�A�A��%��%��2�3�3��)�)�2�2�3�t�9�c�(�m�U�S��
��}�}��@�A�A�����
�
�6��
rc�$�|j�yr)�close�r:s r
�__del__zAugeas.__del__|s���
�
�rc�f�t|t�std��|jst	d��tj�}tjj|jt|�tj|��}|dkDrtd��t|j�S)z�Lookup the value associated with 'path'.
        Returns the value at the path specified.
        It is an error if more than one node matches 'path'.�path MUST be a string!�*The Augeas object has already been closed!r(�$path specified had too many matches!)r1r2r3r7r8r�c_char_pr&r5�aug_getr�byref�
ValueErrorr�value�r:�pathrK�rets    r
�getz
Augeas.gets����$��-��4�5�5��}�}��K�L�L����!�����'�'��
�
�s�4�y�(.���U�(;�=����7��C�D�D��5�;�;��rc�f�t|t�std��|jst	d��tj�}tjj|jt|�tj|��}|dkDrtd��t|j�S)z�Lookup the label associated with 'path'.
        Returns the label of the path specified.
        It is an error if more than one node matches 'path'.rDrEr(rF)r1r2r3r7r8rrGr&r5�	aug_labelrrIrJrrK)r:rM�labelrNs    r
rRzAugeas.label�s����$��-��4�5�5��}�}��K�L�L����!�����)�)�$�-�-��T��*0�,�,�u�*=�?����7��C�D�D��5�;�;��rc�f�t|t�std��t|t�s"t|�td�k7rtd��|jstd��tjj|jt|�t|��}|dk7rtd��y)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'.rDNzvalue MUST be a string or None!rEr�Unable to set value to path!)r1r2r3�typer7r8r&r5�aug_setrrJrLs    r
�setz
Augeas.set�s����$��-��4�5�5��%��.�4��;�$�t�*�3L��=�>�>��}�}��K�L�L����'�'��
�
�s�4�y�#�e�*�M���!�8��;�<�<�rc��t|�tk7rtd��t|�tk7r|dk7rtd��t|�tk7rtd��|jst	d��t
jj|jt|�t|�t|��}|dkrtd��|S)aSet 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 None, in which case all the nodes matching
        'base' will be modified.zbase MUST be a string!Nzsub MUST be a string or None!�value MUST be a string!rErrT)
rU�strr3r7r8r&r5�aug_setmrrJ)r:�base�subrKrNs     r
�setmzAugeas.setm�s�����:����4�5�5���9����t���;�<�<���;�#���5�6�6��}�}��K�L�L����(�(��M�M�3�t�9�c�#�h��E�
�<����7��;�<�<��
rc��t|t�std��t|t�std��t|t�std��|jst	d��t
jj|jt|�t|�t|��}|dk7rtd��|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!rDrEr�Unable to store text at node!)
r1r2r3r7r8r&r5�aug_text_storerrJ)r:�lens�noderMrNs     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��<�=�=��
rc	���t|t�std��t|t�std��t|t�std��t|t�std��|jst	d��t
jj|jt|�t|�t|�t|��}|dk7rtd��|S)z�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.r`znode_in MUST be a string!rDznode_out MUST be a string!rErra)
r1r2r3r7r8r&r5�aug_text_retrieverrJ)r:rc�node_inrM�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����1�1��M�M�3�t�9�c�'�l�C��I�s�8�}�N���!�8��<�=�=��
rc�L�t|�tk7rtd��t|�tk7r|dk7rtd��|jst	d��t
jj|jt|�t|��}|dkrtd��|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 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 '$'.�name MUST be a string!Nzexpr MUST be a string or None!rErzUnable to register variable!)
rUrZr3r7r8r&r5�
aug_defvarrrJ)r:�name�exprrNs    r
�defvarz
Augeas.defvars�����:����4�5�5���:�������<�=�=��}�}��K�L�L����*�*�4�=�=�#�d�)�S��Y�O����7��;�<�<��
rc��t|�tk7rtd��t|�tk7rtd��t|�tk7rtd��|jst	d��t
jj|jt|�t|�t|�d�}|dkrtd��|S)a�Define a variable 'name' whose value is the result of
        evaluating 'expr', which must not be 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.rlzexpr MUST be a string!rYrENrzUnable to register node!)
rUrZr3r7r8r&r5�aug_defnoderrJ)r:rnrorKrNs     r
�defnodezAugeas.defnodes�����:����4�5�5���:����4�5�5���;�#���5�6�6��}�}��K�L�L����+�+��M�M�3�t�9�c�$�i��U��T�C����7��7�8�8��
rc�8�t|t�std��t|t�std��|jst	d��t
jj|jt|�t|��}|dk7rtd��y)ajMove 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!rErzUnable to move src to dst!N)
r1r2r3r7r8r&r5�aug_mvrrJ�r:�src�dstrNs    r
�movezAugeas.move7s����#�|�,��3�4�4��#�|�,��3�4�4��}�}��K�L�L����&�&�t�}�}�c�#�h��C��I���!�8��9�:�:�rc�:�t|t�std��t|t�std��|jst	d��t
jj|jt|�t|��}|dkrtd��|S)z6Rename the label of all nodes matching 'src' to 'lbl'.rurvrErzUnable to rename src as dst!)
r1r2r3r7r8r&r5�
aug_renamerrJrxs    r
�renamez
Augeas.renameKs����#�|�,��3�4�4��#�|�,��3�4�4��}�}��K�L�L����*�*�4�=�=�#�c�(�C��H�M����7��;�<�<��
rc�J�t|t�std��t|t�std��|jst	d��t
jj|jt|�t|�|xrdxsd�}|dk7rtd��y)aXCreate a new sibling 'label' for 'path' by inserting into the tree
        just before 'path' (if 'before' is True) or just after 'path'
        (if 'before' is False).

        'path' must match exactly one existing node in the tree, and 'label'
        must be a label, i.e. not contain a '/', '*' or end with a bracketed
        index '[N]'.rDzlabel MUST be a string!rEr(rzUnable to insert label!N)
r1r2r3r7r8r&r5�
aug_insertrrJ)r:rMrR�beforerNs     r
�insertz
Augeas.insert\s����$��-��4�5�5��%��.��5�6�6��}�}��K�L�L����*�*�4�=�=�#�d�)�+.�u�:�v�|�!�7H�q�J���!�8��6�7�7�rc���t|t�std��|jst	d��t
jj|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.rDrE)	r1r2r3r7r8r&r5�aug_rmr)r:rMs  r
�removez
Augeas.removessP���$��-��4�5�5��}�}��K�L�L�� � �'�'��
�
�s�4�y�A�Arc	���t|t�std��|jst	d��tjt
j��}tjj|jt|�tj|��}|dkrt	d|��g}t|�D]�}||s�	|jttj ||t
j"�j$��t
j&j)tj||����t
j&j)|�|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 '/'; each segment can
        either be a '*', 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 Nth node with that label (counting from 1), or the
        special expression '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.rDrErzError during match procedure!)r1r2r3r7r8r�POINTERr9r&r5�	aug_matchrrI�range�appendr�castrGrK�	pythonapi�
PyMem_Free)r:rM�arrayrN�matches�is      r
�matchzAugeas.match�s��"�$��-��4�5�5��}�}��K�L�L�0����v���/�1�����)�)�$�-�-��T��*0�,�,�u�*=�?����7��>��E�E����s��	G�A��Q�x����s�6�;�;�u�Q�x�/5���$@�@E�� G�H�
� � �+�+�F�O�O�E�!�H�,E�F�	G�	���#�#�E�*��rc
�6�t|t�std��|jst	d��tj�}tj�}tj�}tj�}tj�}tj�}tj�}t
j}	tjj|jt|�|	|�|	|�|	|�|	|�|	|�|	|�|	|��	}
|
dkrtd��t|j�|j|j|j|j|j|jfS)aiGet the span according to input file of the node associated with
        PATH. If the node is associated with a file, un tuple of 5 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, ValueError is raised.rDrErzError during span procedure)r1r2r3r7r8rrG�c_uintrIr&r5�aug_spanrrJrrK)r:rM�filename�label_start�	label_end�value_start�	value_end�
span_start�span_end�rrNs           r
�spanzAugeas.span�s+���$��-��4�5�5��}�}��K�L�L��?�?�$���m�m�o���M�M�O�	��m�m�o���M�M�O�	��]�]�_�
��=�=�?���L�L�����(�(�����D�	�1�X�;�)*�;���9��)*�;���9��)*�:���(��E��
�!�G��:�;�;��H�N�N�#�[�%6�%6�	����!�!�9�?�?�� � �(�.�.�2�	2rc��|jstd��tjj	|j�}|dk7rtd��y)a�Write all pending changes to disk. Only files that had any changes
        made to them are written.

        If SAVE_NEWFILE is set in the creation 'flags', create changed files as
        new files with the extension ".augnew", and leave the original file
        unmodified.

        Otherwise, if SAVE_BACKUP is set in the creation 'flags', move the
        original file to a new file with extension ".augsave".

        If neither of these flags is set, overwrite the original file.rErzUnable to save to file!N)r7r8r&r5�aug_save�IOError�r:rNs  r
�savezAugeas.save�sK���}�}��K�L�L����(�(����7���!�8��3�4�4�rc��|jstd��tjj	|j�}|dk7rtd��y)a�Load files into the tree. Which files to load and what lenses to use
        on them is specified under /augeas/load in the tree; each entry
        /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 NAME has no meaning.

        The 'lens' grandchild of /augeas/load specifies which lens to use, and
        can either be the fully qualified name of a lens 'Module.lens' or
        '@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 /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 /augeas/load with the
        transforms marked for autoloading in all the modules it finds.

        Before loading any files, AUG_LOAD will remove everything underneath
        /augeas/files and /files, regardless of whether any entries have been
        modified or not.rErzaug_load() failed!N)r7r8r&r5�aug_loadr�s  r
�loadzAugeas.load�sI��2�}�}��K�L�L����(�(����7���!�8��3�4�4�rc�&�|jd�y)zClear all transforms beneath /augeas/load. If load() is called right
        after this, there will be no files beneath /files.z/augeas/load/*N)r�rAs r
�clear_transformszAugeas.clear_transforms
s��	
���$�%rc�H�|rddl}|jdtd��t|t�r|g}t|t�r|g}tt
|��D]}|j|||d��tt
|��D]}|j|||d��y)aAdd a transform beneath /augeas/load.

        lens: the (file)name of the lens to use
        incl: one or more glob patterns for the files to transform
        name: deprecated parameter
        excl: zero or more glob patterns of files to exclude from transforming
        rNz'name is now deprecated in this functionr)��
stacklevelFT)�warnings�warn�DeprecationWarningr1r2r��len�	transform)r:rc�inclrn�exclr�r�s       r
�
add_transformzAugeas.add_transforms������M�M�C�EW�%&�
�
(��t�\�*��6�D��t�\�*��6�D��s�4�y�!�	1�A��N�N�4��a��%�0�	1��s�4�y�!�	0�A��N�N�4��a��$�/�	0rc�p�t|t�std��t|t�std��t|t�std��|jstd��tjj|jt|�t|�|�}|dk7rtd��y)a$Add a transform for 'file' using 'lens'.
        'excl' specifies if this the file is to be included (False)
        or excluded (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.
        r`zfile MUST be a string!zexcl MUST be a boolean!rErzUnable to add transform!N)
r1r2r3�boolr7r8r&r5�
aug_transformr)r:rc�filer�rNs     r
r�zAugeas.transform&s����$��-��4�5�5��$��-��4�5�5��$��%��5�6�6��}�}��K�L�L����-�-�d�m�m�S��Y��D�	�SW�X���!�8��9�:�:�rc�~�|jsytjj|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)r7r&r5�	aug_closerAs r
r@zAugeas.close;s1���}�}��	���#�#�D�M�M�2���
r)T)N�)F))�__name__�
__module__�__qualname__�__doc__r$r5rr9r6�restype�NONE�SAVE_BACKUP�SAVE_NEWFILE�
TYPE_CHECK�	NO_STDINC�	SAVE_NOOP�NO_LOAD�NO_MODL_AUTOLOAD�ENABLE_SPANr>rBrOrRrWr^rerjrprsr{r~r�r�r�r�r�r�r�r�r�r@r�rr
r&r&Ns���*���"�J�"(�/�/�J����
�D��K��L��J��I��I��G����K� �4�t�7�8� �, �,=�$�0�,�0�2�6;�(�"8�.B�/�b 2�D5�,5�@&�
0�.;�*
rr&c�"��eZdZdZ�fd�Z�xZS)r'z2Compat class, obsolete. Use class Augeas directly.c�d��ddl}|jdtd��tt|�|i|��y)Nrzuse Augeas instead of augeasr)r�)r�r�r��superr'r>)r:�p�kr��	__class__s    �r
r>zaugeas.__init__Os4�����
�
�4�6H��	�	�
�f�d�$�a�-�1�-r)r�r�r�r�r>�
__classcell__)r�s@r
r'r'Ls���8�.�.rr')r��
__author__�__credits__�typesr�ctypes.util�sysr�_pyver�	functoolsr�PY3r
rZr2�
basestringrrr$�objectr&r'r�rr
�<module>r�ss���D?�
���

�
��&��
��n��	����L��L�!�
!�
�z�V�z�|.�V�.r

Zerion Mini Shell 1.0