
    QVji{                     r    d dl Zd dlmZ d dlmZ d dlZd dlmZ dZ G d d          Z	 G d d	          Z
dS )
    N)glob)cast)Storagez.data/serialization_idc                       e Zd Zd Zd ZdS )_HasStoragec                     || _         d S N_storage)selfstorages     Y/root/voice-cloning/.venv/lib/python3.11/site-packages/torch/package/_directory_reader.py__init__z_HasStorage.__init__   s        c                     | j         S r	   r
   r   s    r   r   z_HasStorage.storage   s
    }r   N)__name__
__module____qualname__r   r    r   r   r   r      s2                 r   r   c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	DirectoryReaderar  
    Class to allow PackageImporter to operate on unzipped packages. Methods
    copy the behavior of the internal PyTorchFileReader class (which is used for
    accessing packages in all other cases).

    N.B.: ScriptObjects are not depickleable or accessible via this DirectoryReader
    class due to ScriptObjects requiring an actual PyTorchFileReader instance.
    c                     || _         d S r	   )	directory)r   r   s     r   r   zDirectoryReader.__init__    s    "r   c                     | j          d| }t          |d          5 }|                                cd d d            S # 1 swxY w Y   d S )N/rb)r   openread)r   namefilenamefs       r   
get_recordzDirectoryReader.get_record#   s    n--t--(D!! 	Q6688	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   >AAc                     | j          d| }t          j                            |          |z  }t	          t
          t          j                  }t          |                    ||                    S )Nr   )r!   nbytes)	r   torch_utils_element_sizer   r   UntypedStorager   	from_file)r   r    numeldtyper!   r%   r   s          r   get_storage_from_recordz'DirectoryReader.get_storage_from_record(   sd    n--t--++E22U:w 4557,,hv,NNOOOr   c                     t           j                            | j        |          }t           j                            |          S r	   )ospathjoinr   isfile)r   r0   	full_paths      r   
has_recordzDirectoryReader.has_record.   s-    GLL66	w~~i(((r   c                 R      fdt           j         dd          D             }|S )Nc                     g | ]@}t           j                            |          !|t          j                  d z   d         AS )   N)r/   r0   isdirlenr   ).0r!   r   s     r   
<listcomp>z3DirectoryReader.get_all_records.<locals>.<listcomp>5   sW     
 
 
7==**
S((1,../
 
 
r   z/**T)	recursive)r   r   )r   filess   ` r   get_all_recordszDirectoryReader.get_all_records2   sJ    
 
 
 
 DN!7!7!74HHH
 
 

 r   c                 n    |                      t                    r|                     t                    S dS )N )r4    __serialization_id_record_name__r#   r   s    r   serialization_idz DirectoryReader.serialization_id<   s1     ??;<< 	??#CDDD2r   N)
r   r   r   __doc__r   r#   r-   r4   r>   rB   r   r   r   r   r      s{         # # #  
P P P) ) )      r   r   )os.pathr/   r   typingr   r&   torch.typesr   rA   r   r   r   r   r   <module>rG      s                        $<         , , , , , , , , , ,r   