o
    Ni	                     @  s~   d Z ddlmZ ddlmZ ddlmZ ddlmZ er6ddl	m
Z
 ddlmZ ddlmZmZ dd	lmZ G d
d dZdS )z&Record metadata for the build process.    )annotations)TYPE_CHECKING)__)stable_hash)Set)Path)Config_ConfigRebuild)Tagsc                   @  sF   e Zd ZdZedddZd	d	e fdddZdddZdddZ	d	S )	BuildInfozbuildinfo file manipulator.

    HTMLBuilder and its family are storing their own envdata to ``.buildinfo``.
    This class is a manipulator for the file.
    clstype[BuildInfo]filenamer   returnc                C  s   |j dd}| }|d  }|dkrtd}t||d ds+td}t||d	 d
s:td}t|t }|d d |_	|d	 d
 |_
|S )Nutf-8encodingr   z# Sphinx build info version 1z7failed to read broken build info file (unknown version)   zconfig: z<failed to read broken build info file (missing config entry)   ztags: z:failed to read broken build info file (missing tags entry))	read_text
splitlinesrstripr   
ValueError
startswithr   removeprefixstripconfig_hash	tags_hash)r   r   contentlinesversionmsg
build_info r#   T/home/ubuntu/.local/lib/python3.10/site-packages/sphinx/builders/html/_build_info.pyload   s    zBuildInfo.loadNconfigConfig | NonetagsTags | Noneconfig_categoriesSet[_ConfigRebuild]Nonec                 C  sH   d| _ d| _|rdd ||D }t|| _ |r"tt|| _d S d S )N c                 S  s   i | ]}|j |jqS r#   )namevalue).0cr#   r#   r$   
<dictcomp>9   s    z&BuildInfo.__init__.<locals>.<dictcomp>)r   r   filterr   sorted)selfr&   r(   r*   valuesr#   r#   r$   __init__/   s   
zBuildInfo.__init__otherboolc                 C  s   | j |j ko| j|jkS )N)r   r   )r5   r8   r#   r#   r$   __eq__?   s   zBuildInfo.__eq__c                C  s(   d| j  d| j d}|j|dd d S )Nz# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: z
tags: 
r   r   )r   r   
write_text)r5   r   r"   r#   r#   r$   dumpD   s   zBuildInfo.dump)r   r   r   r   r   r   )r&   r'   r(   r)   r*   r+   r   r,   )r8   r   r   r9   )r   r   r   r,   )
__name__
__module____qualname____doc__classmethodr%   	frozensetr7   r:   r=   r#   r#   r#   r$   r      s    
r   N)rA   
__future__r   typingr   sphinx.localer   sphinx.util._serialiser   collections.abcr   pathlibr   sphinx.configr   r	   sphinx.util.tagsr
   r   r#   r#   r#   r$   <module>   s    