
    id                     z    d dl Z d dlmZ d dlmZmZ d dlZd dlmZ  e	       fdee
   de
fdZdeee
f   de
fd	Zy)
    N)Path)IterableUnion)msgexcludereturnc                    t        | t              r(| j                         D ci c]  \  }}||vs|| } }}t        j                  | d      j                  d      }t        j                  |      j                         S c c}}w )zGet the hash for a JSON-serializable object.

    data: The data to hash.
    exclude (Iterable[str]): Top-level keys to exclude if data is a dict.
    RETURNS (str): The hash.
    T)	sort_keysutf8)	
isinstancedictitemssrsly
json_dumpsencodehashlibmd5	hexdigest)datar   kvdata_strs        d/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/weasel/util/hashing.pyget_hashr   	   sq     $!%BA'1A1BB5<<VDH;;x **,, Cs
   BBpathc                    t        |       } | j                         s+| j                         st        j                  d|  dd       | j                         r:t        j                  t        |       j                               j                         S t        j                         }t        d | j                  d      D              D ]!  }|j                  |j                                # |j                         S )zGet the checksum for a file or directory given its file path. If a
    directory path is provided, this uses all files in that directory.

    path (Union[Path, str]): The file or directory path.
    RETURNS (str): The checksum.
    zCan't get checksum for z: not a file or directory   )exitsc              3   B   K   | ]  }|j                         s|  y w)N)is_file).0fps     r   	<genexpr>zget_checksum.<locals>.<genexpr>%   s     Lbrzz|rLs   *)r   r    is_dirr   failr   r   
read_bytesr   sortedrglobupdate)r   dir_checksumsub_files      r   get_checksumr-      s     :DLLNdkkm*4&0IJRST||~{{4:0023==?? {{}LDJJsOLL 	7H 3 3 56	7%%''    )r   pathlibr   typingr   r   r   wasabir   tuplestrr   r-    r.   r   <module>r5      sN      "   -2G 
-HSM 
- 
-(uT3Y' (C (r.   