o
    3g                     @  s  d dl mZ d dlZd dlmZmZ d dlmZ d dlm	Z	 d dl
mZmZmZmZmZ ddlmZmZ ee	ef Zeee ef Zd	Zefd
d
ddIddZedZG dd dee ZdJddZd dlZdKddZdd lmZ esdd!lmZ ed"d#d$ Z ed%d&d' Z!ed(d)d* Z"ed+d,d- Z#ed.d/d0 Z$ed1d2d3 Z%ed4d5d6 Z&ed7d8d9 Z'ed:d;d< Z(ed=d>d? Z)ed@dAdB Z*d dCl
m+Z+ ddDl,m-Z- ddEl.m/Z/ ddFl0m1Z1 ddGl2m3Z3m4Z4m5Z5 e4Z6dS ddHlm7Z7 e7Z1e7Z6e7Z3e7Z5e7Z4dS )L    )annotationsN)IterableSequence)glob)Path)TYPE_CHECKINGCallableGenericTypeVarUnion   )compatwarnings*T)sortguess_compressionppPathsr   strr   boolr   returntuple[Path, ...]c             	     s  t | tr	| g}nt | tr| dkrdS t| g}ndd | D }ddd}g }|D ]S}|jd	 d
kr7| }t|}d|v r]|tkrRt|  d| d| d |t	tt
| q*tjt|rp||}	||	 q*| sxJ ||| q*|rt|}t|d	krtd|  d|  d  d	dl}
|
  |rddlm mm d fddfdd|D }t|S )z
    Helper function to avoid boilerplate.

    Tuple as return type is a bit friendlier for hashing/caching, so hopefully makes sense
      c                 S  s"   g | ]}t |tr|nt|qS r   )
isinstancer   .0pr   r   (/home/garg/my-data/HPI/my/core/common.py
<listcomp>1   s   " zget_files.<locals>.<listcomp>r   r   c                  S  s   dd l } |  d jS )Nr   )	tracebackextract_stackfilename)r!   r   r   r   caller3   s   zget_files.<locals>.callerr   ~r   z: treating z as glob path. Explicit glob=z argument is ignored!
z : no paths were matched against zP. This might result in missing data. Likely, the directory you passed is empty.
Nr   CPathZipPathis_compressedr   r   c                   s4   t | r| S | jdkr| S | r | S | S )Nz.zip)r   suffix)r   r'   r   r   wrapd   s   

zget_files.<locals>.wrapc                   s   g | ]} |qS r   r   r   )r,   r   r   r   m   s    r   r   )r   r   r   r   )r   r   r   parts
expanduserDEFAULT_GLOBr   mediumextendmapdo_globospathisdirr   existsappendsortedlenhighstripr!   print_stackkompressr(   r)   r*   tuple)r   r   r   r   sourcesr$   pathssrcgsgpr!   r   )r(   r)   r*   r,   r   	get_files   sN   



	rF   _Rc                   @  s    e Zd ZdddZddd	Zd
S )classpropertyfCallable[..., _R]r   Nonec                 C  s
   || _ d S NrI   )selfrI   r   r   r   __init__x      
zclassproperty.__init__rG   c                 C  s
   |  |S rL   rM   )rN   objclsr   r   r   __get__{   rP   zclassproperty.__get__N)rI   rJ   r   rK   )r   rG   )__name__
__module____qualname__rO   rS   r   r   r   r   rH   w   s    
rH   rK   c                  C  s:   ddl m}  G dd d}|j}| |t |dksJ d S )Nr   )assert_typec                   @  s   e Zd ZedddZdS )ztest_classproperty.<locals>.Cr   r   c                 S  s   dS )Nhellor   )rR   r   r   r   prop   s   z"test_classproperty.<locals>.C.propNr-   )rT   rU   rV   rH   rY   r   r   r   r   C   s    rZ   rX   )r   rW   rY   r   )rW   rZ   resr   r   r   test_classproperty   s
   
r\   sc                 C  s"   t |  dd} tdd| S )N _z(?u)[^-\w.]r   )r   r=   replaceresub)r]   r   r   r   get_valid_filename   s   rc   )unique_everseen)
deprecatedz'use my.core.compat.assert_never insteadc                  O     t j| i |S rL   )r   assert_neverargskwargsr   r   r   rg         rg   z(use my.core.compat.fromisoformat insteadc                  O  rf   rL   )r   fromisoformatrh   r   r   r   isoparse   rk   rm   zuse more_itertools.one insteadc                  O     dd l }|j| i |S Nr   )more_itertoolsone)ri   rj   rp   r   r   r   the      rr   z%use functools.cached_property insteadc                  O  rn   ro   )	functoolscached_property)ri   rj   rt   r   r   r   	cproperty   rs   rv   z!use more_itertools.bucket insteadc                 C  s8   i }| D ]}||}| |g }|| |||< q|S rL   )getr9   )lkeyr[   ikklstr   r   r   group_by_key   s   

r}   z-use my.core.utils.itertools.make_dict insteadc                  O     ddl m} |j| i |S Nr   )	itertools)utilsr   	make_dictri   rj   UIr   r   r   r         r   z+use my.core.utils.itertools.listify insteadc                  O  r~   r   r   r   listifyr   r   r   r   r      r   r   z!use my.core.warn_if_empty insteadc                  O  r~   r   r   r   r   r   r   warn_if_empty   r   r   zuse my.core.stat insteadc                  O  r~   )Nr   )stats)r   r   stat)ri   rj   r   r   r   r   r      r   r   zuse my.core.make_logger insteadc                  O  r~   )Nr   )logging)r   r   
LazyLogger)ri   rj   r   r   r   r   r      r   r   z use my.core.types.asdict insteadc                  O  r~   )Nr   )types)r   r   asdict)ri   rj   r   r   r   r   r      r   r   )Literal)mcachew)setup_logger)Stats)Jsondatetime_awaredatetime_naive)Never)
r   r   r   r   r   r   r   r   r   r   )r   rK   )r]   r   r   r   )8
__future__r   r5   collections.abcr   r   r   r4   pathlibr   typingr   r   r	   r
   r   r   r   r   r   PathIshr   r0   rF   rG   rH   r\   ra   rc   utils.itertoolsrd   re   rg   rm   rr   rv   r}   r   r   r   r   r   r   r   cachewr   r   r   r   r   r   r   r   r   
tzdatetimer   r   r   r   r   <module>   sr    V






	





