File: //usr/lib/python3/dist-packages/sphinx/__pycache__/theming.cpython-310.pyc
o
�$�a�! � @ s d Z ddlZddlZddlZddlZddlmZ ddlmZmZm Z m
Z
ddlmZ ddl
Z
ddlmZ ddlmZ ddlmZ dd lmZ dd
lmZ erTddlmZ e�e�Ze� ZdZd
e de ddfdd�Z!G dd� d�Z"d
e de#fdd�Z$G dd� 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
C s� t |� t| ��C}|�� D ]5}|�d�rq
t�||�}t t�|�� tt�|�d��}|�|� |�� W d � n1 s=w Y q
W d � dS 1 sNw Y dS )z%Extract zip file to target directory.�/�wbN)
r r �namelist�endswithr �join�dirname�open�write�read)r r �archive�name�entry�fp� r �0/usr/lib/python3/dist-packages/sphinx/theming.py�extract_zip% s
���"�r c @ s� e Zd ZdZdededdddfdd �Zdee fd
d�Zefdeded
e de fdd�Z
i fdeee f deee f fdd�Zddd�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�HTMLThemeFactoryr Nc
C s* || _ d | _d | _t�|�rd | _|| _nt�d�| _t�| j|�| _t || j� t
�� | _| j�
t�| jt�� z | j�dd�}W n+ t
jyX } z ttd�| �|�d }~w t
jym } z ttd�| �|�d }~ww |dkr�z |�|�| _W d S ty� } zttd�||f �|�d }~ww d S )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�mkdtempr r �configparser�RawConfigParser�configr � THEMECONF�get�NoSectionErrorr r
�
NoOptionError�create)�selfr r"