a DOgF)@sgdZddlZdZdZdZeeZdZeddZd Zd Z eee eZ dd d Z ddl Z dd lmZiZGdddZeGdddZdS)) ascii_lettersascii_lowercaseascii_uppercasecapwordsdigits hexdigits octdigits printable punctuation whitespace FormatterTemplateNz abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789ZabcdefZABCDEF01234567z !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~cCs|pddd||DS)N css|]}|VqdSN) capitalize).0xr/usr/lib64/python3.9/string.py 0zcapwords..)joinsplit)sseprrrr%s r)ChainMapcsVeZdZdZdZdZejZfddZ ddZ dd Z e fd d Z e fd d ZZS)r $z(?a:[_a-z][_a-z0-9]*)Nc srtd|jvr|j}nzC) | # Escape sequence of two delimiters (?PzJ) | # delimiter and a Python identifier {(?Pz)} | # delimiter and a braced identifier (?P) # Other ill-formed delimiter exprs ) ) super__init_subclass____dict__r!_reescape delimiter idpatternbraceidpatterncompileflagsVERBOSE)clsr!delimidbid __class__rrr#Es     zTemplate.__init_subclass__cCs ||_dSr)template)selfr3rrr__init__WszTemplate.__init__cCsd|d}|jd|jdd}|s.d}d}n"|td|dd}t|}td||fdS)NinvalidT)keependsz.Invalid placeholder in string: line %d, col %d)startr3 splitlineslenr ValueError)r4moilinescolnolinenorrr_invalid\s zTemplate._invalidc s:tur|n|rt|fdd}j|jS)Ncsd|dp|d}|dur(t|S|ddur<jS|ddurT|tdjdSNnamedbracedescapedr6z#Unrecognized named group in pattern)groupstrr'rDr>r!r?rFmappingr4rrconvertns  z$Template.substitute..convert_sentinel_dict _ChainMapr!subr3r4rMkwsrNrrLr substitutehs   zTemplate.substitutec s:tur|n|rt|fdd}j|jS)Ncs|dp|d}|durFzt|WStyD|YS0|ddurZjS|ddurp|StdjdSrE)rIrJKeyErrorr'r>r!rKrLrrrNs z)Template.safe_substitute..convertrOrSrrLrsafe_substitute{s   zTemplate.safe_substitute)__name__ __module__ __qualname__r'r(r)r% IGNORECASEr+r#r5rDrPrUrW __classcell__rrr1rr 9s  r c@sVeZdZddZddZdddZdd Zd d Zd d ZddZ ddZ ddZ dS)r cOs||||Sr)vformat)r4 format_stringargskwargsrrrformatszFormatter.formatcCs.t}|||||d\}}|||||S)N)set_vformatcheck_unused_args)r4r^r_r` used_argsresult_rrrr]szFormatter.vformatr c Cs|dkrtdg}||D]\}} } } |r8||| dur| dkrj|durXtdt|} |d7}n| r|r~tdd}|| ||\} } || || | } |j| ||||d|d\} }|| | | qd ||fS)Nr zMax string recursion exceededr9FzJcannot switch from manual field specification to automatic field numberingr8)auto_arg_index) r>parseappendrJisdigit get_fieldadd convert_fieldrd format_fieldr)r4r^r_r`rfrecursion_depthrirg literal_text field_name format_spec conversionobjarg_usedrrrrds6     zFormatter._vformatcCst|tr||S||SdSr) isinstanceint)r4keyr_r`rrr get_values zFormatter.get_valuecCsdSrr)r4rfr_r`rrrreszFormatter.check_unused_argscCs t||Sr)ra)r4valuertrrrrpszFormatter.format_fieldcCsN|dur |S|dkrt|S|dkr,t|S|dkrra)r4r|rurrrroszFormatter.convert_fieldcCs t|Sr)_stringformatter_parser)r4r^rrrrjszFormatter.parsec CsJt|\}}||||}|D] \}}|r8t||}q ||}q ||fSr)rformatter_field_name_splitr{getattr) r4rsr_r`firstrestrvis_attrr@rrrrm s   zFormatter.get_fieldN)r ) rXrYrZrar]rdr{rerprorjrmrrrrr s 6 r )N)__all__rr rrrrrrr rrrer% collectionsrrQrPr r#r rrrrs"   Y