
„àWN.  ã               @   sû   d  Z  d d d d d d d d d	 d
 d d g Z d d l Z d Z d Z d Z e e Z d Z e d d Z d Z	 d Z
 e e e
 e Z d d d „ Z d d l Z d d l m Z Gd d „  d e ƒ Z Gd d „  d d e ƒZ Gd d „  d ƒ Z d S)an  A 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_lettersÚascii_lowercaseÚascii_uppercaseÚcapwordsÚdigitsÚ	hexdigitsÚ	octdigitsÚ	printableÚpunctuationÚ
whitespaceÚ	FormatterÚTemplateé    Nz 	
ÚabcdefghijklmnopqrstuvwxyzÚABCDEFGHIJKLMNOPQRSTUVWXYZÚ
0123456789ZabcdefZABCDEFÚ01234567z !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~c             C   s)   | p	 d j  d d „  |  j | ƒ Dƒ ƒ S)a‘  capwords(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.

    ú c             s   s   |  ] } | j  ƒ  Vq d  S)N)Ú
capitalize)Ú.0Úx© r   ú;/afs/.cs/s/python-3.5.2/amd64_rhel6/lib/python3.5/string.pyú	<genexpr>0   s    zcapwords.<locals>.<genexpr>)ÚjoinÚsplit)ÚsÚsepr   r   r   r   %   s    )ÚChainMapc                   s(   e  Z d  Z d Z ‡  f d d †  Z ‡  S)Ú_TemplateMetaclassa/  
    %(delim)s(?:
      (?P<escaped>%(delim)s) |   # Escape sequence of two delimiters
      (?P<named>%(id)s)      |   # delimiter and a Python identifier
      {(?P<braced>%(id)s)}   |   # delimiter and a braced identifier
      (?P<invalid>)              # Other ill-formed delimiter exprs
    )
    c                s   t  t |  ƒ j | | | ƒ d | k r4 |  j } n( t j d t j |  j ƒ d |  j i } t j | |  j	 t j
 Bƒ |  _ d  S)NÚpatternÚdelimÚid)Úsuperr   Ú__init__r   Ú_reÚescapeÚ	delimiterÚ	idpatternÚcompileÚflagsÚVERBOSE)ÚclsÚnameÚbasesÚdctr   )Ú	__class__r   r   r#   A   s    z_TemplateMetaclass.__init__)Ú__name__Ú
__module__Ú__qualname__r   r#   r   r   )r/   r   r   7   s   r   c               @   s[   e  Z d  Z d Z d Z d Z e j Z d d „  Z	 d d „  Z
 d d	 „  Z d
 d „  Z d S)r   z.A string class for supporting $-substitutions.ú$z[_a-z][_a-z0-9]*c             C   s   | |  _  d  S)N)Útemplate)Úselfr4   r   r   r   r#   T   s    zTemplate.__init__c             C   sŒ   | j  d ƒ } |  j d  | … j d d ƒ } | sC d } d } n/ | t d j | d  d … ƒ ƒ } t | ƒ } t d | | f ƒ ‚ d  S)NÚinvalidÚkeependsTé   Ú z.Invalid placeholder in string: line %d, col %déÿÿÿÿ)Ústartr4   Ú
splitlinesÚlenr   Ú
ValueError)r5   ÚmoÚiÚlinesÚcolnoÚlinenor   r   r   Ú_invalidY   s    	#zTemplate._invalidc                 sœ   |  s t  d ƒ ‚ |  ^ ‰ }  t |  ƒ d k r< t  d ƒ ‚ |  sK | ‰  n& | rg t | |  d ƒ ‰  n
 |  d ‰  ‡  ‡ f d d †  } ˆ j j | ˆ j ƒ S)Nz>descriptor 'substitute' of 'Template' object needs an argumentr8   zToo many positional argumentsr   c                s“   |  j  d ƒ p |  j  d ƒ } | d  k	 r? ˆ  | } d | f S|  j  d ƒ d  k	 r[ ˆ j S|  j  d ƒ d  k	 r} ˆ j |  ƒ t d ˆ j ƒ ‚ d  S)NÚnamedÚbracedz%sÚescapedr6   z#Unrecognized named group in pattern)Úgroupr&   rD   r>   r   )r?   rE   Úval)Úmappingr5   r   r   Úconverts   s    
z$Template.substitute.<locals>.convert)Ú	TypeErrorr=   Ú	_ChainMapr   Úsubr4   )ÚargsÚkwsrK   r   )rJ   r5   r   Ú
substitutee   s    	
zTemplate.substitutec                 sœ   |  s t  d ƒ ‚ |  ^ ‰ }  t |  ƒ d k r< t  d ƒ ‚ |  sK | ‰  n& | rg t | |  d ƒ ‰  n
 |  d ‰  ‡  ‡ f d d †  } ˆ j j | ˆ j ƒ S)NzCdescriptor 'safe_substitute' of 'Template' object needs an argumentr8   zToo many positional argumentsr   c                s­   |  j  d ƒ p |  j  d ƒ } | d  k	 r\ y d ˆ  | f SWn t k
 r[ |  j  ƒ  SYn X|  j  d ƒ d  k	 rx ˆ j S|  j  d ƒ d  k	 r— |  j  ƒ  St d ˆ j ƒ ‚ d  S)NrE   rF   z%srG   r6   z#Unrecognized named group in pattern)rH   ÚKeyErrorr&   r>   r   )r?   rE   )rJ   r5   r   r   rK   ‘   s    
z)Template.safe_substitute.<locals>.convert)rL   r=   rM   r   rN   r4   )rO   rP   rK   r   )rJ   r5   r   Úsafe_substituteƒ   s    	
zTemplate.safe_substituteN)r0   r1   r2   Ú__doc__r&   r'   r$   Ú
IGNORECASEr)   r#   rD   rQ   rS   r   r   r   r   r   M   s   	Ú	metaclassc               @   s   e  Z d  Z d d „  Z d d „  Z d d d „ Z d d	 „  Z d
 d „  Z d d „  Z d d „  Z	 d d „  Z
 d d „  Z d S)r   c              O   s¥   |  s t  d ƒ ‚ |  ^ } }  y |  ^ } }  Wna t k
 r‘ d | k r~ | j d ƒ } d d  l } | j d t d d ƒn t  d ƒ d  ‚ Yn X| j | |  | ƒ S)Nz;descriptor 'format' of 'Formatter' object needs an argumentÚformat_stringr   z9Passing 'format_string' as keyword argument is deprecatedÚ
stacklevelé   z@format() missing 1 required positional argument: 'format_string')rL   r>   ÚpopÚwarningsÚwarnÚDeprecationWarningÚvformat)rO   Úkwargsr5   rW   r[   r   r   r   Úformat¯   s    		zFormatter.formatc             C   sA   t  ƒ  } |  j | | | | d ƒ \ } } |  j | | | ƒ | S)NrY   )ÚsetÚ_vformatÚcheck_unused_args)r5   rW   rO   r_   Ú	used_argsÚresultÚ_r   r   r   r^   Á   s    	!zFormatter.vformatr   c          	   C   sU  | d k  r t  d ƒ ‚ g  } x!|  j | ƒ D]\ } }	 }
 } | rS | j | ƒ |	 d  k	 r. |	 d k rœ | d k rƒ t  d ƒ ‚ t | ƒ }	 | d 7} n$ |	 j ƒ  rÀ | rº t  d ƒ ‚ d } |  j |	 | | ƒ \ } } | j | ƒ |  j | | ƒ } |  j |
 | | | | d d | ƒ\ }
 } | j |  j	 | |
 ƒ ƒ q. Wd j
 | ƒ | f S)Nr   zMax string recursion exceededr9   FzJcannot switch from manual field specification to automatic field numberingr8   Úauto_arg_index)r>   ÚparseÚappendÚstrÚisdigitÚ	get_fieldÚaddÚconvert_fieldrb   Úformat_fieldr   )r5   rW   rO   r_   rd   Úrecursion_depthrg   re   Úliteral_textÚ
field_nameÚformat_specÚ
conversionÚobjÚarg_usedr   r   r   rb   Ç   s4    	zFormatter._vformatc             C   s#   t  | t ƒ r | | S| | Sd  S)N)Ú
isinstanceÚint)r5   ÚkeyrO   r_   r   r   r   Ú	get_valueý   s    zFormatter.get_valuec             C   s   d  S)Nr   )r5   rd   rO   r_   r   r   r   rc     s    zFormatter.check_unused_argsc             C   s   t  | | ƒ S)N)r`   )r5   Úvaluers   r   r   r   ro     s    zFormatter.format_fieldc             C   sk   | d  k r | S| d k r& t  | ƒ S| d k r< t | ƒ S| d k rR t | ƒ St d j | ƒ ƒ ‚ d  S)Nr   ÚrÚaz"Unknown conversion specifier {0!s})rj   ÚreprÚasciir>   r`   )r5   r{   rt   r   r   r   rn     s    


zFormatter.convert_fieldc             C   s   t  j | ƒ S)N)Ú_stringÚformatter_parser)r5   rW   r   r   r   rh      s    zFormatter.parsec       	      C   sm   t  j | ƒ \ } } |  j | | | ƒ } x6 | D]. \ } } | rU t | | ƒ } q1 | | } q1 W| | f S)N)r€   Úformatter_field_name_splitrz   Úgetattr)	r5   rr   rO   r_   ÚfirstÚrestru   Úis_attrr@   r   r   r   rl   )  s    zFormatter.get_fieldN)r0   r1   r2   r`   r^   rb   rz   rc   ro   rn   rh   rl   r   r   r   r   r   ®   s   5	)rT   Ú__all__r€   r
   r   r   r   r   r   r   r	   r   r   Úrer$   Úcollectionsr   rM   Útyper   r   r   r   r   r   r   Ú<module>   s&   
a