
    Ki              
          d dl mZ d dlmZ dZdZddedededz  d	efd
Zddededz  d	eeef   fdZ	ddee   dedz  d	e
eeef      fdZeddedededz  d	efd       Zeddededz  d	eeef   fd       Zddedededz  d	efdZddedededz  d	efdZddedededz  d	efdZddedededz  d	efdZddee   dedz  d	e
e   fdZddee   dededz  d	e
e   fdZy)    )Sequence)bear_enforcez::__Nfirstsecond	separatorreturnc                 &    |xs t         }|  | | S N)DEFAULT_COMPOUND_SEPARATORr   r   r   s      k/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/key_value/shared/utils/compound.pycompound_stringr   	   s     77IWYKx((    stringc                     |xs t         }|| vrd|  d}t        |      d | j                  |d      }t        |      dk7  rd|  d}t        |      d |d   |d   fS )NzString z is not a compound identifier      r   )r   	TypeErrorsplitlen)r   r   msg	split_keys       r   uncompound_stringr      sz    77IVH$ABn$&!<<	15I
9~x<=n$&Q<1%%r   stringsc                 V    |xs t         }| D cg c]  }t        ||       c}S c c}w N)r   r   r   r   )r   r   r   s      r   uncompound_stringsr      s)    77IPWXfVyAXXXs   &
collectionkeyc                 2    |xs t         }t        | ||      S Nr   )r   r   )r    r!   r   s      r   compound_keyr$   "   s    77IC9MMr   c                 0    |xs t         }t        | |      S r   r   )r!   r   s     r   uncompound_keyr&   (   s    77IC9==r   prefixc                 2    |xs t         }t        || |      S r#   DEFAULT_PREFIX_SEPARATORr   )r!   r'   r   s      r   
prefix_keyr+   .   s    55IyIIr   c                     |xs t         }| j                  ||z         sd|  d| | }t        |      | t        ||z         d  S )NzKey  is not prefixed with r*   
startswith
ValueErrorr   )r!   r'   r   r   s       r   unprefix_keyr1   3   sW    55I>>&9,-SE/x	{Cos6I%&())r   c                 2    |xs t         }t        || |      S r#   r)   )r    r'   r   s      r   prefix_collectionr3   ;   s    55I
iPPr   c                     |xs t         }| j                  ||z         sd|  d| | }t        |      | t        ||z         d  S )NzCollection r-   r.   )r    r'   r   r   s       r   unprefix_collectionr5   @   sY    55I  )!34J<'=fXi[Qoc&9,-/00r   compound_keysc                 t    |xs t         }t        t        | |      D ch c]  \  }}|	 c}}      S c c}}w )zAReturn a unique list of collections from a list of compound keys.r   r   )r   listr   )r6   r   key_collection_s       r   "get_collections_from_compound_keysr<   H   s5    77I9KTamv9wx$5NAxyyxs   4
c                 n    |xs t         }t        | |      D cg c]  \  }}||k(  s| c}}S c c}}w )zDReturn all keys from a list of compound keys for a given collection.r8   )r   r   )r6   r    r   r:   r!   s        r   get_keys_from_compound_keysr>   N   sK    77I+=m_h+i  K'NCm{  @J  nJC  K  K  Ks   11r   )collections.abcr   )key_value.shared.type_checking.bear_sprayr   r   r*   strr   tupler   r9   r   r$   r&   r+   r1   r3   r5   r<   r>    r   r   <module>rD      s   $ B!  )3 ) )d
 )c )
&c &cDj &E#s(O &Y Y#* YPTUZ[^`c[cUdPe Y
 NS Ns NsTz NS N N
 > >d
 >eCHo > >
JC J Jt Js J
*c *3 *3: * *Q# Qs QsTz QUX Q
1C 1 1t 1WZ 1zhsm zPSVZPZ zfjknfo zKx} K# KZ]`dZd Kptuxpy Kr   