|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /lib/python3/dist-packages/__pycache__/ |
Upload File : |
U
�XT\ � @ s� d Z dZdZddlZddlZddlZddlmZ ddl m
Z
edkZdZerRe
ZneZd d
� Zdd� Zd
d� ZG dd� de�ZG dd� de�ZdS )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 C s | r| � t�S d S �N)�encode�AUGENC��st� r �(/usr/lib/python3/dist-packages/augeas.py�enc: s r
c C s | r| � t�S d S r )�decoder r r r r �dec? s r c G s@ dd� dd� | D �D �}t dd� |d�}|s<td| d ��|S ) z]Search for one of the libraries given as arguments and load it.
Returns the library.
c S s g | ]}|r|�qS r r )�.0�lr r r �
<listcomp>H s z_dlopen.<locals>.<listcomp>c S s g | ]}t j�|��qS r )�ctypes�utilZfind_library)r �ar r r r H s c S s | pt j�|�S r )r ZcdllZLoadLibrary)�x�yr r r �<lambda>I � z_dlopen.<locals>.<lambda>NzUnable to import lib%s!r )r �ImportError)�argsZlibs�libr r r �_dlopenD s
r c @ s e Zd ZdZed�Zejej_ dZ
dZdZdZ
dZdZd Zd
ZdZdde
fd
d�Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd#d$� Zd<d&d'�Zd(d)� Z d*d+� Z!d,d-� Z"d.d/� Z#d0d1� Z$d2d3� Z%d=d5d6�Z&d>d8d9�Z'd:d;� Z(dS )?�Augeasz$Class wrapper for the augeas library�augeasr � � � � � � �@ � Nc C s� t |t�s|dkrtd��t |t�s4|dkr4td��t |t�sFtd��tj�t|�t|�|�| _| jsnt d��t
�| j�| _dS )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�rootZloadpath�flagsr r r �__init__` s
zAugeas.__init__c C s | � � d S r )�close�r1 r r r �__del__| s zAugeas.__del__c C s^ t |t�std��| js td��t�� }tj� | jt
|�t�|��}|dkrTtd��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!)r( r) r* r. r/ r �c_char_pr r, Zaug_getr
�byref�
ValueErrorr �value�r1 �pathr>