a
    mJh                     @   s  d dl mZmZmZmZmZmZmZmZm	Z	 er6e
Z
neeZ
e	eef Zeedf Ze	ee
f Zeedf Ze	ee
f Zeeee	eef f  Ze	deeeef f Zee	eef e	eef dddZeedddd	Zeed
ddZee eeeeeef  f dddZdS )    )	AnyDictIterableListOptionalSequenceTupleTYPE_CHECKINGUnion.N)namepathreturnc                    s6   t |tr S t |ttfr |S t fdd|D S )z7Fix all `...` in the path replacing then with the name.c                 3   s    | ]}t |tr n|V  qd S )N)
isinstanceellipsis).0xr    N/var/www/shaz/venv/lib/python3.9/site-packages/dataclass_factory/path_utils.py	<genexpr>#   s   z#replace_ellipsis.<locals>.<genexpr>)r   r   strinttuple)r   r   r   r   r   replace_ellipsis   s    
r   )rootkeyr   c                 C   s   t | tr\t |ts.tdt| d| dt| |d k r| d g|t|  d   n$t |trtdt| d| dd S )NzExpected int, but got got  (`z`) in field path   zExpected str, but got )r   listr   
ValueErrortypelenextend)r   r   r   r   r   extend_container)   s    


r#   )r   r   c                 C   s    t | trd g| d  S i S d S )Nr   )r   r   )r   r   r   r   make_container3   s    
r$   )pathsr   c                 C   s   dg}g }| D ]}|}d}|D ]}d}|du r2t t|trlt|ts`t dt| d| d||vrld}t|trt|tst dt| d| d|| du rd}|rt|||< nt|| | || }|}q|	||f q|d |fS )	z
    Create empty structure that can be filled by described path
    Returns whole container itself and separate subcontainers for each path
    Nr   Fzstr expected, found r   z`)Tzint expected, found )
r   r   dictr   r    r   r   r$   r#   append)r%   r   Zfield_containersr   currentZprev_keyZnext_keyZ	not_existr   r   r   init_structure:   s4    



r)   )typingr   r   r   r   r   r   r   r	   r
   r   r    Ellipsisr   r   ZCleanKeyZ	CleanPathKeyPathZFieldOrAutoZNameMapping	Containerr   r#   r$   r)   r   r   r   r   <module>   s   ,"
