
    $TXg                        d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZ erddlmZmZ  e	e      Zd	 Zdd
ZddZddZy)zCommon directory utilities.    )annotations)reduce)
accumulatechain)	getLoggerjoin)TYPE_CHECKING)IterableSequencec                :    t        d t        | |      D              S )Nc              3  ,   K   | ]  \  }}||k(    y wN ).0tsws      =lib/python3.12/site-packages/conda/common/path/directories.py	<genexpr>z'tokenized_startswith.<locals>.<genexpr>   s     L$K51bqBw$Ks   )allzip)test_iterablestartswith_iterables     r   tokenized_startswithr      s    LC7J$KLLL    c                    t        t        d | D ch c]  }t        |j                  d      d d       ! c}            S c c}w )N/)sortedfiltertuplesplit)filesfs     r   get_all_directoriesr%      s:    &%H%Qaggcl3B&7 8%HIJJHs   $?c                    t        |       }|syg fd}t        ||      }sj                  |d          n t        |d         sj                  |       t	        d D              S )Nr   c                B    t        ||       sj                  |        |S r   )r   append)xyleavess     r   _processz&get_leaf_directories.<locals>._process$   s    #Aq)MM!r   r   c              3  >   K   | ]  }d j                  |        yw)r   Nr   )r   leafs     r   r   z'get_leaf_directories.<locals>.<genexpr>0   s     3FD$Fs   )r%   r   r(   r   r!   )r#   directoriesr,   lastr+   s       @r   get_leaf_directoriesr1      sk     &e,KF
 (K(Dk"o&!$r
3d3F333r   c                L    t        t        j                  d | D                    S )Nc              3  B   K   | ]  }|st        |t                y wr   )r   r	   )r   	directorys     r   r   z&explode_directories.<locals>.<genexpr>7   s      
9JIiJy$'9Js   )setr   from_iterable)child_directoriess    r   explode_directoriesr8   3   s,      
9J
 	
 r   N)r#   Iterable[str]returnzlist[tuple[str, ...]])r#   r9   r:   zSequence[str])r7   zIterable[tuple[str, ...]]r:   zset[str])__doc__
__future__r   	functoolsr   	itertoolsr   r   loggingr   os.pathr	   typingr
   collections.abcr   r   __name__logr   r%   r1   r8   r   r   r   <module>rE      sB    " "  '    2MK40r   