f _fc@sddlmZddlmZddlZddlZddlZddlZddl Z ddl Z ddl Z gdZ e ZdZdZGdddeZGd d d eZGd d d eZGd ddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZeZGdddZGdd d eZ Gd!d"d"eZ!Gd#d$d$eZ"Gd%d&d&eZ#Gd'd(d(e#Z$Gd)d*d*e$Z%Gd+d,d,eZ&Gd-d.d.eZ'dS)/)MutableMapping)ChainMapN)NoSectionErrorDuplicateOptionErrorDuplicateSectionError NoOptionErrorInterpolationErrorInterpolationDepthErrorInterpolationMissingOptionErrorInterpolationSyntaxError ParsingErrorMissingSectionHeaderError ConfigParserSafeConfigParserRawConfigParser InterpolationBasicInterpolationExtendedInterpolationLegacyInterpolation SectionProxyConverterMapping DEFAULTSECTMAX_INTERPOLATION_DEPTHZDEFAULTi c@s"eZdZdddZddZeZdS)ErrorcCs||_t||dSN)message Exception__init__)selfmsgr %/usr/lib64/python3.10/configparser.pyrszError.__init__cC|jSr)rrr r r!__repr__zError.__repr__N)r)__name__ __module__ __qualname__rr$Z__str__r r r r!rs rc@eZdZddZdS)rcCs$t|d|f||_|f|_dS)NzNo section: %r)rrsectionargsrr*r r r!rszNoSectionError.__init__Nr&r'r(rr r r r!rrc@eZdZdddZdS)rNcCst|dg}|durRdt|g}|dur8|d||d|||}n |ddt|d|||_||_ ||_ |||f|_ dS)N already existsWhile reading from  [line {0:2d}]z : section rzSection r) reprappendformatextendinsertrrjoinr*sourcelinenor+)rr*r9r:rrr r r!rs     zDuplicateSectionError.__init__NNr-r r r r!rsrc@r/)rNcCst|dt|dg}|durZdt|g}|dur@|d||d|||}n |ddt|d|||_||_ ||_ ||_ ||||f|_ dS) Nz in section r0r1r2z : option rzOption r) r3r4r5r6r7rrr8r*optionr9r:r+)rr*r<r9r:rrr r r!rs"    zDuplicateOptionError.__init__r;r-r r r r!rsrc@r))rcCs.t|d||f||_||_||f|_dS)NzNo option %r in section: %rrrr<r*r+)rr<r*r r r!rs zNoOptionError.__init__Nr-r r r r!rr.rc@r))rcCs(t||||_||_|||f|_dSrr=)rr<r*rr r r!rs zInterpolationError.__init__Nr-r r r r!rr.rc@r))r cCs8d||||}t||||||_||||f|_dS)NzBad value substitution: option {!r} in section {!r} contains an interpolation key {!r} which is not a valid option name. Raw value: {!r})r5rr referencer+)rr<r*rawvalr>rr r r!r s z(InterpolationMissingOptionError.__init__Nr-r r r r!r r.r c@s eZdZdS)r N)r&r'r(r r r r!r sr c@r))rcCs0d||t|}t|||||||f|_dS)NzRecursion limit exceeded in value substitution: option {!r} in section {!r} contains an interpolation key which cannot be substituted in {} steps. Raw value: {!r})r5rrrr+)rr<r*r?rr r r!rs z InterpolationDepthError.__init__Nr-r r r r!rr.rc@s8eZdZd ddZeddZejddZddZdS) r NcCsT|r|rtdn|s$|s$tdn|r,|}t|d|||_g|_|f|_dS)Nz:Cannot specify both `filename' and `source'. Use `source'.z%Required argument `source' not given.z"Source contains parsing errors: %r) ValueErrorrrr9errorsr+)rr9filenamer r r!r,s  zParsingError.__init__cCstjdtdd|jSNzSThe 'filename' attribute will be removed in future versions. Use 'source' instead.Z stacklevelwarningswarnDeprecationWarningr9r#r r r!rB; zParsingError.filenamecCstjdtdd||_dSrCrFrvaluer r r!rBErJcCs*|j||f|jd||f7_dS)Nz [line %2d]: %s)rAr4r)rr:liner r r!r4OzParsingError.appendr;)r&r'r(rpropertyrBZsetterr4r r r r!r )s    r c@r))r cCs8t|d|||f||_||_||_|||f|_dS)Nz7File contains no section headers. file: %r, line: %d %r)rrr9r:rMr+)rrBr:rMr r r!rWsz"MissingSectionHeaderError.__init__Nr-r r r r!r Tr.r c@s,eZdZddZddZddZddZd S) rcC|Srr )rparserr*r<rLdefaultsr r r! before_getkr%zInterpolation.before_getcCrPrr rrQr*r<rLr r r! before_setnr%zInterpolation.before_setcCrPrr rTr r r! before_readqr%zInterpolation.before_readcCrPrr rTr r r! before_writetr%zInterpolation.before_writeN)r&r'r(rSrUrVrWr r r r!rhsrc@.eZdZedZddZddZddZdS) rz %\(([^)]+)\)sc C$g}|||||||dd|SNr_interpolate_somer8rrQr*r<rLrRZLr r r!rSzBasicInterpolation.before_getcC<|dd}|jd|}d|vr8td||df|S)Nz%%r%1invalid interpolation syntax in %r at position %dreplace_KEYCREsubr@findrrQr*r<rLZ tmp_valuer r r!rU  zBasicInterpolation.before_setc Csh|j||d|d}|tkr&t||||rd|d} | dkrL||dS| dkrr||d| || d}|dd} | dkr|d|dd}q&| dkrP|j|} | durt||d||| d} || d}z || } Wn$t yt |||| dYn0d| vrD| |||| |||dn|| q&t||d |fq&dS) NTrawfallbackrarr[rDz('bad interpolation variable reference %rz/'%%' must be followed by '%%' or '(', found: %r)getrrrgr4rematchr optionxformgroupendKeyErrorr r])rrQr<accumrestr*mapdepthr?pcmZvarvr r r!r]sT             z$BasicInterpolation._interpolate_someN r&r'r(recompilererSrUr]r r r r!rxs rc@rX) rz \$\{([^}]+)\}c CrYrZr\r^r r r!rSr_z ExtendedInterpolation.before_getcCr`)Nz$$r$rbrcrhr r r!rUriz ExtendedInterpolation.before_setc Cs|j||d|d}|tkr&t||||r|d} | dkrL||dS| dkrr||d| || d}|dd} | dkr|d|dd}q&| dkr|j|} | durt||d|| d d } || d}|} |}zrt | dkr| | d}||}nHt | dkrR| d} | | d}|j| |dd }nt||d |fWn0t ttfyt|||d | dYn0d|vr|||||| t|j| dd |dn||q&t||d |fq&dS) NTrjrrr[rDZ{rm:)rkzMore than one ':' found: %rz-'$' must be followed by '$' or '{', found: %r)rnrrrgr4reror rqZsplitrrlenrprsrrr r8r]dictitems)rrQr<rtrur*rvrwr?rxryrzZpathZsectZoptr{r r r!r]sn           z'ExtendedInterpolation._interpolate_someNr|r r r r!rs rc@s2eZdZedZddZddZeddZ dS) rz%\(([^)]*)\)s|.c Cs|}t}|r|d8}|rd|vrtj|j|d}|j||}z ||}Wn:ty} z"t|||| jddWYd} ~ n d} ~ 00q|rd|vrt ||||S)Nr[z%()rQr) r functoolspartial_interpolation_replacererfrsr r+r) rrQr*r<rLvarsr?rwrder r r!rSs*    zLegacyInterpolation.before_getcCrPrr rTr r r!rU$r%zLegacyInterpolation.before_setcCs(|d}|dur|Sd||S)Nr[z%%(%s)s)rqrp)rorQZsr r r!r's z*LegacyInterpolation._interpolation_replaceN) r&r'r(r}r~rerSrUZ staticmethodrr r r r!r s  rc s2eZdZdZdZdZeZe eej Z e ej ddej Z e ej ddej Ze dZddddddddd Zd edfd d d ddeeed ddZddZddZddZddZddZdcddZddddZdedd Zdfd"d#Zdgd$d%Zdd ed&d'd(Zd)d*Z dd ed&d+d,Z!dd ed&d-d.Z"dd ed&d/d0Z#dd ed&d1d2Z$edd ffd3d4 Z%d5d6Z&d7d8Z'd9d:Z(dhd;d<Z)did=d>Z*d?d@Z+dAdBZ,dCdDZ-dEdFZ.dGdHZ/dIdJZ0dKdLZ1dMdNZ2dOdPZ3dQdRZ4dSdTZ5dUdVZ6dWdXZ7dYdZZ8d[d\Z9d]d]d]d^d_d`Z:e;dadbZ<Z=S)jrz \[ # [ (?P
[^]]+) # very permissive! \] # ] a (?P