
    -PhP              	          d dl mZ d dlZd dlmZ d dlmZ d dlmZ er
d dl	Z	d dl
mZ  G d deeeee         ef         f                   Z G d	 d
eeeee         ef         f                   ZdS )    )annotationsN)Path)TYPE_CHECKING)_StrPath)Setc                  L     e Zd ZdZd fdZdd	Zdd
ZddZddZddZ	 xZ
S )FilenameUniqDictzA dictionary that automatically generates unique names for its keys,
    interpreted as filenames, and keeps track of a set of docnames they
    appear in.  Used for images and downloadable files in the environment.
    returnNonec                n    t                                                       t                      | _        d S N)super__init__set	_existing)self	__class__s    R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx/util/_files.pyr   zFilenameUniqDict.__init__   s(    #&55    docnamestrnewfilestr | os.PathLike[str]c                >   t          |          }|| v r"| |         \  }}|                    |           |S t          |          }|j        }|j        }|j        }d}|| j        v r|dz  }| | | }|| j        v |h|f| |<   | j                            |           |S )Nr      )r   addr   namestemsuffixr   )	r   r   r   docnamesunique_namenew_filebaseextis	            r   add_filezFilenameUniqDict.add_file   s    g,,d??$(M!HkLL!!!==m}oT^++FA!+1+c++K T^++ "K0W;'''r   c                    t          |                                           D ]<\  }\  }}|                    |           |s| |= | j                            |           =d S r   )listitemsdiscardr   )r   r   filenamedocsuniques        r   	purge_doczFilenameUniqDict.purge_doc+   sl    (,TZZ\\(:(: 	/ 	/$HntVLL!!! /N&&v...		/ 	/r   r    Set[str]otherdict[str, tuple[set[str], str]]c                    |                                 D ]3\  }\  }}|t          |          z  D ]}|                     ||           4d S r   r)   r   r&   )r   r    r0   r+   r,   _uniquedocs          r   merge_otherzFilenameUniqDict.merge_other2   sd     */ 	- 	-%HotWc(mm+ - -c8,,,,-	- 	-r   set[str]c                    | j         S r   r   )r   s    r   __getstate__zFilenameUniqDict.__getstate__9   s
    ~r   statec                    || _         d S r   r9   )r   r;   s     r   __setstate__zFilenameUniqDict.__setstate__<   s    r   )r
   r   )r   r   r   r   r
   r   r   r   r
   r   )r    r/   r0   r1   r
   r   )r
   r7   )r;   r7   r
   r   )__name__
__module____qualname____doc__r   r&   r.   r6   r:   r=   __classcell__)r   s   @r   r	   r	      s         
) ) ) ) ) )   &/ / / /- - - -          r   r	   c                  *    e Zd ZdZddZdd
ZddZdS )DownloadFileszA special dictionary for download files.

    .. important:: This class would be refactored in nearly future.
                   Hence don't hack this directly.
    r   r   r+   r   r
   r   c                B   t          |          }|| vrkt          j        |                                                                d                                          }t          ||j                  }|h|f| |<   |S | |         \  }}|                    |           |S )NF)usedforsecurity)	r   hashlibmd5as_posixencode	hexdigestr   r   r   )r   r   r+   digest	dest_pathr    s         r   r&   zDownloadFiles.add_fileG   s    >>4[!!##**,,e  ikk  !77I&i3DN"8n)Wr   r   c                    t          |                                           D ]"\  }\  }}|                    |           |s| |= #d S r   )r(   r)   r*   )r   r   r+   r,   _dests        r   r.   zDownloadFiles.purge_docU   sV    '+DJJLL'9'9 	# 	##HmtULL!!! #N	# 	#r   r    r/   r0   %dict[Path, tuple[set[str], _StrPath]]c                    |                                 D ]3\  }\  }}|t          |          z  D ]}|                     ||           4d S r   r3   )r   r    r0   r+   r,   rP   r   s          r   r6   zDownloadFiles.merge_other[   sd     (-{{}} 	1 	1#HmtU#h--/ 1 1gx00001	1 	1r   N)r   r   r+   r   r
   r   r>   )r    r/   r0   rQ   r
   r   )r?   r@   rA   rB   r&   r.   r6    r   r   rE   rE   @   sZ            # # # #1 1 1 1 1 1r   rE   )
__future__r   rH   pathlibr   typingr   sphinx.util._pathlibr   oscollections.abcr   dictr   tupler   r	   rE   rS   r   r   <module>r\      s   " " " " " "                    ) ) ) ) ) ) $III######/ / / / /tCs3x}!556 / / /d 1  1  1  1  1DuSXx%7889  1  1  1  1  1r   