docstr: Upload a theme to the HuggingFace hub.
  
  This requires a HuggingFace account.
  
  Parameters:
      repo_name: The name of the repository to store the theme assets, e.g. 'my_theme' or 'sunset'.
      org_name: The name of the org to save the space in. If None (the default), the username corresponding to the logged in user, or hƒ_token is used.
      version: A semantic version tag for theme. Bumping the version tag lets you publish updates to a theme without changing the look of applications that already loaded your theme.
      hf_token: API token for your HuggingFace account
      theme_name: Name for the name. If None, defaults to repo_name
      description: A long form description to your theme.
docstr_tok: ["Upload","a","theme","to","the","HuggingFace","hub",".","This","requires","a","HuggingFace","account",".","Parameters",":","repo_name",":","The","name","of","the","repository","to","store","the","theme","assets",",","e.g",".","'my_theme","'","or","'sunset","'",".","org_name",":","The","name","of","the","org","to","save","the","space","in",".","If","None","(","the","default",")",",","the","username","corresponding","to","the","logged","in","user",",","or","h\u0192_token","is","used",".","version",":","A","semantic","version","tag","for","theme",".","Bumping","the","version","tag","lets","you","publish","updates","to","a","theme","without","changing","the","look","of","applications","that","already","loaded","your","theme",".","hf_token",":","API","token","for","your","HuggingFace","account","theme_name",":","Name","for","the","name",".","If","None",",","defaults","to","repo_name","description",":","A","long","form","description","to","your","theme","."]
code: def push_to_hub(
      self,
      repo_name: str,
      org_name: str | None = None,
      version: str | None = None,
      hf_token: str | None = None,
      theme_name: str | None = None,
      description: str | None = None,
      private: bool = False,
  ):
      """Upload a theme to the HuggingFace hub.
  
      This requires a HuggingFace account.
  
      Parameters:
          repo_name: The name of the repository to store the theme assets, e.g. 'my_theme' or 'sunset'.
          org_name: The name of the org to save the space in. If None (the default), the username corresponding to the logged in user, or hƒ_token is used.
          version: A semantic version tag for theme. Bumping the version tag lets you publish updates to a theme without changing the look of applications that already loaded your theme.
          hf_token: API token for your HuggingFace account
          theme_name: Name for the name. If None, defaults to repo_name
          description: A long form description to your theme.
      """
  
      from gradio import __version__
  
      api = huggingface_hub.HfApi()
  
      if not hf_token:
          try:
              author = huggingface_hub.whoami()["name"]
          except OSError as e:
              raise ValueError(
                  "In order to push to hub, log in via `huggingface-cli login` "
                  "or provide a theme_token to push_to_hub. For more information "
                  "see https://huggingface.co/docs/huggingface_hub/quick-start#login"
              ) from e
      else:
          author = huggingface_hub.whoami(token=hf_token)["name"]
  
      space_id = f"{org_name or author}/{repo_name}"
  
      try:
          space_info = api.space_info(space_id)
      except Exception:
          space_info = None
  
      space_exists = space_info is not None
  
      # If no version, set the version to next patch release
      if not version:
          version = (
              self._get_next_version(space_info)
              if space_exists
              else "0.0.1"
          )
      else:
          _ = semver.Version(version)
  
      if space_exists and self._theme_version_exists(
          space_info, version
      ):
          raise ValueError(
              f"The space {space_id} already has a "
              f"theme with version {version}. See: themes/theme_schema@{version}.json. "
              "To manually override this version, use the HuggingFace hub UI."
          )
  
      theme_name = theme_name or repo_name
  
      with tempfile.NamedTemporaryFile(
          mode="w", delete=False, suffix=".json"
      ) as css_file:
          contents = self.to_dict()
          contents["version"] = version
          json.dump(contents, css_file, cls=fonts.FontEncoder)
      with tempfile.NamedTemporaryFile(
          mode="w", delete=False
      ) as readme_file:
          readme_content = README_CONTENT.format(
              theme_name=theme_name,
              description=description
              or "Add a description of this theme here!",
              author=author,
              gradio_version=__version__,
          )
          readme_file.write(textwrap.dedent(readme_content))
      with tempfile.NamedTemporaryFile(
          mode="w", delete=False
      ) as app_file:
          contents = (Path(__file__).parent / "app.py").read_text()
          contents = re.sub(
              r"theme=gr.themes.Default\(\)",
              f"theme='{space_id}'",
              contents,
          )
          contents = re.sub(
              r"{THEME}", theme_name or repo_name, contents
          )
          contents = re.sub(r"{AUTHOR}", org_name or author, contents)
          contents = re.sub(r"{SPACE_NAME}", repo_name, contents)
          app_file.write(contents)
  
      operations = [
          CommitOperationAdd(
              path_in_repo=f"themes/theme_schema@{version}.json",
              path_or_fileobj=css_file.name,
          ),
          CommitOperationAdd(
              path_in_repo="README.md", path_or_fileobj=readme_file.name
          ),
          CommitOperationAdd(
              path_in_repo="app.py", path_or_fileobj=app_file.name
          ),
      ]
  
      huggingface_hub.create_repo(
          space_id,
          repo_type="space",
          space_sdk="gradio",
          token=hf_token,
          exist_ok=True,
          private=private,
      )
  
      api.create_commit(
          repo_id=space_id,
          commit_message="Updating theme",
          repo_type="space",
          operations=operations,
          token=hf_token,
      )
      url = f"https://huggingface.co/spaces/{space_id}"
      print(f"See your theme here! {url}")
      return url
  
imports: from __future__ import annotations
  import json
  import re
  import tempfile
  import textwrap
  from pathlib import Path
  from typing import Iterable
  import huggingface_hub
  import semantic_version
  from gradio_client.documentation import document, set_documentation_group
  from huggingface_hub import CommitOperationAdd
  from gradio.themes.utils import colors, fonts, get_matching_version, get_theme_assets, sizes
  from gradio.themes.utils.readme_content import README_CONTENT
label_desc: Use image node_id 10 for calling the ThemeClass obj's underlying member method code with example usage: obj.push_to_hub(repo_name, org_name, version, hf_token, theme_name, description, private) and returns: url