B d "ە @sdddddddddd d d g Zd d lZdZdZdZeeZdZeddZdZdZ eee eZ dddZ d d l Z d dlmZGdddeZGdd d edZGdd d Zd S) ascii_lettersascii_lowercaseascii_uppercasecapwordsdigits hexdigits octdigits printable punctuation whitespace FormatterTemplateNz ZabcdefghijklmnopqrstuvwxyzZABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789ZabcdefZABCDEFZ01234567z !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~cCs|pddd||DS)N css|]}|VqdS)N) capitalize).0xr)/opt/alt/python37/lib/python3.7/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__rrrAs z_TemplateMetaclass.__init__)__name__ __module__ __qualname__rr __classcell__rr)r+rr7src@s>eZdZdZdZdZejZddZ ddZ dd Z d d Z dS) r $z(?a:[_a-z][_a-z0-9]*)NcCs ||_dS)N)template)selfr1rrrrZszTemplate.__init__cCsd|d}|jd|jdd}|s.d}d}n"|td|dd}t|}td||fdS)NinvalidT)keependsz.Invalid placeholder in string: line %d, col %d)startr1 splitlineslenr ValueError)r2moilinescolnolinenorrr_invalid_s zTemplate._invalidcsl|s td|^}t|dkr(td|s2|n|rFt||dn|dfdd}j|jS)Nz>descriptor 'substitute' of 'Template' object needs an argumentr5zToo many positional argumentsr csd|dp|d}|dk r(t|S|ddk r<jS|ddk rT|tdjdS)Nnamedbracedescapedr3z#Unrecognized named group in pattern)groupstrr"rAr;r)r<rB)mappingr2rrconvertys  z$Template.substitute..convert) TypeErrorr: _ChainMaprsubr1)argskwsrHr)rGr2r substituteks  zTemplate.substitutecsl|s td|^}t|dkr(td|s2|n|rFt||dn|dfdd}j|jS)NzCdescriptor 'safe_substitute' of 'Template' object needs an argumentr5zToo many positional argumentsr cs||dp|d}|dk rBy t|Stk r@|SX|ddk rVjS|ddk rl|StdjdS)NrBrCrDr3z#Unrecognized named group in pattern)rErFKeyErrorr"r;r)r<rB)rGr2rrrHs  z)Template.safe_substitute..convert)rIr:rJrrKr1)rLrMrHr)rGr2rsafe_substitutes  zTemplate.safe_substitute) r,r-r.r"r#r$r IGNORECASEr&rrArNrPrrrrr Ns ) metaclassc@sVeZdZddZddZdddZdd Zd d Zd d ZddZ ddZ ddZ dS)r cOsN|s td|^}}y |^}}Wntk r>tddYnX||||S)Nz;descriptor 'format' of 'Formatter' object needs an argumentz@format() missing 1 required positional argument: 'format_string')rIr;vformat)rLkwargsr2 format_stringrrrformats  zFormatter.formatcCs.t}|||||d\}}|||||S)N)set_vformatcheck_unused_args)r2rUrLrT used_argsresult_rrrrSszFormatter.vformatr c Cs|dkrtdg}x||D]\}} } } |r:||| dk r | dkrl|dkrZtdt|} |d7}n| r|rtdd}|| ||\} } || || | } |j| ||||d|d\} }|| | | q Wd ||fS)Nr zMax string recursion exceededr6FzJcannot switch from manual field specification to automatic field numberingr5)auto_arg_index) r;parseappendrFisdigit get_fieldadd convert_fieldrY format_fieldr)r2rUrLrTr[Zrecursion_depthr^r\Z literal_text field_name format_spec conversionobjZarg_usedrrrrYs4     zFormatter._vformatcCst|tr||S||SdS)N) isinstanceint)r2keyrLrTrrr get_values zFormatter.get_valuecCsdS)Nr)r2r[rLrTrrrrZszFormatter.check_unused_argscCs t||S)N)rV)r2valuergrrrreszFormatter.format_fieldcCsN|dkr |S|dkrt|S|dkr,t|S|dkrs$     a