[(@sdZddlZdZdZdZeeZdZeddZd Zd Z eee eZ dd d Z ddl Z dd lmZGdddeZGddddeZGdddZdS)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 Nz ZabcdefghijklmnopqrstuvwxyzZABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789ZabcdefZABCDEFZ01234567z !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~cCs)|p djdd|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/lib/python3.4/string.py ,szcapwords..)joinsplit)sseprrrcapwords!s r)ChainMapcs(eZdZdZfddZS)_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 ) cstt|j|||d|kr4|j}n*tjitj|jd6|jd6}tj||j tj B|_dS)NpatternZdelimid) superr__init__r_reescape delimiter idpatterncompileflagsVERBOSE)clsnamebasesZdctr) __class__rrr=s   z_TemplateMetaclass.__init__)__name__ __module__ __qualname__rrrr)rrr3s rc@s[eZdZdZdZdZejZddZ ddZ dd Z d d Z d S) Templatez.A string class for supporting $-substitutions.$z[_a-z][_a-z0-9]*cCs ||_dS)N)template)selfr%rrrrPszTemplate.__init__cCs|jd}|jd|jdd}|sCd}d}n/|tdj|dd}t|}td||fdS)NinvalidkeependsTz.Invalid placeholder in string: line %d, col %d)startr% splitlineslenr ValueError)r&moilinesZcolnolinenorrr_invalidUs # zTemplate._invalidcst|dkr!tdn|s0|n&|rLt||dn |dfdd}jj|jS)Nr)zToo many positional argumentsrcs|jdp|jd}|dk r?|}d|fS|jddk r[jS|jddk rj|ntdjdS)Nnamedbracedz%sescapedr'z#Unrecognized named group in pattern)grouprr4r/r)r0r5val)mappingr&rrconvertks   z$Template.substitute..convert)r. TypeErrorrrsubr%)r&argskwsr;r)r:r&r substituteas  zTemplate.substitutecst|dkr!tdn|s0|n&|rLt||dn |dfdd}jj|jS)Nr)zToo many positional argumentsrc s|jdp|jd}|dk r_yd|fSWq_tk r[|jSYq_Xn|jddk r{jS|jddk r|jStdjdS)Nr5r6z%sr7r'z#Unrecognized named group in pattern)r8KeyErrorrr/r)r0r5)r:r&rrr;s   z)Template.safe_substitute..convert)r.r<rrr=r%)r&r>r?r;r)r:r&rsafe_substitute{s  zTemplate.safe_substituteN) r r!r"__doc__rrr IGNORECASErrr4r@rBrrrrr#Is    r# metaclassc@seZdZddZddZdddZdd Zd d Zd d ZddZ ddZ ddZ dS) FormattercOs|j|||S)N)vformat)r& format_stringr>kwargsrrrformatszFormatter.formatcCs;t}|j||||d}|j||||S)N)set_vformatcheck_unused_args)r&rHr>rI used_argsresultrrrrGs zFormatter.vformatrc Cs[|dkrtdng}x*|j|D]\}} } } |rY|j|n| dk r1| dkr|dkrtdnt|} |d7}n*| jr|rtdnd}n|j| ||\} } |j| |j| | } |j| ||||dd|} |j|j | | q1q1Wdj |S)NrzMax string recursion exceededr*FzJcannot switch from manual field specification to automatic field numberingr)auto_arg_index) r/parseappendstrisdigit get_fieldadd convert_fieldrM format_fieldr )r&rHr>rIrOZrecursion_depthrQrPZ literal_text field_name format_spec conversionobjZarg_usedrrrrMs2            zFormatter._vformatcCs#t|tr||S||SdS)N) isinstanceint)r&keyr>rIrrr get_valueszFormatter.get_valuecCsdS)Nr)r&rOr>rIrrrrNszFormatter.check_unused_argscCs t||S)N)rJ)r&valuer[rrrrYszFormatter.format_fieldcCsk|dkr|S|dkr&t|S|dkr<t|S|dkrRt|Stdj|dS)Nr raz"Unknown conversion specifier {0!s})rTreprasciir/rJ)r&rbr\rrrrXs       zFormatter.convert_fieldcCs tj|S)N)_stringZformatter_parser)r&rHrrrrRszFormatter.parsec Csmtj|\}}|j|||}x6|D].\}}|rUt||}q1||}q1W||fS)N)rgZformatter_field_name_splitragetattr) r&rZr>rIfirstrestr]Zis_attrr1rrrrV szFormatter.get_fieldN) r r!r"rJrGrMrarNrYrXrRrVrrrrrFs   4     rF)rCrgZ whitespaceZascii_lowercaseZascii_uppercaseZ ascii_lettersZdigitsZ hexdigitsZ octdigitsZ punctuationZ printablerrer collectionsrtyperr#rFrrrrs    Y