3 \X@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||_tj||dS)N)message Exception__init__)selfmsgr"$/usr/lib64/python3.6/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$tj|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|jdj||jd|j||}n |jddtj|dj|||_||_ ||_ |||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@|jdj||jd|j||}n |jddtj|dj|||_||_ ||_ ||_ ||||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.tj|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(tj||||_||_|||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 cCs8dj||||}tj||||||_||||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 cCs0dj||t|}tj|||||||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 NcCsX|r|rtdn| r(| r(tdn|r0|}tj|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*|jj||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)rcCs8tj|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.eZdZejdZddZddZddZdS) rz %\(([^)]+)\)scCs$g}|j||||||ddj|S)Nr)_interpolate_somer0)r rBr)r3r>rCLr"r"r#rDszBasicInterpolation.before_getcCs<|jdd}|jjd|}d|kr8td||jdf|S)Nz%%r%z1invalid interpolation syntax in %r at position %d)replace_KEYCREsubr6find)r rBr)r3r> tmp_valuer"r"r#rEs  zBasicInterpolation.before_setcCsp|j||d|d}|tkr&t|||xB|rj|jd} | dkrP|j|dS| dkrv|j|d| || d}|dd} | dkr|jd|dd}q*| dkrV|jj|} | dkrt||d||j| j d} || j d}y || } Wn&t k r"t |||| dYnXd| krJ|j |||| |||dn |j| 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.eZdZejdZddZddZddZdS) rz \$\{([^}]+)\}cCs$g}|j||||||ddj|S)NrHr)rIr0)r rBr)r3r>rCrJr"r"r#rDsz ExtendedInterpolation.before_getcCs<|jdd}|jjd|}d|kr8td||jdf|S)Nz$$r$z1invalid interpolation syntax in %r at position %d)rLrMrNr6rO)r rBr)r3r>rPr"r"r#rEs  z ExtendedInterpolation.before_setcCs|j||d|d}|tkr&t|||x|r|jd} | dkrP|j|dS| dkrv|j|d| || d}|dd} | dkr|jd|dd}q*| dkr|jj|} | dkrt||d|| jdj d } || j d}|} |}yrt | dkr |j | d}||}nHt | dkrV| d} |j | d}|j| |dd }nt||d |fWn2t ttfk rt|||d j| dYnXd|kr|j||||| t|j| dd |dn |j|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@s2eZdZejdZddZddZeddZ dS) rz%\(([^)]*)\)s|.c Cs|}t}x|r|d8}|rd|krtj|j|d}|jj||}y ||}Wqtk r} zt|||| jddWYdd} ~ XqXq 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,|jd}|dkr|jSd|j|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 s*eZdZdZdZdZeZej eej Z ej ej ddej Z ej ej ddej Zej dZddddddddd Zd edfdcddd ddeeedddZddZddZddZddZddZdeddZdfddZdgd!d"Zdhd$d%Zdid&d'Zdd ed(d)d*Zd+d,Z dd ed(d-d.Z!dd ed(d/d0Z"dd ed(d1d2Z#dd ed(d3d4Z$edd ffd5d6 Z%d7d8Z&d9d:Z'd;d<Z(djd=d>Z)dkd?d@Z*dAdBZ+dCdDZ,dEdFZ-dGdHZ.dIdJZ/dKdLZ0dMdNZ1dOdPZ2dQdRZ3dSdTZ4dUdVZ5dWdXZ6dYdZZ7d[d\Z8d]d]d]d^d_d`Z9e:dadbZ;Z[^]]+) # very permissive! \] # ] a (?P