3 \. @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|pdjdd|j|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|]}|jVqdS)N) capitalize).0xr/usr/lib64/python3.6/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%(id)s)} | # delimiter and a braced identifier (?P) # Other ill-formed delimiter exprs ) csXtt|j|||d|kr$|j}ntjtj|j|jd}tj||j tj B|_dS)Npattern)Zdelimid) superr__init__r_reescape delimiter idpatterncompileflagsVERBOSE)clsnamebasesZdctr) __class__rrrAs  z_TemplateMetaclass.__init__)__name__ __module__ __qualname__rr __classcell__rr)r*rr7src@s>eZdZdZdZdZejZddZ ddZ dd Z d d Z d S) r z.A string class for supporting $-substitutions.$z(?-i:[_a-zA-Z][_a-zA-Z0-9]*)cCs ||_dS)N)template)selfr0rrrrXszTemplate.__init__cCsd|jd}|jd|jdd}|s.d}d}n"|tdj|dd}t|}td||fdS)NinvalidT)keependsz.Invalid placeholder in string: line %d, col %d)startr0 splitlineslenr ValueError)r1moilinescolnolinenorrr_invalid]s zTemplate._invalidcsl|s td|^}t|dkr(td|s2|n|rFt||dn|dfdd}jj|jS)Nz>descriptor 'substitute' of 'Template' object needs an argumentr4zToo many positional argumentsr csd|jdp|jd}|dk r(t|S|jddk r<jS|jddk rTj|tdjdS)Nnamedbracedescapedr2z#Unrecognized named group in pattern)groupstrr"r@r:r)r;rA)mappingr1rrconvertws  z$Template.substitute..convert) TypeErrorr9 _ChainMaprsubr0)argskwsrGr)rFr1r substituteis  zTemplate.substitutecsl|s td|^}t|dkr(td|s2|n|rFt||dn|dfdd}jj|jS)NzCdescriptor 'safe_substitute' of 'Template' object needs an argumentr4zToo many positional argumentsr c s||jdp|jd}|dk rBy t|Stk r@|jSX|jddk rVjS|jddk rl|jStdjdS)NrArBrCr2z#Unrecognized named group in pattern)rDrEKeyErrorr"r:r)r;rA)rFr1rrrGs  z)Template.safe_substitute..convert)rHr9rIrrJr0)rKrLrGr)rFr1rsafe_substitutes  zTemplate.safe_substituteN) r+r,r-__doc__r"r#r IGNORECASEr%rr@rMrOrrrrr Ms ) metaclassc@sVeZdZddZddZdddZdd Zd d Zd d ZddZ ddZ ddZ dS)r c Osz|s td|^}}y |^}}WnJtk rjd|kr\|jd}ddl}|jdtddn tddYnX|j|||S)Nz;descriptor 'format' of 'Formatter' object needs an argument format_stringr z9Passing 'format_string' as keyword argument is deprecated) stacklevelz@format() missing 1 required positional argument: 'format_string')rHr:popwarningswarnDeprecationWarningvformat)rKkwargsr1rSrWrrrformats    zFormatter.formatcCs.t}|j||||d\}}|j||||S)NrT)set_vformatcheck_unused_args)r1rSrKr[ used_argsresult_rrrrZszFormatter.vformatr c Cs|dkrtdg}x|j|D]\}} } } |r:|j|| dk r | dkrl|dkrZtdt|} |d7}n| jr|rtdd}|j| ||\} } |j| |j| | } |j| ||||d|d\} }|j|j | | q Wdj ||fS)Nr zMax string recursion exceededr5FzJcannot switch from manual field specification to automatic field numberingr4)auto_arg_index) r:parseappendrEisdigit get_fieldadd convert_fieldr^ format_fieldr)r1rSrKr[r`Zrecursion_depthrcraZ literal_text field_name format_spec conversionobjZarg_usedrrrr^s4     zFormatter._vformatcCst|tr||S||SdS)N) isinstanceint)r1keyrKr[rrr get_values zFormatter.get_valuecCsdS)Nr)r1r`rKr[rrrr_szFormatter.check_unused_argscCs t||S)N)r\)r1valuerlrrrrjszFormatter.format_fieldcCsN|dkr |S|dkrt|S|dkr,t|S|dkrs&     `