
    ij|                        d dl mZ d dlZd dlZd dlZd dlZd dlmZmZ d dl	m
Z
mZ ddZddZ	 	 	 d	 	 	 	 	 	 	 	 	 ddZddZdd	Z G d
 de      Zy)    )annotationsN)IterableIterator)AnyCallablec                 4    d }t        j                  ||       S )Nc                      fdS )Nc                        | i |      S N )argskwargsf1f2s     7/DATA/.local/lib/python3.12/site-packages/path/masks.py<lambda>z+compose.<locals>.<lambda>.<locals>.<lambda>   s    B<O<O9P    r   )r   r   s   ``r   r   zcompose.<locals>.<lambda>   s    !Pr   )	functoolsreduce)funcscompose_twos     r   composer      s    PKK//r   c                P    t        |       dd }t        t        t        |            S )z
    Return a zero or one for each bit of a numeric value up to the most
    significant 1 bit, beginning with the least significant bit.

    >>> list(gen_bit_values(16))
    [0, 0, 0, 0, 1]
       N)binmapintreversed)numberdigitss     r   gen_bit_valuesr!      s%     [_FsHV$%%r   c              #    K   t        |       }|2t        j                  |t        j                  |            E d{    y|dk  rt	        d      d}|D ]  }| |dz  } |r||z
  |z  n||z
  }t        |      D ]  }|  y7 Kw)a  Yield the elements from *iterable*, followed by *fillvalue*, such that
    at least *n* items are emitted.

        >>> list(padded([1, 2, 3], '?', 5))
        [1, 2, 3, '?', '?']

    If *next_multiple* is ``True``, *fillvalue* will be emitted until the
    number of items emitted is a multiple of *n*::

        >>> list(padded([1, 2, 3, 4], n=3, next_multiple=True))
        [1, 2, 3, 4, None, None]

    If *n* is ``None``, *fillvalue* will be emitted indefinitely.

    N   zn must be at least 1r   )iter	itertoolschainrepeat
ValueErrorrange)	iterable	fillvaluennext_multipleit
item_countitem	remaining_s	            r   paddedr3      s     * 
hBy??2y'7'7	'BCCC	
Q/00
DJ!OJ  -:Q^q(q:~	y!AO " 	Ds   :B
BAB
c           
     ^    t        t        t        t        | j	                  d                   S )zw
    Support multiple, comma-separated Unix chmod symbolic modes.

    >>> oct(compound('a=r,u+w')(0))
    '0o644'
    ,)r   r   simpler   split)modes    r   compoundr9   D   s#     CC 9:;;r   c                  	
 t        j                  d|       }|st        d|       t        ddd      fd|j	                  d      D        }t        j                  t        j                  |d	      
t        d
dd	      	|j	                  d      j                  dd      }	
fd|D        }t        j                  t        j                  |      }|j	                  d      }|dk(  r|dz  }|dk(  r2	fd|D        }t        j                  t        j                  |      dz  t        j                  t        j                  fdd}t        j                  ||   |      S )au  
    Convert a Unix chmod symbolic mode like ``'ugo+rwx'`` to a function
    suitable for applying to a mask to affect that change.

    >>> mask = simple('ugo+rwx')
    >>> mask(0o554) == 0o777
    True

    >>> simple('go-x')(0o777) == 0o766
    True

    >>> simple('o-x')(0o445) == 0o444
    True

    >>> simple('a+x')(0) == 0o111
    True

    >>> simple('a=rw')(0o057) == 0o666
    True

    >>> simple('u=x')(0o666) == 0o166
    True

    >>> simple('g=')(0o157) == 0o107
    True

    >>> simple('gobbledeegook')
    Traceback (most recent call last):
    ValueError: ('Unrecognized symbolic mode', 'gobbledeegook')
    z.(?P<who>[ugoa]+)(?P<op>[-+=])(?P<what>[rwx]*)$zUnrecognized symbolic mode   r   r#   )rwxc              3  (   K   | ]	  }|     y wr   r   ).0permspec_maps     r   	<genexpr>zsimple.<locals>.<genexpr>t   s     =(<Xd^(<s   whatr         )ugowhoaugoc              3  .   K   | ]  }|   z    y wr   r   )r@   subj	shift_mapspecs     r   rC   zsimple.<locals>.<genexpr>z   s     5TYt_$   op-i  =c              3  .   K   | ]  }d |   z    yw)   Nr   )r@   rN   rO   s     r   rC   zsimple.<locals>.<genexpr>   s     8CD	$'CrQ   c                    |z  | z  S r   r   )masktargetretains     r   r   zsimple.<locals>.<lambda>   s    &6/D"8r   )+rS   rT   )rematchr(   dictgroupr   r   operatoror_replaceand_partial)r8   parsedspecsrJ   masksrX   rR   op_maprZ   rO   rP   rB   s           @@@@r   r6   r6   N   s/   @ XXFMF5t<< a1"H=V(<=EHLL%3D qA#I
,,u

%
%c5
1C55EHLL%0D	d	B 
Sy 
Sy8C8!!(,,6> \\]]8F
 VBZ..r   c                  <    e Zd ZdZedd       Zedd       ZddZy)Permissionsz
    >>> perms = Permissions(0o764)
    >>> oct(perms)
    '0o764'
    >>> perms.symbolic
    'rwxrw-r--'
    >>> str(perms)
    'rwxrw-r--'
    >>> str(Permissions(0o222))
    '-w--w--w-'
    c                    dj                  d t        t        j                  d      | j                        D              S )N c              3  0   K   | ]  \  }}d |g|     yw)rS   Nr   )r@   valbits      r   rC   z'Permissions.symbolic.<locals>.<genexpr>   s!      
,RSS#JsO,Rs   rwx)joinzipr%   cyclebitsselfs    r   symboliczPermissions.symbolic   s4    ww 
,/	0F		,R
 
 	
r   c           	     T    t        t        t        t        |       dd                  S )Nr   	   )r,   )r   tupler3   r!   ru   s    r   rt   zPermissions.bits   s     f^D%91BCDDr   c                    | j                   S r   )rw   ru   s    r   __str__zPermissions.__str__   s    }}r   N)returnstr)r}   Iterator[int])__name__
__module____qualname____doc__propertyrw   rt   r|   r   r   r   rj   rj      s6    
 
 

 E Er   rj   )r   Callable[..., Any]r}   r   )r   r   r}   r   )NNF)
r*   zIterable[Any]r+   z
Any | Noner,   z
int | Noner-   boolr}   zIterator[Any])r8   r~   r}   zCallable[[int], int])
__future__r   r   r%   r`   r\   collections.abcr   r   typingr   r   r   r!   r3   r9   r6   r   rj   r   r   r   <module>r      sz    "    	 .  0	& !	""" " 	"
 "J<?/D# r   