o �J�h� � @spddlmZddlZddlmZmZGdd�d�Zedkr6ed�Ze ej dd gd d gd d ddggd��dSdS)�)� annotationsN)�Mapping�Sequencec@sXeZdZUdZe�eej�Zded<ded<e ddd��Z ddd d �Z dddd�Z d S)� CodeTemplatez-(^[^\n\S]*)?\$([^\d\W]\w*|\{,?[^\d\W]\w*\,?})�str�pattern�filename�returncCs:t|��}t|��|�Wd�S1swYdS�N)�openr�read)r�f�r�TC:\pinokio\api\whisper-webui.git\app\env\lib\site-packages\torchgen\code_template.py� from_files  $�zCodeTemplate.from_file��NonecCs||_||_dSr )rr)�selfrrrrr�__init__s zCodeTemplate.__init__N�env�Mapping[str, object] | None�kwargs�objectc sF�duri�d��fdd� �dd d ��d��fd d� }|j�||j�S)N�vrr rcs$�dusJ�|�vr�|S�|Sr r)r)rrrr�lookup's z'CodeTemplate.substitute.<locals>.lookup�indent�Sequence[object]csd��fdd�|D����S)Nrcs*g|]}t|���D]}�|d�q qS)� )r� splitlines)�.0�e�l�rrr� <listcomp>-s*zACodeTemplate.substitute.<locals>.indent_lines.<locals>.<listcomp>)�join�rstrip)rrrr"r� indent_lines+s ��z-CodeTemplate.substitute.<locals>.indent_lines�match� re.Match[str]cs�|�d�}|�d�}d}d}|ddkr6|dd�}|ddkr(d}|dd�}|ddkr6d}|dd�}�|�}|durKt|t�sF|g}�||�St|t�rhd�d d �|D��}t|�dkrb|S|||St|�S) N��rr�{������,z, cSsg|]}t|��qSr)r)r�xrrrr#Csz<CodeTemplate.substitute.<locals>.replace.<locals>.<listcomp>)�group� isinstance�listr$�lenr)r'r�keyZ comma_beforeZ comma_afterr�middle)r&rrr�replace0s.             z(CodeTemplate.substitute.<locals>.replace)rrr r)rrrrr r)r'r(r r)� substitution�subr)rrrr5r)rr&rrr� substitute!s  zCodeTemplate.substitute)rrr r)r)rrrrr rr )rrrrr r) �__name__� __module__� __qualname__Zsubstitution_str�re�compile� MULTILINEr6�__annotations__� staticmethodrrr8rrrrrs   �r�__main__z� int foo($args) { $bar $bar $a+$b } int commatest(int a${,stuff}) int notest(int a${,empty,}) �hi��what���z things...�others)�args�bar�a�b�stuff�empty) � __future__rr<�typingrrrr9�c�printr8rrrr�<module>s&  <� ���
Memory