mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-08-16 02:25:10 +00:00
Finally got around to installing This amazing component by @ludeeus
This commit is contained in:
43
config/custom_components/hacs/helpers/get_defaults.py
Executable file
43
config/custom_components/hacs/helpers/get_defaults.py
Executable file
@@ -0,0 +1,43 @@
|
||||
"""Helpers to get default repositories."""
|
||||
import json
|
||||
from aiogithubapi import AIOGitHub, AIOGitHubException
|
||||
from integrationhelper import Logger
|
||||
|
||||
|
||||
async def get_default_repos_orgs(github: type(AIOGitHub), category: str) -> dict:
|
||||
"""Gets default org repositories."""
|
||||
repositories = []
|
||||
logger = Logger("hacs")
|
||||
orgs = {
|
||||
"plugin": "custom-cards",
|
||||
"integration": "custom-components",
|
||||
"theme": "home-assistant-community-themes",
|
||||
}
|
||||
if category not in orgs:
|
||||
return repositories
|
||||
|
||||
try:
|
||||
repos = await github.get_org_repos(orgs[category])
|
||||
for repo in repos:
|
||||
repositories.append(repo.full_name)
|
||||
|
||||
except AIOGitHubException as exception:
|
||||
logger.error(exception)
|
||||
|
||||
return repositories
|
||||
|
||||
|
||||
async def get_default_repos_lists(github: type(AIOGitHub), default: str) -> dict:
|
||||
"""Gets repositories from default list."""
|
||||
repositories = []
|
||||
logger = Logger("hacs")
|
||||
|
||||
try:
|
||||
repo = await github.get_repo("hacs/default")
|
||||
content = await repo.get_contents(default)
|
||||
repositories = json.loads(content.content)
|
||||
|
||||
except AIOGitHubException as exception:
|
||||
logger.error(exception)
|
||||
|
||||
return repositories
|
Reference in New Issue
Block a user