U
    [¹Öh}  ã                   @  sª   d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dlmZ ddlmZ ej	rbd	d
l
mZ G dd„ deeef ƒZG dd„ deeedf eed ef f ƒZdS )é    )ÚannotationsN)ÚAny)ÚDict)ÚTuple)ÚUnioné   )ÚLiteralé   )Ú
CacheConstc                   @  s    e Zd ZdZdddœdd„ZdS )Úprefix_anon_mapaf  A map that creates new keys for missing key access.

    Considers keys of the form "<ident> <name>" to produce
    new symbols "<name>_<index>", where "index" is an incrementing integer
    corresponding to <name>.

    Inlines the approach taken by :class:`sqlalchemy.util.PopulateDict` which
    is otherwise usually used for this type of operation.

    Ústr©ÚkeyÚreturnc                 C  sB   |  dd¡\}}|  |d¡}|d | |< |› d|› }|| |< |S )Nú r	   Ú_)ÚsplitÚget)Úselfr   ÚidentZderivedZanonymous_counterÚvalue© r   ú=./venv/lib/python3.8/site-packages/sqlalchemy/sql/_py_util.pyÚ__missing__"   s    zprefix_anon_map.__missing__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s   r   c                   @  s4   e Zd ZdZdZdddœdd„Zdd	d
œdd„ZdS )Úcache_anon_mapaU  A map that creates new keys for missing key access.

    Produces an incrementing sequence given a series of unique keys.

    This is similar to the compiler prefix_anon_map class although simpler.

    Inlines the approach taken by :class:`sqlalchemy.util.PopulateDict` which
    is otherwise usually used for this type of operation.

    r   r   zTuple[str, bool])Úobject_r   c                 C  sX   t |ƒ}|| kr,| | }|dk	s$t‚|dfS t| jƒ | |< }|  jd7  _|dfS d S )NTr	   F)ÚidÚAssertionErrorr   Ú_index)r   r   ZidselfZs_valZid_r   r   r   Úget_anon;   s    zcache_anon_map.get_anonÚintr   r   c                 C  s$   t | jƒ | |< }|  jd7  _|S )Nr	   )r   r"   )r   r   Úvalr   r   r   r   H   s    zcache_anon_map.__missing__N)r   r   r   r   r"   r#   r   r   r   r   r   r   +   s   r   zLiteral[CacheConst.NO_CACHE]T)Z
__future__r   Útypingr   r   r   r   Zutil.typingr   ZTYPE_CHECKINGZ	cache_keyr
   r   r   r$   r   r   r   r   r   Ú<module>   s   
ÿ