forked from hacs/integration
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
130 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,4 +105,5 @@ | |
"CyrisXD/love-lock-card", | ||
], | ||
"python_script": [], | ||
"theme": [], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"""Blueprint for HacsRepositoryThemes.""" | ||
# pylint: disable=too-many-instance-attributes,invalid-name,broad-except | ||
import logging | ||
|
||
from .blueprints import HacsRepositoryBase | ||
from .exceptions import HacsRequirement | ||
|
||
_LOGGER = logging.getLogger("custom_components.hacs.repository") | ||
|
||
|
||
class HacsRepositoryThemes(HacsRepositoryBase): | ||
""" | ||
Set up a HacsRepositoryThemes object. | ||
repository_name(str): The full name of a repository | ||
(example: awesome-dev/awesome-repo) | ||
""" | ||
|
||
def __init__(self, repository_name: str, repositoryobject=None): | ||
"""Initialize a HacsRepositoryThemes object.""" | ||
super().__init__() | ||
self.repository = repositoryobject | ||
self.repository_name = repository_name | ||
self.repository_type = "theme" | ||
self.manifest_content = None | ||
|
||
async def update(self): | ||
"""Run update tasks.""" | ||
if await self.common_update(): | ||
return | ||
await self.set_repository_content() | ||
|
||
async def set_repository_content(self): | ||
"""Set repository content attributes.""" | ||
contentfiles = [] | ||
|
||
if self.content_path is None: | ||
self.content_objects = await self.repository.get_contents( | ||
"themes", self.ref | ||
) | ||
|
||
self.content_path = self.content_objects[0].path | ||
|
||
self.name = self.content_objects[0].name.replace(".yaml", "") | ||
|
||
if not isinstance(self.content_objects, list): | ||
raise HacsRequirement("Repository structure does not meet the requirements") | ||
|
||
for filename in self.content_objects: | ||
contentfiles.append(filename.name) | ||
|
||
if contentfiles: | ||
self.content_files = contentfiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ python_scripts/awesome.py | |
info.md | ||
README.md | ||
``` | ||
|
||
#### Not OK example: | ||
|
||
```text | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Theme developers | ||
|
||
A template to use as a reference is [theme-hacs](https://github.com/ludeeus/theme-hacs) | ||
|
||
This is for the [`frontend` integration in Home Assistant](https://www.home-assistant.io/components/frontend/) | ||
|
||
## Requirements | ||
|
||
For a theme repository to be valid these are the requirements: | ||
|
||
### Repository structure | ||
|
||
- The theme configuration file are located here `ROOT_OF_THE_REPO/themes/SCRIPT_NAME.yaml` | ||
- There is only one theme configuration file (one directory under `ROOT_OF_THE_REPO/themes/`) per repository (if you have more, only the first one will be managed.) | ||
|
||
#### OK example: | ||
|
||
```text | ||
themes/awesome.yaml | ||
info.md | ||
README.md | ||
``` | ||
|
||
#### Not OK example: | ||
|
||
```text | ||
awesome.py | ||
info.md | ||
README.md | ||
``` | ||
|
||
### GitHub releases (optional) | ||
|
||
#### If there are releases | ||
|
||
When installing/upgrading it will scan the content in the latest release. | ||
|
||
#### If there are no releases | ||
|
||
It will scan files in the branch marked as default. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters