class_docstr: A Theme is a set of HTML templates and configurations.
  
  This class supports both theme directory and theme archive (zipped theme).
class_docstr_tok: ["A","Theme","is","a","set","of","HTML","templates","and","configurations",".","This","class","supports","both","theme","directory","and","theme","archive","(","zipped","theme",")","."]
code: def __init__(
      self, name: str, theme_path: str, factory: HTMLThemeFactory
  ) -> None:
      self.name = name
      self.base = None
      self.rootdir = None
  
      if path.isdir(theme_path):
          # already a directory, do nothing
          self.rootdir = None
          self.themedir = theme_path
      else:
          # extract the theme to a temp directory
          self.rootdir = tempfile.mkdtemp("sxt")
          self.themedir = path.join(self.rootdir, name)
          extract_zip(theme_path, self.themedir)
  
      self.config = configparser.RawConfigParser()
      config_file_path = path.join(self.themedir, THEMECONF)
      if not os.path.isfile(config_file_path):
          raise ThemeError(
              __("theme configuration file %r not found")
              % config_file_path
          )
      self.config.read(config_file_path, encoding="utf-8")
  
      try:
          inherit = self.config.get("theme", "inherit")
      except configparser.NoSectionError as exc:
          raise ThemeError(
              __('theme %r doesn\'t have "theme" setting') % name
          ) from exc
      except configparser.NoOptionError as exc:
          raise ThemeError(
              __('theme %r doesn\'t have "inherit" setting') % name
          ) from exc
  
      if inherit != "none":
          try:
              self.base = factory.create(inherit)
          except ThemeError as exc:
              raise ThemeError(
                  __("no theme named %r found, inherited by %r")
                  % (inherit, name)
              ) from exc
  
imports: from __future__ import annotations
  import configparser
  import os
  import shutil
  import sys
  import tempfile
  from os import path
  from typing import TYPE_CHECKING, Any
  from zipfile import ZipFile
  import contextlib
  from sphinx import package_dir
  from sphinx.config import check_confval_types
  from sphinx.errors import ThemeError
  from sphinx.locale import __
  from sphinx.util import logging
  from sphinx.util.osutil import ensuredir
label_desc: Use image node_id 1 to create a new Theme object  with example: obj = Theme(name, theme_path, factory)