B
    d                 @   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   J/var/www/html/venv/lib/python3.7/site-packages/pasta/base/fstring_utils.py
<listcomp>   s    z(get_formatted_values.<locals>.<listcomp>)values)Z
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)Z	val_indexr   r   r   placeholder   s    r   c             C   s2   x,t |D ] \}}| tt|t|} q
W | S )z7Replace placeholders in an fstring with subexpressions.)	enumeratereplace_wrapr   )Z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   