f _f@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_DEPTHZDEFAULT c@s"eZdZdddZddZeZdS)ErrorcCs||_t||dSN)message Exception__init__)selfmsgr"%/usr/lib64/python3.10/configparser.pyrszError.__init__cCs|jSr)rr r"r"r#__repr__szError.__repr__N)r)__name__ __module__ __qualname__rr%__str__r"r"r"r#rs rc@seZdZddZdS)rcCs$t|d|f||_|f|_dS)NzNo section: %r)rrsectionargsr r*r"r"r#rszNoSectionError.__init__Nr&r'r(rr"r"r"r#rsrc@seZdZdddZdS)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+)r r*r7r8r!rr"r"r#rs     zDuplicateSectionError.__init__)NNr-r"r"r"r#rsrc@seZdZdddZdS)rNcCst|dt|dg}|durZdt|g}|dur@|d||d|||}n |ddt|d|||_||_ ||_ ||_ ||||f|_ dS) Nz in section r.r/r0z : option rzOption r) r1r2r3r4r5rrr6r*optionr7r8r+)r r*r9r7r8r!rr"r"r#rs"    zDuplicateOptionError.__init__)NNr-r"r"r"r#rsrc@seZdZddZdS)rcCs.t|d||f||_||_||f|_dS)NzNo option %r in section: %rrrr9r*r+)r r9r*r"r"r#rs zNoOptionError.__init__Nr-r"r"r"r#rsrc@seZdZddZdS)rcCs(t||||_||_|||f|_dSrr:)r r9r*r!r"r"r#rs zInterpolationError.__init__Nr-r"r"r"r#rsrc@seZdZddZdS)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})r3rr referencer+)r r9r*rawvalr;r!r"r"r#r s z(InterpolationMissingOptionError.__init__Nr-r"r"r"r#r sr c@s eZdZdS)r N)r&r'r(r"r"r"r#r sr c@seZdZddZdS)r cCs0d||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})r3rrrr+)r r9r*r<r!r"r"r#rs z InterpolationDepthError.__init__Nr-r"r"r"r#r sr c@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) ValueErrorrrr7errorsr+)r r7filenamer"r"r#r,s  zParsingError.__init__cCstjdtdd|jSNzSThe 'filename' attribute will be removed in future versions. Use 'source' instead. stacklevelwarningswarnDeprecationWarningr7r$r"r"r#r?;s zParsingError.filenamecCstjdtdd||_dSr@rDr valuer"r"r#r?Es cCs*|j||f|jd||f7_dS)Nz [line %2d]: %s)r>r2r)r r8liner"r"r#r2OszParsingError.append)NN)r&r'r(rpropertyr?setterr2r"r"r"r#r )s    r c@seZdZddZdS)r cCs8t|d|||f||_||_||_|||f|_dS)Nz7File contains no section headers. file: %r, line: %d %r)rrr7r8rJr+)r r?r8rJr"r"r#rWsz"MissingSectionHeaderError.__init__Nr-r"r"r"r#r Tsr c@s,eZdZddZddZddZddZd S) rcCs|Srr")r parserr*r9rIdefaultsr"r"r# before_getkszInterpolation.before_getcCs|Srr"r rMr*r9rIr"r"r# before_setnszInterpolation.before_setcCs|Srr"rPr"r"r# before_readqszInterpolation.before_readcCs|Srr"rPr"r"r# before_writetszInterpolation.before_writeN)r&r'r(rOrQrRrSr"r"r"r#rhsrc@s.eZdZedZddZddZddZdS) rz %\(([^)]+)\)sc Cs$g}|||||||dd|SNr_interpolate_somer6r rMr*r9rIrNLr"r"r#rOszBasicInterpolation.before_getcCs<|dd}|jd|}d|vr8td||df|S)Nz%%r%1invalid interpolation syntax in %r at position %dreplace_KEYCREsubr=findr rMr*r9rIZ tmp_valuer"r"r#rQs  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) NTrawfallbackrZrrUrA('bad interpolation variable reference %rz/'%%' must be followed by '%%' or '(', found: %r)getrr r`r2r^matchr optionxformgroupendKeyErrorr rW)r rMr9accumrestr*mapdepthr<pcmvarvr"r"r#rWsT             z$BasicInterpolation._interpolate_someN r&r'r(recompiler^rOrQrWr"r"r"r#rxs rc@s.eZdZedZddZddZddZdS) rz \$\{([^}]+)\}c Cs$g}|||||||dd|SrTrVrXr"r"r#rOsz ExtendedInterpolation.before_getcCs<|dd}|jd|}d|vr8td||df|S)Nz$$r$r[r\rar"r"r#rQs  z 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) NTrbryrrUrA{rf:)rczMore than one ':' found: %rz-'$' must be followed by '$' or '{', found: %r)rgrr r`r2r^rhr rjsplitrklenrirlrrr r6rWdictitems)r rMr9rmrnr*rorpr<rqrrrspathZsectoptrur"r"r#rWsn           z'ExtendedInterpolation._interpolate_someNrvr"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)NrUz%()rMr) r functoolspartial_interpolation_replacer^r_rlr r+r ) r rMr*r9rIvarsr<rpr]er"r"r#rOs*    zLegacyInterpolation.before_getcCs|Srr"rPr"r"r#rQ$szLegacyInterpolation.before_setcCs(|d}|dur|Sd||S)NrUz%%(%s)s)rjri)rhrMsr"r"r#r's z*LegacyInterpolation._interpolation_replaceN) r&r'r(rwrxr^rOrQ 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