a
    ´iF)  ã                   @   s–   g d ¢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 i ZG dd„ dƒZe ¡  G dd„ dƒZdS ))Ú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  dd„ |  |¡D ƒ¡S )Nú c                 s   s   | ]}|  ¡ V  qd S ©N)Ú
capitalize)Ú.0Úx© r   ú/usr/lib64/python3.9/string.pyÚ	<genexpr>0   ó    zcapwords.<locals>.<genexpr>)ÚjoinÚsplit)ÚsÚsepr   r   r   r   %   s    r   )ÚChainMapc                       sV   e Zd ZdZdZdZejZ‡ fdd„Z	dd„ Z
dd	„ Zefd
d„Zefdd„Z‡  ZS )r   ú$z(?a:[_a-z][_a-z0-9]*)Nc              	      sr   t ƒ  ¡  d| jv r| j}n<t | j¡}| j}| jp8| j}d|› d|› d|› d|› d�	}t 	|| j
tjB ¡| _d S )NÚpatternz
            z(?:
              (?P<escaped>zC)  |   # Escape sequence of two delimiters
              (?P<named>zJ)       |   # delimiter and a Python identifier
              {(?P<braced>z�)} |   # delimiter and a braced identifier
              (?P<invalid>)             # Other ill-formed delimiter exprs
            )
            )ÚsuperÚ__init_subclass__Ú__dict__r!   Ú_reÚescapeÚ	delimiterÚ	idpatternÚbraceidpatternÚcompileÚflagsÚVERBOSE)Úclsr!   ÚdelimÚidÚbid©Ú	__class__r   r   r#   E   s     

ÿþýüzTemplate.__init_subclass__c                 C   s
   || _ d S r   )Útemplate)Úselfr3   r   r   r   Ú__init__W   s    zTemplate.__init__c                 C   sd   |  d¡}| jd |… jdd�}|s.d}d}n"|td |d d… ¡ƒ }t|ƒ}td||f ƒ‚d S )NÚinvalidT)Úkeependsé   Ú éÿÿÿÿz.Invalid placeholder in string: line %d, col %d)Ústartr3   Ú
splitlinesÚlenr   Ú
ValueError)r4   ÚmoÚiÚlinesÚcolnoÚlinenor   r   r   Ú_invalid\   s    
ÿzTemplate._invalidc                   s:   ˆ t u r|‰ n|rt|ˆ ƒ‰ ‡ ‡fdd„}ˆj |ˆj¡S )Nc                    sd   |   d¡p|   d¡}|d ur(tˆ | ƒS |   d¡d ur<ˆjS |   d¡d urTˆ | ¡ tdˆjƒ‚d S ©NÚnamedÚbracedÚescapedr6   z#Unrecognized named group in pattern)ÚgroupÚstrr'   rD   r>   r!   ©r?   rF   ©Úmappingr4   r   r   Úconvertn   s    
ÿz$Template.substitute.<locals>.convert©Ú_sentinel_dictÚ	_ChainMapr!   Úsubr3   ©r4   rM   ÚkwsrN   r   rL   r   Ú
substituteh   s    
zTemplate.substitutec                   s:   ˆ t u r|‰ n|rt|ˆ ƒ‰ ‡ ‡fdd„}ˆj |ˆj¡S )Nc                    s€   |   d¡p|   d¡}|d urFztˆ | ƒW S  tyD   |   ¡  Y S 0 |   d¡d urZˆjS |   d¡d urp|   ¡ S tdˆjƒ‚d S rE   )rI   rJ   ÚKeyErrorr'   r>   r!   rK   rL   r   r   rN   �   s    ÿz)Template.safe_substitute.<locals>.convertrO   rS   r   rL   r   Úsafe_substitute{   s    
zTemplate.safe_substitute)Ú__name__Ú
__module__Ú__qualname__r'   r(   r)   r%   Ú
IGNORECASEr+   r#   r5   rD   rP   rU   rW   Ú__classcell__r   r   r1   r   r   9   s   r   c                   @   sV   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 r   )Úvformat)r4   Úformat_stringÚargsÚkwargsr   r   r   Úformat    s    zFormatter.formatc                 C   s.   t ƒ }|  ||||d¡\}}|  |||¡ |S )Né   )ÚsetÚ_vformatÚcheck_unused_args)r4   r^   r_   r`   Ú	used_argsÚresultÚ_r   r   r   r]   £   s    zFormatter.vformatr   c              	   C   sê   |dk rt dƒ‚g }|  |¡D ]¼\}}	}
}|r8| |¡ |	d ur|	dkrj|du rXt dƒ‚t|ƒ}	|d7 }n|	 ¡ r‚|r~t dƒ‚d}|  |	||¡\}}| |¡ |  ||¡}| j|
||||d |d�\}
}| |  	||
¡¡ qd 
|¡|fS )Nr   zMax string recursion exceededr9   FzJcannot switch from manual field specification to automatic field numberingr8   )Úauto_arg_index)r>   ÚparseÚappendrJ   ÚisdigitÚ	get_fieldÚaddÚconvert_fieldrd   Úformat_fieldr   )r4   r^   r_   r`   rf   Úrecursion_depthri   rg   Úliteral_textÚ
field_nameÚformat_specÚ
conversionÚobjÚarg_usedr   r   r   rd   ©   s6    ÿ


ý
zFormatter._vformatc                 C   s   t |tƒr|| S || S d S r   )Ú
isinstanceÚint)r4   Úkeyr_   r`   r   r   r   Ú	get_valueß   s    
zFormatter.get_valuec                 C   s   d S r   r   )r4   rf   r_   r`   r   r   r   re   æ   s    zFormatter.check_unused_argsc                 C   s
   t ||ƒS r   )ra   )r4   Úvaluert   r   r   r   rp   ê   s    zFormatter.format_fieldc                 C   sN   |d u r|S |dkrt |ƒS |dkr,t|ƒS |dkr<t|ƒS td |¡ƒ‚d S )Nr   ÚrÚaz"Unknown conversion specifier {0!s})rJ   ÚreprÚasciir>   ra   )r4   r|   ru   r   r   r   ro   î   s    zFormatter.convert_fieldc                 C   s
   t  |¡S r   )Ú_stringÚformatter_parser)r4   r^   r   r   r   rj     s    zFormatter.parsec           	      C   sJ   t  |¡\}}|  |||¡}|D ] \}}|r8t||ƒ}q || }q ||fS r   )r�   Úformatter_field_name_splitr{   Úgetattr)	r4   rs   r_   r`   ÚfirstÚrestrv   Úis_attrr@   r   r   r   rm     s    
zFormatter.get_fieldN)r   )rX   rY   rZ   ra   r]   rd   r{   re   rp   ro   rj   rm   r   r   r   r   r   Ÿ   s    ÿ
6	r   )N)Ú__all__r�   r
   r   r   r   r   r   r   r	   r   r   Úrer%   Úcollectionsr   rQ   rP   r   r#   r   r   r   r   r   Ú<module>   s"   
Y