o
    2h                     @   sX   d Z ddlmZ ddlmZ ddlmZ ddlZdZdd Zd	d
 Zdd Z	dd Z
dS )z/Helpers for working with fstrings (python3.6+).    )absolute_import)division)print_functionNz__pasta_fstring_val_{index}__c                 C   s   dd | j D S )z3Get all FormattedValues from a JoinedStr, in order.c                 S   s   g | ]
}t |tjr|qS  )
isinstanceastFormattedValue).0vr   r   S/var/www/html/chatgem/venv/lib/python3.10/site-packages/pasta/base/fstring_utils.py
<listcomp>   s    z(get_formatted_values.<locals>.<listcomp>)values)
joined_strr   r   r   get_formatted_values   s   r   c                 C   s   t j| dS )z=Get the placeholder token for a FormattedValue in an fstring.)index)_FSTRING_VAL_PLACEHOLDERformat)	val_indexr   r   r   placeholder   s   r   c                 C   s.   t |D ]\}}| tt|t|} q| S )z7Replace placeholders in an fstring with subexpressions.)	enumeratereplace_wrapr   )fstrr   ivaluer   r   r   perform_replacements$   s   r   c                 C   s   d|  S )Nz{%s}r   )sr   r   r   r   +   s   r   )__doc__
__future__r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s   