
    '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dS )$    )annotationsN)IterableIterator)AnyCallablefuncsCallable[..., Any]returnc                 2    d }t          j        ||           S )Nc                      fdS )Nc                 &      | i |          S N )argskwargsf1f2s     D/DATA/AppData/hermes/venv/lib/python3.11/site-packages/path/masks.py<lambda>z+compose.<locals>.<lambda>.<locals>.<lambda>   s     BB<O<O<O9P9P     r   )r   r   s   ``r   r   zcompose.<locals>.<lambda>   s    !P!P!P!P!P r   )	functoolsreduce)r   compose_twos     r   composer      s    PPKK///r   numberintIterator[int]c                t    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mapr   reversed)r   digitss     r   gen_bit_valuesr$      s/     [[_FsHV$$%%%r   FiterableIterable[Any]	fillvalue
Any | Nonen
int | Nonenext_multipleboolIterator[Any]c              #    K   t          |           }|/t          j        |t          j        |                    E d{V  dS |dk     rt	          d          d}|D ]}|V  |dz  }|r||z
  |z  n||z
  }t          |          D ]}|V  dS )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)	r%   r'   r)   r+   it
item_countitem	remaining_s	            r   paddedr;      s      * 
hBy?2y'7	'B'BCCCCCCCCCCC	
Q/000
 	 	DJJJ!OJJ,9MQ^q((q:~	y!! 	 	AOOOO	 	r   modestrCallable[[int], int]c           
     z    t          t          t          t          |                     d                               S )zw
    Support multiple, comma-separated Unix chmod symbolic modes.

    >>> oct(compound('a=r,u+w')(0))
    '0o644'
    ,)r   r!   simpler"   split)r<   s    r   compoundrC   D   s+     CC 9 9::;;r   c                  	
 t          j        d|           }|st          d|           t          ddd          fd|                    d          D             }t          j        t          j        |d	          
t          d
dd	          	|                    d          	                    dd          }	
fd|D             }t          j        t          j        |          }|                    d          }|dk    r|dz  }|dk    r0	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   | ]}|         V  d S r   r   ).0permspec_maps     r   	<genexpr>zsimple.<locals>.<genexpr>t   s'      ==Xd^======r   whatr         )ugowhoaugoc              3  .   K   | ]}|         z  V  d S r   r   )rJ   subj	shift_mapspecs     r   rM   zsimple.<locals>.<genexpr>z   s,      55TYt_$555555r   op-i  =c              3  .   K   | ]}d |         z  V  dS )   Nr   )rJ   rX   rY   s     r   rM   zsimple.<locals>.<genexpr>   s,      88D	$'888888r   c                    |z  | z  S r   r   )masktargetretains     r   r   zsimple.<locals>.<lambda>   s    &6/D"8 r   )+r\   r]   )rematchr4   dictgroupr   r   operatoror_replaceand_partial)r<   parsedspecsrT   masksra   r[   op_maprc   rY   rZ   rL   s           @@@@r   rA   rA   N   s   @ XFMMF =5t<<< a1"""H====V(<(<===EHL%33D qA###I
,,u


%
%c5
1
1C55555555EHL%00D	d		B 
Syy 
Syy8888C888!(,66> \]8888 F
 VBZ...r   c                  J    e Zd ZdZed	d            Zed
d            Zd	dZdS )Permissionsz
    >>> perms = Permissions(0o764)
    >>> oct(perms)
    '0o764'
    >>> perms.symbolic
    'rwxrw-r--'
    >>> str(perms)
    'rwxrw-r--'
    >>> str(Permissions(0o222))
    '-w--w--w-'
    r
   r=   c                    d                     d t          t          j        d          | j                  D                       S )N c              3  0   K   | ]\  }}d |g|         V  dS )r\   Nr   )rJ   valbits      r   rM   z'Permissions.symbolic.<locals>.<genexpr>   s?       
 
 (SS#JsO
 
 
 
 
 
r   rwx)joinzipr1   cyclebitsselfs    r   symboliczPermissions.symbolic   sJ    ww 
 
,/	0F0F	,R,R
 
 
 
 
 	
r   r   c           	     t    t          t          t          t          |           dd                              S )Nr   	   )r)   )r"   tupler;   r$   r~   s    r   r}   zPermissions.bits   s/    f^D%9%91BBBCCDDDr   c                    | j         S r   )r   r~   s    r   __str__zPermissions.__str__   s
    }r   N)r
   r=   )r
   r   )__name__
__module____qualname____doc__propertyr   r}   r   r   r   r   rs   rs      sv        
 
 
 
 
 X

 E E E XE     r   rs   )r   r	   r
   r	   )r   r   r
   r   )NNF)
r%   r&   r'   r(   r)   r*   r+   r,   r
   r-   )r<   r=   r
   r>   )
__future__r   r   r1   ri   re   collections.abcr   r   typingr   r   r   r$   r;   rC   rA   r   rs   r   r   r   <module>r      s   " " " " " "          				 . . . . . . . .                0 0 0 0	& 	& 	& 	& !	" " " " "J< < < <?/ ?/ ?/ ?/D    #     r   