�
QTc@s�dZdZdZddlZddlZddlZddlmZddl m
Z
edfkZdZerze
ZneZd �Zd
�Zd�Zdefd
��YZdefd��YZdS(s�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.
s/Nathaniel McCallum <nathaniel@natemccallum.com>s�Jeff Schroeder <jeffschroeder@computer.org>
Harald Hoyer <harald@redhat.com> - initial python bindings, packaging
Nils Philippsen <nils@redhat.com>
i����N(tversion_info(treduceitutf8cCs|r|jt�SdS(N(tencodetAUGENC(tst((s*/usr/lib/python2.7/site-packages/augeas.pytenc:scCs|r|jt�SdS(N(tdecodeR(R((s*/usr/lib/python2.7/site-packages/augeas.pytdec?scGstgg|D]}tjj|�^q
D]}|r&|^q&}td�|d�}|sptd|d��n|S(s]Search for one of the libraries given as arguments and load it.
Returns the library.
cSs|ptjj|�S(N(tctypestcdlltLoadLibrary(txty((s*/usr/lib/python2.7/site-packages/augeas.pyt<lambda>IssUnable to import lib%s!iN(R tutiltfind_libraryRtNonetImportError(targstatltlibstlib((s*/usr/lib/python2.7/site-packages/augeas.pyt_dlopenDs
>tAugeascBs:eZdZed�Zejej_dZ d Z
d!Zd"Zd#Z
d$Zd%Zd&Zd'Zd(d(e d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zed�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d(d)d�Z'e(d�Z)d�Z*RS(*s$Class wrapper for the augeas librarytaugeasiiiiiiiicCs�t|t�r+|dkr+td��nt|t�rV|dkrVtd��nt|t�sttd��ntjjt|�t|�|�|_ |j s�t
d��ntj|j �|_ dS(s�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.sroot MUST be a string or None!s"loadpath MUST be a string or None!sflag MUST be a flag!sUnable to create Augeas object!N(
t
isinstancetstring_typesRt TypeErrortintRt
_libaugeastaug_initRt_Augeas__handletRuntimeErrorR tc_void_p(tselftroottloadpathtflags((s*/usr/lib/python2.7/site-packages/augeas.pyt__init__`s' cCs|j�dS(N(tclose(R$((s*/usr/lib/python2.7/site-packages/augeas.pyt__del__|scCs�t|t�std��n|js6td��ntj�}tjj |jt
|�tj|��}|dkr�td��nt
|j�S(s�Lookup the value associated with 'path'.
Returns the value at the path specified.
It is an error if more than one node matches 'path'.spath MUST be a string!s*The Augeas object has already been closed!is$path specified had too many matches!(RRRR!R"R tc_char_pRRtaug_getRtbyreft
ValueErrorRtvalue(R$tpathR/tret((s*/usr/lib/python2.7/site-packages/augeas.pytgets cCs�t|t�std��n|js6td��ntj�}tjj |jt
|�tj|��}|dkr�td��nt
|j�S(s�Lookup the label associated with 'path'.
Returns the label of the path specified.
It is an error if more than one node matches 'path'.spath MUST be a string!s*The Augeas object has already been closed!is$path specified had too many matches!(RRRR!R"R R+RRt aug_labelRR-R.RR/(R$R0tlabelR1((s*/usr/lib/python2.7/site-packages/augeas.pyR4�s cCs�t|t�std��nt|t�rUt|�td�krUtd��n|jsmtd��ntjj |jt
|�t
|��}|dkr�td��ndS(s�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'.spath MUST be a string!svalue MUST be a string or None!s*The Augeas object has already been closed!isUnable to set value to path!N(RRRttypeRR!R"RRtaug_setRR.(R$R0R/R1((s*/usr/lib/python2.7/site-packages/augeas.pytset�s( 'cCs�t|�tkr!td��nt|�tkrN|dkrNtd��nt|�tkrotd��n|js�td��ntjj|jt |�t |�t |��}|dkr�t
d��n|S(sSet 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.sbase MUST be a string!ssub MUST be a string or None!svalue MUST be a string!s*The Augeas object has already been closed!isUnable to set value to path!N(R5tstrRRR!R"RRtaug_setmRR.(R$tbasetsubR/R1((s*/usr/lib/python2.7/site-packages/augeas.pytsetm�s 'cCs�t|t�std��nt|t�s<td��nt|t�sZtd��n|jsrtd��ntjj|jt|�t|�t|��}|dkr�t d��n|S(s�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.slens MUST be a string!snode MUST be a string!spath MUST be a string!s*The Augeas object has already been closed!isUnable to store text at node!(
RRRR!R"RRtaug_text_storeRR.(R$tlenstnodeR0R1((s*/usr/lib/python2.7/site-packages/augeas.pyt
text_store�s 'cCs�t|t�std��nt|t�s<td��nt|t�sZtd��nt|t�sxtd��n|js�td��ntjj|jt|�t|�t|�t|��}|dkr�t d��n|S(s�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.slens MUST be a string!snode_in MUST be a string!spath MUST be a string!snode_out MUST be a string!s*The Augeas object has already been closed!isUnable to store text at node!(
RRRR!R"RRtaug_text_retrieveRR.(R$R>tnode_inR0tnode_outR1((s*/usr/lib/python2.7/site-packages/augeas.pyt
text_retrieve�s 0cCs�t|�tkr!td��nt|�tkrN|dkrNtd��n|jsftd��ntjj|jt |�t |��}|dkr�t
d��n|S(s~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 '$'.sname MUST be a string!sexpr MUST be a string or None!s*The Augeas object has already been closed!isUnable to register variable!N(R5R8RRR!R"RRt
aug_defvarRR.(R$tnametexprR1((s*/usr/lib/python2.7/site-packages/augeas.pytdefvars 'cCs�t|�tkr!td��nt|�tkrBtd��nt|�tkrctd��n|js{td��ntjj|jt|�t|�t|�d�}|dkr�t
d��n|S(s�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.sname MUST be a string!sexpr MUST be a string!svalue MUST be a string!s*The Augeas object has already been closed!isUnable to register node!N(R5R8RR!R"RRtaug_defnodeRRR.(R$RFRGR/R1((s*/usr/lib/python2.7/site-packages/augeas.pytdefnodes *cCs�t|t�std��nt|t�s<td��n|jsTtd��ntjj|jt|�t|��}|dkr�t d��ndS(sjMove 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.ssrc MUST be a string!sdst MUST be a string!s*The Augeas object has already been closed!isUnable to move src to dst!N(
RRRR!R"RRtaug_mvRR.(R$tsrctdstR1((s*/usr/lib/python2.7/site-packages/augeas.pytmove7s 'cCs�t|t�std��nt|t�s<td��n|jsTtd��ntjj|jt|�t|��}|dkr�t d��n|S(s6Rename the label of all nodes matching 'src' to 'lbl'.ssrc MUST be a string!sdst MUST be a string!s*The Augeas object has already been closed!isUnable to rename src as dst!(
RRRR!R"RRt
aug_renameRR.(R$RLRMR1((s*/usr/lib/python2.7/site-packages/augeas.pytrenameKs 'cCs�t|t�std��nt|t�s<td��n|jsTtd��ntjj|jt|�t|�|r�dp�d�}|dkr�t d��ndS(sXCreate 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]'.spath MUST be a string!slabel MUST be a string!s*The Augeas object has already been closed!iisUnable to insert label!N(
RRRR!R"RRt
aug_insertRR.(R$R0R4tbeforeR1((s*/usr/lib/python2.7/site-packages/augeas.pytinsert\s
cCsRt|t�std��n|js6td��ntjj|jt|��S(s�Remove 'path' and all its children. Returns the number of entries
removed. All nodes that match 'path', and their descendants, are
removed.spath MUST be a string!s*The Augeas object has already been closed!( RRRR!R"RRtaug_rmR(R$R0((s*/usr/lib/python2.7/site-packages/augeas.pytremovess
cCst|t�std��n|js6td��ntjtj��}tj j
|jt|�tj|��}|dkr�td|��ng}xgt
|�D]Y}||r�|jttj||tj�j��tjjtj||��q�q�Wtjj|�|S(s�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.spath MUST be a string!s*The Augeas object has already been closed!isError during match procedure!(RRRR!R"R tPOINTERR#RRt aug_matchRR-trangetappendRtcastR+R/t pythonapit
PyMem_Free(R$R0tarrayR1tmatchesti((s*/usr/lib/python2.7/site-packages/augeas.pytmatch�s"
$cCs?t|t�std��n|js6td��ntj�}tj�}tj�}tj�}tj�}tj�}tj�}tj} t j
j|jt|�| |�| |�| |�| |�| |�| |�| |�� }
|
dkrt
d��nt|j�|j|j|j|j|j|jfS(siGet 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.spath MUST be a string!s*The Augeas object has already been closed!isError during span procedure(RRRR!R"R R+tc_uintR-RRtaug_spanRR.RR/(R$R0tfilenametlabel_startt label_endtvalue_startt value_endt
span_starttspan_endtrR1((s*/usr/lib/python2.7/site-packages/augeas.pytspan�s* !cCsL|jstd��ntjj|j�}|dkrHtd��ndS(s�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.s*The Augeas object has already been closed!isUnable to save to file!N(R!R"RRtaug_savetIOError(R$R1((s*/usr/lib/python2.7/site-packages/augeas.pytsave�s
cCsL|jstd��ntjj|j�}|dkrHtd��ndS(s�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.s*The Augeas object has already been closed!isaug_load() failed!N(R!R"RRtaug_load(R$R1((s*/usr/lib/python2.7/site-packages/augeas.pytload�s
cCs|jd�dS(sClear all transforms beneath /augeas/load. If load() is called right
after this, there will be no files beneath /files.s/augeas/load/*N(RU(R$((s*/usr/lib/python2.7/site-packages/augeas.pytclear_transforms
scCs�|r+ddl}|jdtdd�nt|t�rF|g}nt|t�ra|g}nx1tt|��D]}|j|||t�qtWx1tt|��D]}|j|||t �q�WdS(sAdd 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
i����Ns'name is now deprecated in this functiont
stackleveli(
twarningstwarntDeprecationWarningRRRXtlent transformtFalsetTrue(R$R>tinclRFtexclRsR_((s*/usr/lib/python2.7/site-packages/augeas.pyt
add_transforms
cCs�t|t�std��nt|t�s<td��nt|t�sZtd��n|jsrtd��ntjj|jt |�t |�|�}|dkr�td��ndS(s$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.
slens MUST be a string!sfile MUST be a string!sexcl MUST be a boolean!s*The Augeas object has already been closed!isUnable to add transform!N(
RRRtboolR!R"RRt
aug_transformR(R$R>tfileR{R1((s*/usr/lib/python2.7/site-packages/augeas.pyRw&s *cCs-|js
dStjj|j�d|_dS(s�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(R!RRt aug_closeR(R$((s*/usr/lib/python2.7/site-packages/augeas.pyR);s iiiiii i@i�N((+t__name__t
__module__t__doc__RRR R#R trestypetNONEtSAVE_BACKUPtSAVE_NEWFILEt
TYPE_CHECKt NO_STDINCt SAVE_NOOPtNO_LOADtNO_MODL_AUTOLOADtENABLE_SPANRR(R*R2R4R7R<R@RDRHRJRNRPRyRSRUR`RkRnRpRqR|RxRwR)(((s*/usr/lib/python2.7/site-packages/augeas.pyRNsD 1 " RcBseZdZd�ZRS(s2Compat class, obsolete. Use class Augeas directly.cOs?ddl}|jdtdd�tt|�j||�dS(Ni����suse Augeas instead of augeasRri(RsRtRutsuperRR((R$tptkRs((s*/usr/lib/python2.7/site-packages/augeas.pyR(Os(R�R�R�R((((s*/usr/lib/python2.7/site-packages/augeas.pyRLs(R�t
__author__t__credits__ttypesR tctypes.utiltsysRt_pyvert functoolsRtPY3RR8Rt
basestringRRRtobjectRR(((s*/usr/lib/python2.7/site-packages/augeas.pyt<module>s&
�� |