U e5d') @sdddddddddd d d g Zd d lZdZdZdZeeZdZeddZdZdZ eee eZ dddZ d d l Z d dlmZiZGdddeZGdd d edZGdd d Zd S) ascii_lettersascii_lowercaseascii_uppercasecapwordsdigits hexdigits octdigits printable punctuation whitespace FormatterTemplateNz ZabcdefghijklmnopqrstuvwxyzZABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789ZabcdefZABCDEFZ01234567z !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~cCs|pddd||DS)N css|]}|VqdSN) capitalize).0xr/usr/lib64/python3.8/string.py 0szcapwords..)joinsplit)sseprrrr%s )ChainMapcs eZdZdZfddZZS)_TemplateMetaclassa/ %(delim)s(?: (?P%(delim)s) | # Escape sequence of two delimiters (?P%(id)s) | # delimiter and a Python identifier {(?P%(bid)s)} | # delimiter and a braced identifier (?P) # Other ill-formed delimiter exprs ) csbtt||||d|kr$|j}n$tjt|j|j|jp@|jd}t ||j tj B|_dS)Npattern)ZdelimidZbid) superr__init__r_reescape delimiter idpatternbraceidpatterncompileflagsVERBOSE)clsnamebasesZdctr __class__rrr Cs  z_TemplateMetaclass.__init__)__name__ __module__ __qualname__rr __classcell__rrr,rr9s rc@sFeZdZdZdZdZejZddZ ddZ e fdd Z e fd d Z dS) r $z(?a:[_a-z][_a-z0-9]*)NcCs ||_dSr)template)selfr3rrrr \szTemplate.__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_invalidas zTemplate._invalidc s:tkr|n|rt|fdd}j|jS)Ncsd|dp|d}|dk r(t|S|ddk r<jS|ddk rT|tdjdSNnamedZbracedZescapedr5z#Unrecognized named group in pattern)groupstrr#rCr=rr>rEmappingr4rrconvertss  z$Template.substitute..convert_sentinel_dict _ChainMaprsubr3r4rJZkwsrKrrIr substitutems   zTemplate.substitutec s:tkr|n|rt|fdd}j|jS)Ncs|dp|d}|dk rHzt|WStk rF|YSX|ddk r\jS|ddk rr|StdjdSrD)rFrGKeyErrorr#r=rrHrIrrrKsz)Template.safe_substitute..convertrLrPrrIrsafe_substitutes   zTemplate.safe_substitute)r.r/r0r#r$r%r! IGNORECASEr'r rCrMrQrSrrrrr Ps ) metaclassc@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)r4rWrXrY used_argsresult_rrrrVszFormatter.vformatr c Cs|dkrtdg}||D]\}} } } |r8||| dk r| dkrj|dkrXtdt|} |d7}n| r|r~tdd}|| ||\} } || || | } |j| ||||d|d\} }|| | | qd ||fS)Nr zMax string recursion exceededr8FzJcannot switch from manual field specification to automatic field numberingr7)auto_arg_index) r=parseappendrGisdigit get_fieldadd convert_fieldr] format_fieldr)r4rWrXrYr_Zrecursion_depthrbr`Z literal_text field_name format_spec conversionobjZarg_usedrrrr]s<     zFormatter._vformatcCst|tr||S||SdSr) isinstanceint)r4keyrXrYrrr get_values zFormatter.get_valuecCsdSrr)r4r_rXrYrrrr^szFormatter.check_unused_argscCs t||Sr)rZ)r4valuerkrrrriszFormatter.format_fieldcCsN|dkr |S|dkrt|S|dkr,t|S|dkrs4   Q