
    JTh                     Z    S SK JrJr  S/r " S S5      r  SS\S\\   SSSSS	\4
S
 jjrg)   )	GlobGroupGlobPattern	Directoryc                       \ rS rSrSrS\S\4S jrS\\   SS 4S jr	S	\4S
 jr
S\S\4S jrS r  SS\\   S\S\4S jjrSrg)r   	   zA file structure representation. Organized as Directory nodes that have lists of
their Directory children. Directories for a package are created by calling
:meth:`PackageImporter.file_structure`.nameis_dirc                 *    Xl         X l        0 U l        g )N)r   r	   children)selfr   r	   s      c/var/www/auris/envauris/lib/python3.13/site-packages/torch/package/file_structure_representation.py__init__Directory.__init__   s    	.0    dirsreturnc                     [        U5      S:X  a  U $ US   nX R                  ;  a  [        US5      U R                  U'   U R                  U   R                  USS 5      $ )zBuilds path of Directories if not yet built and returns last directory
in list.

Args:
    dirs (List[str]): List of directory names that are treated like a path.

Returns:
    :class:`Directory`: The last Directory specified in the dirs list.
    Tr   N)lenr   r   _get_dir)r   r   dir_names      r   r   Directory._get_dir   s\     t9>K7==(&/$&?DMM(#}}X&//QR99r   	file_pathc                 ~    UR                  S5      Gt p#U R                  U5      n[        US5      UR                  U'   g)zAdds a file to a Directory.

Args:
    file_path (str): Path of file to add. Last element is added as a file while
        other paths items are added as directories.
/FN)splitr   r   r   )r   r   r   filedirs        r   	_add_fileDirectory._add_file$   s7      ooc*mmD!&tU3Tr   filenamec                     UR                  SSS9nUS   n[        U5      S:  a  US   OSnX0R                  R                  5       ;   a"  Uc  gU R                  U   R	                  U5      $ g)zChecks if a file is present in a :class:`Directory`.

Args:
    filename (str): Path of file to search for.
Returns:
    bool: If a :class:`Directory` contains the specified file.
r   r   )maxsplitr   NTF)r   r   r   keyshas_file)r   r!   lineagechildgrandchildrens        r   r%   Directory.has_file/   sn     ..q.1
&)'lQ&6
DMM&&(($}}U+44]CCr   c                 J    / nU R                  U5        SR                  U5      $ )N )_stringify_treejoin)r   str_lists     r   __str__Directory.__str__A   s$     X&wwx  r   r.   preambledir_ptrc                    SnSnSnSnUR                  U U U R                   S35        X6:X  a  X%-   nOX$-   n/ n/ n	U R                  R                  5        H:  u  pUR                  (       a  U	R                  U
5        M)  UR                  U
5        M<     [        [        U	5      5       Hf  u  pU[        U	5      S-
  :X  a0  [        U5      S:X  a!  U R                  U
   R                  XU5        MG  U R                  U
   R                  XU5        Mh     [        [        U5      5       H3  u  pU[        U5      S-
  :X  a  UOUnUR                  U U U S35        M5     g)	zCRecursive method to generate print-friendly version of a Directory.z    u   │   u
   ├── u
   └── 
r   r   N)	appendr   r   itemsr	   	enumeratesortedr   r,   )r   r.   r1   r2   spacebranchteelast	file_keysdir_keyskeyvalindexr   pointers                  r   r,   Directory._stringify_treeF   sD    #$ 	8*WIdii[;< >(H'H!	 ++-HCzz$  %	 . $F8$45JEX**I!0Cc"228tLc"228sK	 6
 %VI%67KE$I(::dGOOxj	$r:; 8r   )r   r	   r   N)r+   u
   ─── )__name__
__module____qualname____firstlineno____doc__strboolr   listr   r   r%   r/   r,   __static_attributes__ r   r   r   r   	   s    /1S 1$ 1
:T#Y :; :"	43 	4  $! ,	$<s)$< $< 	$< $<r   r!   	file_listincluder   excluder   c                     [        X#SS9n[        U S5      nU H,  nUR                  U5      (       d  M  UR                  U5        M.     U$ )a  Return a :class:`Directory` file structure representation created from a list of files.

Args:
    filename (str): The name given to the top-level directory that will be the
        relative root for all file paths found in the file_list.

    file_list (List[str]): List of files to add to the top-level directory.

    include (Union[List[str], str]): An optional pattern that limits what is included from the file_list to
        files whose name matches the pattern.

    exclude (Union[List[str], str]): An optional pattern that excludes files whose name match the pattern.

Returns:
        :class:`Directory`: a :class:`Directory` file structure representation created from a list of files.
r   )rP   	separatorT)r   r   matchesr   )r!   rN   rO   rP   glob_patterntop_dirr   s          r    _create_directory_from_file_listrV   m   sL    , WEL$'G%%d#  Nr   N)z**rM   )
glob_groupr   r   __all__r   rI   rK   rV   rM   r   r   <module>rY      s_    / -a< a<N "	Cy  	
 r   