B J.J ~@sddlmZddlmZmZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z dddddd d d d d dddddddddddgZdZdZGdddeZGdddeZGdddeZGdddeZGd ddeZGd!ddeZGd"d d eZGd#d d eZGd$d d eZGd%d d eZGd&d d eZeZGd'ddZGd(ddeZ Gd)ddeZ!Gd*ddeZ"Gd+ddeZ#Gd,dde#Z$Gd-dde$Z%Gd.ddeZ&Gd/ddeZ'dS)0)MutableMapping) OrderedDictChainMapNNoSectionErrorDuplicateOptionErrorDuplicateSectionError NoOptionErrorInterpolationErrorInterpolationDepthErrorInterpolationMissingOptionErrorInterpolationSyntaxError ParsingErrorMissingSectionHeaderError ConfigParserSafeConfigParserRawConfigParser InterpolationBasicInterpolationExtendedInterpolationLegacyInterpolation SectionProxyConverterMapping DEFAULTSECTMAX_INTERPOLATION_DEPTHZDEFAULT c@s"eZdZdddZddZeZdS)ErrorcCs||_t||dS)N)message Exception__init__)selfmsgr"//opt/alt/python37/lib/python3.7/configparser.pyrszError.__init__cCs|jS)N)r)r 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)rrsectionargs)r r)r"r"r#rszNoSectionError.__init__N)r%r&r'rr"r"r"r#rsc@seZdZdddZdS)rNcCst|dg}|dk rRdt|g}|dk r8|d||d|||}n |ddt|d|||_||_ ||_ |||f|_ dS)Nz already existszWhile reading from z [line {0:2d}]z : section rzSection r) reprappendformatextendinsertrrjoinr)sourcelinenor*)r r)r1r2r!rr"r"r#rs     zDuplicateSectionError.__init__)NN)r%r&r'rr"r"r"r#rsc@seZdZdddZdS)rNcCst|dt|dg}|dk rZdt|g}|dk r@|d||d|||}n |ddt|d|||_||_ ||_ ||_ ||||f|_ dS) Nz in section z already existszWhile reading from z [line {0:2d}]z : option rzOption r) r+r,r-r.r/rrr0r)optionr1r2r*)r r)r3r1r2r!rr"r"r#rs     zDuplicateOptionError.__init__)NN)r%r&r'rr"r"r"r#rsc@seZdZddZdS)rcCs.t|d||f||_||_||f|_dS)NzNo option %r in section: %r)rrr3r)r*)r r3r)r"r"r#rs  zNoOptionError.__init__N)r%r&r'rr"r"r"r#rsc@seZdZddZdS)r cCs(t||||_||_|||f|_dS)N)rrr3r)r*)r r3r)r!r"r"r#rs zInterpolationError.__init__N)r%r&r'rr"r"r"r#r sc@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})r-r r referencer*)r r3r)rawvalr4r!r"r"r#r s  z(InterpolationMissingOptionError.__init__N)r%r&r'rr"r"r"r#r sc@s eZdZdS)r N)r%r&r'r"r"r"r#r sc@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})r-rr rr*)r r3r)r5r!r"r"r#rs z InterpolationDepthError.__init__N)r%r&r'rr"r"r"r#r sc@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) ValueErrorrrr1errorsr*)r r1filenamer"r"r#r+s  zParsingError.__init__cCstjdtdd|jS)NzSThe 'filename' attribute will be removed in future versions. Use 'source' instead.) stacklevel)warningswarnDeprecationWarningr1)r r"r"r#r8:s zParsingError.filenamecCstjdtdd||_dS)NzSThe 'filename' attribute will be removed in future versions. Use 'source' instead.r9)r:)r;r<r=r1)r valuer"r"r#r8Ds cCs*|j||f|jd||f7_dS)Nz [line %2d]: %s)r7r,r)r r2liner"r"r#r,NszParsingError.append)NN)r%r&r'rpropertyr8setterr,r"r"r"r#r (s   c@seZdZddZdS)rcCs8t|d|||f||_||_||_|||f|_dS)Nz7File contains no section headers. file: %r, line: %d %r)rrr1r2r?r*)r r8r2r?r"r"r#rVsz"MissingSectionHeaderError.__init__N)r%r&r'rr"r"r"r#rSsc@s,eZdZddZddZddZddZd S) rcCs|S)Nr")r parserr)r3r>defaultsr"r"r# before_getjszInterpolation.before_getcCs|S)Nr")r rBr)r3r>r"r"r# before_setmszInterpolation.before_setcCs|S)Nr")r rBr)r3r>r"r"r# before_readpszInterpolation.before_readcCs|S)Nr")r rBr)r3r>r"r"r# before_writesszInterpolation.before_writeN)r%r&r'rDrErFrGr"r"r"r#rgsc@s.eZdZedZddZddZddZdS) rz %\(([^)]+)\)sc Cs$g}|||||||dd|S)Nr)_interpolate_somer0)r rBr)r3r>rCLr"r"r#rDszBasicInterpolation.before_getcCs<|dd}|jd|}d|kr8td||df|S)Nz%%r%z1invalid interpolation syntax in %r at position %d)replace_KEYCREsubr6find)r rBr)r3r> tmp_valuer"r"r#rEs  zBasicInterpolation.before_setc Csp|j||d|d}|tkr&t|||xB|rj|d} | dkrP||dS| dkrv||d| || d}|dd} | dkr|d|dd}q*| dkrV|j|} | dkrt||d||| d} || d}y || } Wn&t k r"t |||| dYnXd| krJ| |||| |||dn || q*t||d |fq*WdS) NT)rawfallbackrKrrHr9(z'bad interpolation variable reference %rz/'%%' must be followed by '%%' or '(', found: %r)getrr rOr,rMmatchr optionxformgroupendKeyErrorr rI)r rBr3accumrestr)mapdepthr5pcmvarvr"r"r#rIsF              z$BasicInterpolation._interpolate_someN) r%r&r'recompilerMrDrErIr"r"r"r#rws c@s.eZdZedZddZddZddZdS) rz \$\{([^}]+)\}c Cs$g}|||||||dd|S)NrHr)rIr0)r rBr)r3r>rCrJr"r"r#rDsz ExtendedInterpolation.before_getcCs<|dd}|jd|}d|kr8td||df|S)Nz$$r$z1invalid interpolation syntax in %r at position %d)rLrMrNr6rO)r rBr)r3r>rPr"r"r#rEs  z ExtendedInterpolation.before_setc Cs|j||d|d}|tkr&t|||x|r|d} | dkrP||dS| dkrv||d| || d}|dd} | dkr|d|dd}q*| dkr|j|} | dkrt||d|| d d } || d}|} |}yrt | dkr | | d}||}nHt | dkrV| d} | | d}|j| |dd }nt||d |fWn2t ttfk rt|||d | dYnXd|kr|||||| t|j| dd |dn ||q*t||d |fq*WdS) NT)rQrRrerrHr9{z'bad interpolation variable reference %r:)rQzMore than one ':' found: %rz-'$' must be followed by '$' or '{', found: %r)rTrr rOr,rMrUr rWsplitrXlenrVrYrrr r0rIdictitems)r rBr3rZr[r)r\r]r5r^r_r`pathZsectoptrbr"r"r#rIs^              z'ExtendedInterpolation._interpolate_someN) r%r&r'rcrdrMrDrErIr"r"r"r#rs c@s2eZdZedZddZddZeddZ dS) rz%\(([^)]*)\)s|.c Cs|}t}x|r|d8}|rd|krtj|j|d}|j||}y ||}Wqtk r} zt|||| jddWdd} ~ XYqXq Pq W|rd|krt ||||S)NrHz%()rBr) r functoolspartial_interpolation_replacerMrNrYr r*r ) r rBr)r3r>varsr5r]rLer"r"r#rDs"  (  zLegacyInterpolation.before_getcCs|S)Nr")r rBr)r3r>r"r"r#rE#szLegacyInterpolation.before_setcCs,|d}|dkr|Sd||SdS)NrHz%%(%s)s)rWrV)rUrBsr"r"r#rp&s z*LegacyInterpolation._interpolation_replaceN) r%r&r'rcrdrMrDrE staticmethodrpr"r"r"r#r s c 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