MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //etc/leapp/repos.d/system_upgrade/el7toel8/libraries/isccfg.pyc
�
��ic@s�ddlmZddlZddlZdefd��YZdefd��YZdefd��YZd	efd
��YZ	defd��YZ
d
efd��YZde	fd��YZdefd��YZ
defd��YZedkr�ddlmZd�ZejZee�dkr;edZnee�dkruiZxedD]Zeee<q^Wnied6ed6Zee�Zx=ejD]2Zedjej��ejej�e�q�WndS(i����(tprint_functionNtConfigParseErrorcBseZdZddd�ZRS(s'Generic error when parsing config file.cCsidjd|jdt|��}|r=|dj|�7}ntt|�j|�||_||_dS(Ns4Cannot open the configuration file "{path}": {error}tpathterrors; included from "{0}"(tformattfilenametstrtsuperRt__init__Rtparent(tselfRR	tmessage((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRs		N(t__name__t
__module__t__doc__tNoneR(((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRs	t
ConfigFilecBsDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(s=Representation of single configuration file and its contents.cCs#||_|j|�d|_dS(sPLoad config file contents from path.

        :param path: Path to file
        N(RtloadRtstatus(R
R((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRs	
cCs|jS(N(tbuffer(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt__str__%scCsdj|j|j�S(NsConfigFile {0} ({1})(RRR(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt__repr__(scCs2t|d��}|j�|_|_WdQXdS(Ntr(topentreadRtoriginal(R
Rtf((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR,scCs|j|jkS(N(RR(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytis_modified0scCst|ddt|j��S(Ni(t
ConfigSectionRtlenR(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytroot_section3s(	RR
RRRRRRR(((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRs						t
MockConfigcBs)eZdZdZed�Zd�ZRS(sgConfiguration file with contents defined on constructor.

       Intended for testing the library.
    s/etc/named/mock.confcCs#||_tt|�j|�dS(N(RRRR(R
tcontentsR((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR>s	cCs|j|_dS(N(RR(R
R((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRBs(RR
RtDEFAULT_PATHRR(((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR7sRcBs�eZdZdZdZdZdZdddddd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zed
�Zd�ZRS(s�Representation of section or key inside single configuration file.

    Section means statement, block, quoted string or any similar.iiiicCs�||_||_||_||_|j�|_||_|dkr�|jjj	d|j�rr|j
|_q�|jjj	d|j�r�|j|_q�|j
|_n	||_g|_dS(s�
        :param config: config file inside which is this section
        :type config: ConfigFile
        :param kind: type of this section
        t{t"N(tconfigtnametstarttendtoriginal_valuetctexttparserRRt
startswitht
TYPE_BLOCKtkindtTYPE_QSTRINGt	TYPE_BAREt
statements(R
R$R%R&R'R-R*((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRPs						cCsI|j�}|jj}djd|d|jd|jd|d|j�S(Ns4ConfigSection#{kind}({path}:{start}-{end}: "{text}")RR&R'ttextR-(tvalueR$RRR&R'R-(R
R1R((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRgs
	cCs
|j�S(N(R2(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRoscCs%t|j|j|j|j|j�S(N(RR$R%R&R'R-(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytcopyrscCs|jS(N(R-(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyttypeuscCs|jS(N(R)(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR2xscCs|jj|j|jd!S(Ni(R$RR&R'(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR({scCs<|j�}||j|jfkr2|jdd!S|j�S(s6Return just inside value of blocks and quoted strings.ii����(R4R.R,R)R2(R
tt((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytinvalue~scCsG|j}|j�|jkr+|d7}ntt|j|||��S(s)Return list of items inside this section.i(R&R4R,tlisttIscIteratorR*(R
tcommentsR&((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytchildren�s	
cCs
|j�S(N(R2(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt	serialize�sN(RR
RR/R.R,tTYPE_IGNOREDRRRRR3R4R2R(R6tFalseR:R;(((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRFs							R8cBs5eZdZedd�Zd�Zd�ZeZRS(s�Iterator for walking over parsed configuration.

       Creates sequence of ConfigSection objects for a given file.
       That means a stream of objects.
    cCs[||_||_d|_t|_||_d|_|dkrN|j}n||_dS(s�Create iterator.

        :param comments: Include comments and whitespaces
        :param start: Index for starting, None means beginning of section
        N(	R*tsectionRtcurrenttTruet
key_wantedR9twaitingR&(R
R*R>R9R&((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR�s						cCsd|_t|_d|_|S(N(RR?R@RARB(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt__iter__�s			c
Cs�|j}|jj}|jr:|j|_d|_|jS|jdk	r\|jjd}n|jr�|jj	|||jj�}t
|_nW|jj|d||jjdt�}|dk	r�|j
�|jjkr�t|_n|dkr\|jdk	rS|jj|jjkrS|jrSt|jjd||jjtj�|_|jSt�n||jkr�|jr�||_t|jd||jdtj�}n||_|S(Nit
end_report(R&R>R$RBR?RR'RAR*t
find_next_keyR=t
find_next_valR@R2t
CHAR_DELIMR9RR<t
StopIteration(R
tindextcfgtval((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt__next__�s2				'$0		(	N(	RR
RR=RRRCRLtnext(((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR8�s
		tIscVarIteratorcBs5eZdZedd�Zd�Zd�ZeZRS(s�Iterator for walking over parsed configuration.

       Creates sequence of ConfigVariableSection objects for a given
       file or section.
    cCs.||_||_t||||�|_dS(sCreate iterator.N(R*R>R8titer(R
R*R>R9R&((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR�s		cCs|S(N((R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRC�scCs�g}ydt|j�}xN|rh|j|�|jj|�rVt|dd|j�St|j�}qWWn-tk
r�|r�t|dd|j�SnXt�dS(NR	(	RMROtappendR*tis_terminaltConfigVariableSectionRR>RH(R
tvlt	statement((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRL�s	

N(	RR
RR=RRRCRLRM(((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRN�s
		RRcBsYeZdZdddd�Zd�Zd�Zd�Zd�Zd�Z	dd�Z
RS(	s[Representation for key and values of variable length.

    Intended for view and zone.
    c	Cs�tt|��}|d}||_tt|�j|j|d|jd|jd|�|dkr�y|j
d�j�|_Wq�t
k
r�q�Xn||_||_dS(s�Creates variable block for zone or view.

        :param sectionlist: list of ConfigSection, obtained from IscConfigParser.find_values()
        iR&R'R*iN(RMtreversedtvaluesRRRRR$R&R'RtvarR6R%t
IndexErrort
zone_classR	(R
tsectionlistR%RYR	R*tlasttfirst((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR�s
	%
	cCs(|jdkr|jS|jd|jS(Nt_(RYRR%(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytkey	scCs|jd|j�S(s(Return first block section in this tool.i(tvartypeR,(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt
firstblockscCsVd}xC|jD]8}|j�tjkr||kr;|S|d7}qqWt�dS(s%Return value by index, ignore spaces.iiN(RVR4RR<RX(R
titntv((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRWscCsSd}x@|jD]5}|j�|kr||kr8|S|d7}qqWt�dS(Nii(RVR4RX(R
RatvtypeRbRc((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR_scCs.d}x!|jD]}||j�7}qW|S(Nt(RVR;(R
tsRc((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR;%scCs�d}d}x�|jD]�}|dkrY|j�|jkr�|}||j�7}q�q|dk	r�|j�|jkr�||7}q||j�7}qW|S(s>
        Create single string from section, but skip whitespace on start.

        :type section: ConfigVariableSection
        :param replace_ignored: Specify replaced text for whitespace

        Allows normalizing with replace ignored sections.
        Is intended to strip possible comments between parts.
        ReN(RRVR4R<R;(R
treplace_ignoredRftnonwhiteRc((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytserialize_skip+s
!
N(RR
RRRR^R`RWR_R;Ri(((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRR�s			
			tModifyStatecBsYeZdZd�Zd�Zd�Zd�Zd�Zed��Z	ed��Z
RS(s�Object keeping state of modifications when walking configuration file statements.

    It would keep modified configuration file and position of last found statement.
    cCsd|_d|_dS(NRei(R2tlastpos(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRIs	cCsq|j}|jd}|j�|jkr7|j}n|jj}|j||j|d!7_|d|_dS(s�Appends content from last seen section to beginning of current one.

        It adds also whitespace on beginning of statement,
        which is usually not interesting for any changes.

        :type section: ConfigVariableSection
        iiN(	R&RVR4R<R'R$RR2Rk(R
R>R'R\RJ((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt
append_beforeMs		
cCs|jd|_dS(s#Set position to the end of section.iN(R'Rk(R
R>((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt
move_after^scCsK|j|jkrG|j|jj|j|jd!7_|j|_ndS(s0Append remaining part of file to modified state.iN(RkR'R2R$R(R
R>((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytfinishbs&cCs|jS(s^Get content of (modified) section.

        Would be valid after finish() was called.
        (R2(R
((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytcontenthscCs>|j|�|jd|jd�d7_|j|�dS(s4parser.walk callback for commenting out the section.s/* t s */N(RlR2RiRm(R>tstate((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytcallback_comment_outos
 cCs|j|�|j|�dS(s,parser.walk callback for skipping a section.N(RlRm(R>Rq((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytcallback_removevs
(RR
RRRlRmRnRotstaticmethodRrRs(((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRjCs					tIscConfigParsercBs�eZdZdZgZdZedZeejZ	ej
ejdZdZ
d%d�Zdd�Zdd	�Zd
�Zed�Zd�Zdd
ed�Zdd
d�Zdd
ed�Zdd
ed�Zd%dd
ed�Zdd
d�Zd�Zd�Zd%dd�Zd�Z d%dd�Z!d�Z"d�Z#d%d%dd�Z$dd�Z%d%d �Z&d!�Z'd"�Z(d#�Z)d%d$�Z*RS(&s�Parser file with support of included files.

    Reads ISC BIND configuration file and tries to skip commented blocks, nested sections and similar stuff.
    Imitates what isccfg does in native code, but without any use of native code.
    s/etc/named.conft;s})]s-_.:R#cCsHt|t�r(|g|_|j�n|dk	rD|j|�ndS(s�Construct parser.

        :param config: path to file or already loaded ConfigFile instance

        Initialize contents from path to real config or already loaded ConfigFile class.
        N(t
isinstanceRtFILES_TO_CHECKtload_included_filesRtload_config(R
R$((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR�s

icCsE||dks=|dt|�krA|||d!dkrAtStS(Nt#iis//s/*(s//s/*(RR@R=(R
tistrRI((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytis_comment_start�s-cCs�t|�}||ks$|dkr(dS||dksK||jd�r[|jd|�S|d|kr�|||d!dkr�|jd|d�}|dkr�|d	SndS(
s�Returns index where the comment ends.

        :param istr: input string
        :param index: begin search from the index; from the start by default

        Support usual comments till the end of line (//, #) and block comment
        like (/* comment */). In case that index is outside of the string or end
        of the comment is not found, return -1.

        In case of block comment, returned index is position of slash after star.
        ii����R{s//s
is/*s*/i(RR+tfind(R
R|RItlengthtres((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt_find_end_of_comment�s#'cCs
|dkS(Ns"'{([((R
tc((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytis_opening_char�scCs%d}t|�}d}x||kr |j||�r�|j||�}|dkr`|}n|rx|j|�}n||kr||dkr|d7}qno|||jkr|j||�}|dkr�|||7}Pn||||d!7}|}n|||7}|d7}qW|S(s�Removes all comments from the given string.

        :param istr: input string
        :param space_replace When true, replace comments with spaces. Skip them by default.
        :return: istr without comments
        Reii����s
i(RR}R�tljustt
CHAR_STR_OPENt_find_closing_char(R
R|t
space_replacetostrRRItend_str((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt_remove_comments�s,		cCs|j|t�S(s�Replaces all comments by spaces in the given string.

        :param istr: input string
        :returns: string of the same length with comments replaced
        (R�R@(R
R|((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt_replace_comments�si����cCsRt|�}||ks$|dkr-|}n||ksE|dkrIdS||dkrf|d7}n:|j||�r�|j|||�}|dkr�|d7}q�n�|j||�r�|j||�}|dkr�|d7}q�n�|||jkrc|d7}x�||kr_|||jksN|j||�sN|j||�rRPn|d7}q
Wn=|r�|||jkr�|S|||jkr�|d7}nx�d|ko�|knrM||dkr�|d7}q�n|j||�r|j||�}|dkr@Pq@n*|j||�s<||tj	kr@|S|d7}q�WdS(s�
        Return index of another interesting token or -1 when there is not next.

        :param istr: input string
        :param index: begin search from the index; from the start by default
        :param end_index: stop searching at the end_index or end of the string

        In case that initial index contains already some token, skip to another.
        But when searching starts on whitespace or beginning of the comment,
        choose the first one.

        The function would be confusing in case of brackets, but content between
        brackets is not evaluated as new tokens.
        E.g.:

        "find { me };"      : 5
        " me"               : 1
        "find /* me */ me " : 13
        "/* me */ me"       : 9
        "me;"               : 2
        "{ me }; me"        : 6
        "{ me }  me"        : 8
        "me }  me"          : 3
        "}} me"             : 1
        "me"                : -1
        "{ me } "           : -1
        ii����s\ii(
RR�R�R}R�tCHAR_CLOSING_WHITESPACERGtCHAR_CLOSINGtstringt
whitespace(R
R|RIt	end_indexRDR((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytfind_next_token�sN	



&c
Cs�idd6dd6dd6dd6d|j6}t|�}d|koO|knr]|}n|d	krmd
S||ks�|dkr�d
S|j|||j�}|dkr�d
S||dk}|d7}d}x�||kr�||}|d
kr|d	7}n�|j||�rB|rB|j||�}|d
kr�d
Snr|r�|j|�r�|j||�}	|	d
kr{Pn||	7}n,||kr�||jkr�|d8}n|S|d7}q�Wd
S(s�
        Returns index of equivalent closing character.

        :param istr: input string

        It's similar to the "find" method that returns index of the first character
        of the searched character or -1. But in this function the corresponding
        closing character is looked up, ignoring characters inside strings
        and comments. E.g. for
            "(hello (world) /* ) */ ), he would say"
        index of the third ")" is returned.
        t}R"t)t(t]t[s"iii����iRes//N(RRGRtgetR}R�R�R�(
R
R|RIR�timportant_charsRtclosing_chartisStringtcurr_ct
deep_close((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR�8sL

	




cCs�t|�}t|�}||ks0|dkr9|}n||ksQ|dkrUdSx�|dkr�|j||�r�|||kr�||||jkr�|Snx<|r�|dkr�|||jkr�|j||�}q�W|j||�}qXWdS(s-
        Return index of the key or -1.

        :param istr: input string; it could be whole file or content of a section
        :param key: name of the searched key in the current scope
        :param index: start searching from the index
        :param end_index: stop searching at the end_index or end of the string

        Function is not recursive. Searched key has to be in the current scope.
        Attention:

        In case that input string contains data outside of section by mistake,
        the closing character is ignored and the key outside of scope could be
        found. Example of such wrong input could be:
              key1 "val"
              key2 { key-ignored "val-ignored" };
            };
            controls { ... };
        In this case, the key "controls" is outside of original scope. But for this
        cases you can set end_index to value, where searching should end. In case
        you set end_index higher then length of the string, end_index will be
        automatically corrected to the end of the input string.
        ii����(RR+tCHAR_KEYWORDRGR�(R
R|R^RIR�t
only_firstRtkeylen((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytfind_keyrs	')cCsI|j}t|�}||ks-|dkr6|}n||ksN|dkr]td��nx�|dkrD|}x-||kr�|||jkr�|d7}quW||kr�Pn||ko�|knr�|||jkr�t||||!||d�S|||jkr)t|||||�S|j||||�}q`WdS(s�Modernized variant of find_key.

        :type cfg: ConfigFile
        :param index: Where to start search
        :rtype: ConfigSection

        Searches for first place of bare keyword, without quotes or block.
        isInvalid cfg indexi����iN(RRRXR�RRGR�R(R
RJRIR�RDR|Rtkeystart((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRE�s$			"/cCs�|j|j|||�}|dkr+dS|dkrIt|j�}n|j|j|�su|j||||�S|j|j||�}|dks�d|ko�|knr�dSt||||�S(s�Find following token.

        :param cfg: input token
        :type cfg: ConfigFile
        :returns: ConfigSection object or None
        :rtype: ConfigSection
        ii����N(R�RRRR�RER�R(R
RJR^RIR�RDR&R'((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRF�s(cCs�t|t�std��n|dkr<t|j�}n|j|j|||�}|dksy|t|�|kr}dS|j|||t|�|�S(s4Find value of keyword specified by key.

        :param cfg: ConfigFile
        :param key: name of searched key (str)
        :param index: start of search in cfg (int)
        :param end_index: end of search in cfg (int)
        :returns: ConfigSection object or None
        :rtype: ConfigSection
        s cfg must be ConfigFile parameteriN(RwRt	TypeErrorRRR�RRF(R
RJR^RIR�t	key_start((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytfind_val�s
"cCsAt|t�std��n|j|j||jd|j�S(s�Find value of keyword in section.

        :param section: section object returned from find_val

        Section is object found by previous find_val call.
        ssection must be ConfigSectioni(RwRR�R�R$R&R'(R
R>R^((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytfind_val_section�sc
Csrt|t�r-|}d}t|j�}nVt|t�rw|j}|jd}|j}||kr�|d8}q�ntd��|dkr�|j
|||�}n`|j|j|||�}|t|�d}|dks�||kr�dSt||||�}g}	x^t|t�rm|	j|�|j
�|jkrEPn|j|||jd|dt�}qW|	S(s�Find key in section and list variable parameters.

        :param key: Name to statement to find
        :returns: List of all found values in form of ConfigSection. First is key itself.

        Returns all sections of keyname. They can be mix of "quoted strings", {nested blocks}
        or just bare keywords. First key is section of key itself, final section includes ';'.
        Makes it possible to comment out whole section including terminal character.
        iisUnexpected typeRDN(RwRRRRR$R&R'R�RRER�RPR2RGRFR@(
R
R>R^RJRIR�RcR�tkey_endRV((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytfind_values�s2	
	
)t.cCsn|j|�}|dk	r1|j|j�|�Sg}x0|jD]%}|j|j|j�|��qAW|S(s�Helper searching for values under requested sections.

        Search for statement under some sections. It is inspired by xpath style paths,
        but searches section in bind configuration.

        :param key_string: keywords delimited by dots. For example options.dnssec-lookaside
        :type key_string: str
        :param cfg: Search only in given config file
        :type cfg: ConfigFile
        :returns: list of ConfigVariableSection
        N(tsplitRt_find_values_simpleRRxtextend(R
t
key_stringRJt	delimitertkeystitemstcfgs((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR~"s#cCs|j�|jkS(s?.Returns true when section is final character of one statement.(R2RG(R
R>((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRQ7sicCsy|j|d�j�}d}|j|d�}|j�tjkrf|j|d�rf|j�}nt||||�S(s�Create ConfigVariableSection with a name and optionally class.

        Intended for view and zone in bind.
        :returns: ConfigVariableSection
        iiN(t_list_valueR6RR4RR,R2RR(R
RSR	toffsettvnametvclassRc((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt_variable_section;s'cCsSd}x@|D]8}|j�tjkr
||kr8|S|d7}q
q
Wt�dS(Nii(R4RR<RX(R
RSRaRbRc((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR�Hs
c	Csg}|j�}x�|dk	r�|j||d�}|dkrGPnt|�dkr�|j||�}|j|�|jd|_qxX|D]P}|j�t	j
kr�|j||d�}|dk	r�|j|�q�q�q�W|djd|_qW|S(Niii����(
R3RR�RR�RPR'R&R4RR,R�R�(	R
R>R�tfound_valuestsectRStvariableRctvl2((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR�Qs"

c	Cs�|dkr*|j�tjkr*d}nt||td|j|�}x�|D]�}y?|jd�j�}||kr�||}	|	||�nWntk
r�nXxB|j	D]7}
|
j�tjkr�|j
|
||d|�q�q�WqPW|S(s�Walk over section also with nested blocks.

        :param section: Section to iterate, usually ConfigFile.root_section()
        :param callbacks: Set of callbacks with name: f(section, state) parameters, indexed by statement name
        :param start: Offset from beginning of section

        Call specified actions specified in callbacks, which can react on desired statements.
        Pass state and matching section to callback.
        iiR&R	(R4RR,RNR@R&RWR2RXRVtwalk(R
R>t	callbacksRqR	R&titRTR%Rtchild((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyR�gs
!	


$RecCs+x$|jD]}|j|kr
tSq
WtS(s]
        Checks if the file with a given 'path' is already loaded in FILES_TO_CHECK.
        (RxRR@R=(R
RR((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytis_file_loaded�scCs t|�}|jj|�|S(N(RRxRP(R
RR	R$((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt
new_config�scCs
|�dS(sTHandle IO errors on file reading.

        Override to create custom error handling.N((R
te((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyton_include_error�scCs�tjd�}x�|jD]�}|j|j�}tj||�}x`|D]X}|j|�reqJny|j|�WqJtk
r�}|j	t
||��qJXqJWqWdS(s�Add included list to parser.

        Finds the configuration files that are included in some configuration
        file, reads it, closes and adds into the FILES_TO_CHECK list.
        sinclude\s*"(.+?)"\s*;N(tretcompileRxR�RtfindallR�R�tIOErrorR�R(R
tpatterntch_filet
nocommentstincludestincludeR�((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRy�s
cCs:y|j|j�Wntk
r5}t|��nXdS(sLoads main CONFIG_FILE.N(R�tCONFIG_FILER�R(R
R�((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytload_main_config�scCs0|dk	r||_n|j�|j�dS(s/Loads main config file with all included files.N(RR�R�Ry(R
R((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRz�s
N(+RR
RR�RxRGR�R�R�R�t
ascii_letterstdigitsR�R�RRR}R�R�R=R�R�R�R�R@R�RERFR�R�R�R~RQR�R�R�R�R�R�R�RyR�Rz(((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyRu~sF

	#	K:-$		*	
							t__main__(targvcCst|�dS(N(tprint(R>Rq((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pytprint_cb�siitoptionstzones# Walking file '{}'( t
__future__RR�R�t	ExceptionRtobjectRRRR8RNRRRjRuRtsysR�R�R�tcfgpathRtcbR^R*RxR>R�RRR�R(((sT/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/libraries/isccfg.pyt<module>s8J>!T;��B