ó QTc@sËdZdZdZddlZddlZddlZddlmZddl m Z edfkZ dZ e rze ZneZd „Zd „Zd „Zd efd „ƒ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 s”Jeff Schroeder Harald Hoyer - initial python bindings, packaging Nils Philippsen iÿÿÿÿN(t version_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(tctypestcdllt LoadLibrary(txty((s*/usr/lib/python2.7/site-packages/augeas.pytIssUnable to import lib%s!iN(R tutilt find_libraryRtNonet ImportError(targstatltlibstlib((s*/usr/lib/python2.7/site-packages/augeas.pyt_dlopenDs >tAugeascBs:eZdZedƒZejej_dZ d Z d!Z d"Z d#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ƒ‚nt j |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 isinstancet string_typesRt TypeErrortintRt _libaugeastaug_initRt_Augeas__handlet RuntimeErrorR 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‡t dƒ‚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‡t dƒ‚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¯t dƒ‚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|jstdƒ‚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  0 cCs¬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"RRt aug_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|ƒ|rdp„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.pytmatchs"   $c Cs?t|tƒstdƒ‚n|js6tdƒ‚ntjƒ}tjƒ}tjƒ}tjƒ}tjƒ}tjƒ}tjƒ}tj} t j j |jt |ƒ| |ƒ| |ƒ| |ƒ| |ƒ| |ƒ| |ƒ| |ƒƒ } | dkr t 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$R0tfilenamet label_startt label_endt value_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 trestypetNONEt SAVE_BACKUPt SAVE_NEWFILEt TYPE_CHECKt NO_STDINCt SAVE_NOOPtNO_LOADtNO_MODL_AUTOLOADt ENABLE_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 (RR‚RƒR((((s*/usr/lib/python2.7/site-packages/augeas.pyRLs(Rƒt __author__t __credits__ttypesR t ctypes.utiltsysRt_pyvert functoolsRtPY3RR8Rt basestringRRRtobjectRR(((s*/usr/lib/python2.7/site-packages/augeas.pyt s&       ÿÿ