
    mi                     <   d Z ddlZddlZddlZddlZddl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 ddlmZ dd	lmZ dd
lmZ ej        dk    rddlmZ nddlmZ  G d de          ZdefdZ e            ZdedefdZe	 G d d                      ZdS )z;Caching of formatted files with feature-based invalidation.    N)Iterable)	dataclassfield)Path)
NamedTuple)user_cache_dir)version)Mode)err)      )Selfc                   .    e Zd ZU eed<   eed<   eed<   dS )FileDatast_mtimest_sizehashN)__name__
__module____qualname__float__annotations__intstr     c/var/www/html/bestrading.cuttalo.com/scripts/kaggle-env/lib/python3.11/site-packages/black/cache.pyr   r      s+         OOOLLL
IIIIIr   r   returnc                      t          d          } t          t          j                            d|                     }|t
          z  }|S )a[  Get the cache directory used by black.

    Users can customize this directory on all systems using `BLACK_CACHE_DIR`
    environment variable. By default, the cache directory is the user cache directory
    under the black application.

    This result is immediately set to a constant `black.cache.CACHE_DIR` as to avoid
    repeated calls.
    blackBLACK_CACHE_DIR)r   r   osenvironget__version__)default_cache_dir	cache_dirs     r   get_cache_dirr(      sA     'w//RZ^^$57HIIJJIK'Ir   modec                 B    t           d|                                  dz  S )Nzcache.z.pickle)	CACHE_DIRget_cache_key)r)   s    r   get_cache_filer-   3   s%    = 2 2 4 4=====r   c                   &   e Zd ZU eed<   eed<    ee          Zee	e
f         ed<   ededefd            Zedede	fd            Zedede
fd	            Zd
edefdZdee         deee         ee         f         fdZdee         ddfdZdS )Cacher)   
cache_file)default_factory	file_datar   c                 *   t          |          }	 |                                }n8# t          $ r+}t          d| d|             | ||          cY d}~S d}~ww xY w|s | ||          S |                    d          5 }	 t          j        |          }d |                                D             }n:# t
          j        t          t          f$ r  | ||          cY cddd           S w xY w	 ddd           n# 1 swxY w Y    | |||          S )zRead the cache if it exists and is well-formed.

        If it is not well-formed, the call to write later should
        resolve the issue.
        zUnable to read cache file z due to Nrbc                 (    i | ]\  }}|t          | S r   )r   .0kvs      r   
<dictcomp>zCache.read.<locals>.<dictcomp>Q   s"    FFFAQ!FFFr   )r-   existsOSErrorr   openpickleloaditemsUnpicklingError
ValueError
IndexError)clsr)   r0   r;   efobjdatar2   s           r   readz
Cache.read=   s    $D))
	)&&((FF 	) 	) 	)DZDDDDEEE3tZ((((((((	)  	)3tZ(((__T"" 	-d-:@+d:K:KFFFFF		*J
C - - -s4,,,,	- 	- 	- 	- 	- 	- 	- 	-- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- s4Y///sP   & 
A AAAC=2B65C=6(C-C=,C--C==DDpathc                 v    |                                  }t          j        |                                          S )zReturn hash digest for path.)
read_byteshashlibsha256	hexdigest)rI   rG   s     r   hash_digestzCache.hash_digestW   s/       ~d##--///r   c                     |                                  }t                              |           }t          |j        |j        |          S )zReturn file data for path.)statr/   rO   r   r   r   )rI   rQ   r   s      r   get_file_datazCache.get_file_data^   s:     yy{{  &&t|T:::r   sourcec                 >   |                                 }| j                            t          |                    }|dS |                                }|j        |j        k    rdS |j        |j        k    r't                              |          }||j	        k    rdS dS )z7Check if source has changed compared to cached version.NTF)
resolver2   r$   r   rQ   r   r   r/   rO   r   )selfrS   res_srcoldstnew_hashs         r   
is_changedzCache.is_changedf   s    ..""n  W..;4\\^^:$$4;#,&&((11H38##tur   sourcesc                     t                      }t                      }|D ]B}|                     |          r|                    |           -|                    |           C||fS )zSplit an iterable of paths in `sources` into two sets.

        The first contains paths of files that modified on disk or are not in the
        cache. The other contains paths to non-modified files.
        )setr[   add)rV   r\   changeddonesrcs        r   filtered_cachedzCache.filtered_cachedv   si     !UU%% 	 	Cs## C    }r   Nc                     | j         j        d
i d |D              	 t                              dd           t	          j        t          | j        j                  d          5 }d | j         	                                D             }t          j        ||d           d	d	d	           n# 1 swxY w Y   t          j        |j        | j                   d	S # t          $ r Y d	S w xY w)z6Update the cache file data and write a new cache file.c                     i | ]<}t          |                                          t                              |          =S r   )r   rU   r/   rR   )r7   rb   s     r   r:   zCache.write.<locals>.<dictcomp>   s8    OOOs3;;==!!5#6#6s#;#;OOOr   T)parentsexist_okF)dirdeletec                      i | ]\  }}|g |R S r   r   r6   s      r   r:   zCache.write.<locals>.<dictcomp>   s1     ; ; ;!%AAuuu; ; ;r      )protocolNr   )r2   updater+   mkdirtempfileNamedTemporaryFiler   r0   parentr@   r>   dumpr"   replacenamer<   )rV   r\   frG   s       r   writezCache.write   sS    	
 	
OOwOOO	
 	
 	
	OOD4O888,.//   1; ;)-)=)=)?)?; ; ; D!a00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Jqvt///// 	 	 	DD	s6   A	C ';B."C .B22C 5B26"C 
C('C()r   r   r   r
   r   r   r   dictr2   r   r   classmethodr   rH   staticmethodrO   rR   boolr[   r   tupler^   rc   rv   r   r   r   r/   r/   7   sY        
JJJ%*U4%@%@%@ItCM"@@@0 0 0 0 0 [02 0$ 03 0 0 0 \0 ;D ;X ; ; ; \; $     x~ %D	3t9@T:U    Xd^       r   r/   ) __doc__rL   r"   r>   sysro   collections.abcr   dataclassesr   r   pathlibr   typingr   platformdirsr   _black_versionr	   r%   
black.moder
   black.outputr   version_infor   typing_extensionsr   r(   r+   r-   r/   r   r   r   <module>r      s   A A  				  



  $ $ $ $ $ $ ( ( ( ( ( ( ( (             ' ' ' ' ' ' 1 1 1 1 1 1            w&&&&&&    z   t    " MOO	> >$ > > > > ^ ^ ^ ^ ^ ^ ^ ^ ^ ^r   