B Y6d,- @sdZddddddddd d d d g Zd dlZdZdZdZeeZdZeddZdZ dZ eee eZ dddZ d dl Zd dlmZGdddeZGdd d edZGdd d ZdS)anA collection of string constants. Public module variables: whitespace -- a string containing all ASCII whitespace ascii_lowercase -- a string containing all ASCII lowercase letters ascii_uppercase -- a string containing all ASCII uppercase letters ascii_letters -- a string containing all ASCII letters digits -- a string containing all ASCII decimal digits hexdigits -- a string containing all ASCII hexadecimal digits octdigits -- a string containing all ASCII octal digits punctuation -- a string containing all ASCII punctuation characters printable -- a string containing all ASCII characters considered printable ascii_lettersascii_lowercaseascii_uppercasecapwordsdigits hexdigits octdigits printable punctuation whitespace FormatterTemplateNz ZabcdefghijklmnopqrstuvwxyzZABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789ZabcdefZABCDEFZ01234567z !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~cCs|pddd||DS)acapwords(s [,sep]) -> string Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using join. If the optional second argument sep is absent or None, runs of whitespace characters are replaced by a single space and leading and trailing whitespace are removed, otherwise sep is used to split and join the words.  css|]}|VqdS)N) capitalize).0xr"/usr/local/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)clsnamebasesdctr) __class__rrrAs z_TemplateMetaclass.__init__)__name__ __module__ __qualname__rr __classcell__rr)r,rr7src@sBeZdZdZdZdZdZejZ ddZ ddZ d d Z d d Z dS) r z.A string class for supporting $-substitutions.$z(?a:[_a-z][_a-z0-9]*)NcCs ||_dS)N)template)selfr2rrrrZszTemplate.__init__cCsd|d}|jd|jdd}|s.d}d}n"|td|dd}t|}td||fdS)NinvalidT)keependsz.Invalid placeholder in string: line %d, col %d)startr2 splitlineslenr ValueError)r3moilinescolnolinenorrr_invalid_s zTemplate._invalidcsl|s td|^}t|dkr(td|s2|n|rFt||dn|dfdd}j|jS)Nz>descriptor 'substitute' of 'Template' object needs an argumentr6zToo many positional argumentsr csd|dp|d}|dk r(t|S|ddk r<jS|ddk rT|tdjdS)Nnamedbracedescapedr4z#Unrecognized named group in pattern)groupstrr"rBr<r)r=rC)mappingr3rrconvertys  z$Template.substitute..convert) TypeErrorr; _ChainMaprsubr2)argskwsrIr)rHr3r substituteks  zTemplate.substitutecsl|s td|^}t|dkr(td|s2|n|rFt||dn|dfdd}j|jS)NzCdescriptor 'safe_substitute' of 'Template' object needs an argumentr6zToo many positional argumentsr cs||dp|d}|dk rBy t|Stk r@|SX|ddk rVjS|ddk rl|StdjdS)NrCrDrEr4z#Unrecognized named group in pattern)rFrGKeyErrorr"r<r)r=rC)rHr3rrrIs  z)Template.safe_substitute..convert)rJr;rKrrLr2)rMrNrIr)rHr3rsafe_substitutes  zTemplate.safe_substitute)r-r.r/__doc__r"r#r$r IGNORECASEr&rrBrOrQrrrrr 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')rJr<vformat)rMkwargsr3 format_stringrrrformats  zFormatter.formatcCs.t}|||||d\}}|||||S)N)set_vformatcheck_unused_args)r3rWrMrV used_argsresult_rrrrUszFormatter.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 exceededr7FzJcannot switch from manual field specification to automatic field numberingr6)auto_arg_index) r<parseappendrGisdigit get_fieldadd convert_fieldr[ format_fieldr)r3rWrMrVr]Zrecursion_depthr`r^Z literal_text field_name format_spec conversionobjZarg_usedrrrr[s4     zFormatter._vformatcCst|tr||S||SdS)N) isinstanceint)r3keyrMrVrrr get_values zFormatter.get_valuecCsdS)Nr)r3r]rMrVrrrr\szFormatter.check_unused_argscCs t||S)N)rX)r3valuerirrrrgszFormatter.format_fieldcCsN|dkr |S|dkrt|S|dkr,t|S|dkrrrrrd$s  zFormatter.get_fieldN)r ) r-r.r/rXrUr[ror\rgrfrardrrrrr s  5 )N)rR__all__rur rrrrrrr rrrer collectionsrrKtyperr r rrrrs&     a