o
    i                  
   @   s  d Z dZd#dedededB defddZd#d	ededB deeef fd
dZd#dee dedB deeeef  fddZd#dedededB defddZd#dededB deeef fddZ	d#dedededB defddZ
d#dedededB defddZd#dedededB defddZd#dedededB defddZd#dee dedB dee fdd Zd#dee dededB dee fd!d"ZdS )$z::__Nfirstsecond	separatorreturnc                 C   s   |pt }|  | | S NDEFAULT_COMPOUND_SEPARATORr   r   r    r
   e/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/key_value/shared/utils/compound.pycompound_string   s   r   stringc                 C   sd   |pt }|| vrd|  d}t|d | |d}t|dkr*d|  d}t|d |d |d fS )NzString z is not a compound identifier          )r   	TypeErrorsplitlen)r   r   msg	split_keyr
   r
   r   uncompound_string
   s   

r   stringsc                    s    pt   fdd| D S )Nc                    s   g | ]}t | d qS )r   r   )r   ).0r   r   r
   r   
<listcomp>   s    z&uncompound_strings.<locals>.<listcomp>r   r   r   r
   r   r   uncompound_strings   s   r   
collectionkeyc                 C   s   |pt }t| ||dS Nr	   )r   r   )r   r   r   r
   r
   r   compound_key      r!   c                 C   s   |pt }t| |dS )Nr   )r   r   )r   r   r
   r
   r   uncompound_key#   s   r#   prefixc                 C      |pt }t|| |dS r    DEFAULT_PREFIX_SEPARATORr   )r   r$   r   r
   r
   r   
prefix_key(   r"   r(   c                 C   F   |pt }| || sd|  d| | }t|| t|| d  S )NzKey  is not prefixed with r'   
startswith
ValueErrorr   )r   r$   r   r   r
   r
   r   unprefix_key-   
   r.   c                 C   r%   r    r&   )r   r$   r   r
   r
   r   prefix_collection5   r"   r0   c                 C   r)   )NzCollection r*   r+   )r   r$   r   r   r
   r
   r   unprefix_collection:   r/   r1   compound_keysc                 C   s"   |pt }tdd t| |dD S )zAReturn a unique list of collections from a list of compound keys.c                 S   s   h | ]\}}|qS r
   r
   )r   key_collection_r
   r
   r   	<setcomp>E   s    z5get_collections_from_compound_keys.<locals>.<setcomp>r   )r   listr   )r2   r   r
   r
   r   "get_collections_from_compound_keysB      r7   c                    s"   |pt } fddt| |dD S )zDReturn all keys from a list of compound keys for a given collection.c                    s   g | ]
\}}| kr|qS r
   r
   )r   r3   r   r   r
   r   r   K   s    z/get_keys_from_compound_keys.<locals>.<listcomp>r   )r   r   )r2   r   r   r
   r9   r   get_keys_from_compound_keysH   r8   r:   r   )r   r'   strr   tupler   r6   r   r!   r#   r(   r.   r0   r1   r7   r:   r
   r
   r
   r   <module>   s     $, $    $,