i f,@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+/opt/alt/python34/lib64/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._invalidcs|stdn|^}t|dkrBtdn|sQ|n&|rmt||dn |dfdd}jj|jS)Nz>descriptor 'substitute' of 'Template' object needs an argumentr)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&rrconvertos   z$Template.substitute..convert) TypeErrorr.rrsubr%)argskwsr;r)r:r&r substituteas   zTemplate.substitutecs|stdn|^}t|dkrBtdn|sQ|n&|rmt||dn |dfdd}jj|jS)NzCdescriptor 'safe_substitute' of 'Template' object needs an argumentr)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&rsafe_substitutes   zTemplate.safe_substituteN) r r!r"__doc__rrr IGNORECASErrr4r@rBrrrrr#Is    r# metaclassc@seZdZddZddZdddZdd Zd d Zd d ZddZ ddZ ddZ dS) Formatterc Os|stdn|^}}y|^}}Wn?tk rrd|kr_|jd}ntddYnX|j|||S)Nz;descriptor 'format' of 'Formatter' object needs an argument format_stringz@format() missing 1 required positional argument: 'format_string')r<r/popvformat)r>kwargsr&rGrrrformats     zFormatter.formatcCsAt}|j||||d\}}|j||||S)N)set_vformatcheck_unused_args)r&rGr>rJ used_argsresult_rrrrIs !zFormatter.vformatrc Csg|dkrtdng}x0|j|D]\}} } } |rY|j|n| dk r1| dkr|dkrtdnt|} |d7}n*| jr|rtdnd}n|j| ||\} } |j| |j| | } |j| ||||dd|\} }|j|j | | q1q1Wdj ||fS)NrzMax string recursion exceededr*FzJcannot switch from manual field specification to automatic field numberingr)auto_arg_index) r/parseappendstrisdigit get_fieldadd convert_fieldrN format_fieldr )r&rGr>rJrPZrecursion_depthrSrQZ literal_text field_name format_spec conversionobjZarg_usedrrrrNs4            zFormatter._vformatcCs#t|tr||S||SdS)N) isinstanceint)r&keyr>rJrrr get_valueszFormatter.get_valuecCsdS)Nr)r&rPr>rJrrrrOszFormatter.check_unused_argscCs t||S)N)rK)r&valuer]rrrr[szFormatter.format_fieldcCsk|dkr|S|dkr&t|S|dkr<t|S|dkrRt|Stdj|dS)Nr raz"Unknown conversion specifier {0!s})rVreprasciir/rK)r&rdr^rrrrZs       zFormatter.convert_fieldcCs tj|S)N)_stringZformatter_parser)r&rGrrrrTszFormatter.parsec Csmtj|\}}|j|||}x6|D].\}}|rUt||}q1||}q1W||fS)N)riZformatter_field_name_splitrcgetattr) r&r\r>rJfirstrestr_Zis_attrr1rrrrX"szFormatter.get_fieldN) r r!r"rKrIrNrcrOr[rZrTrXrrrrrFs   5     rF)rCriZ whitespaceZascii_lowercaseZascii_uppercaseZ ascii_lettersZdigitsZ hexdigitsZ octdigitsZ punctuationZ printablerrer collectionsrtyperr#rFrrrrs    a