Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ee7ce8f70 | ||
|
|
2dfbc31b5d | ||
|
|
ab4997494d | ||
|
|
83b1c85043 |
No files matched your search
@@ -1,5 +1,9 @@
|
|||||||
# Changelog 
|
# Changelog 
|
||||||
|
|
||||||
|
## [0.7.3] Bugfixes
|
||||||
|
|
||||||
|
- Backend now correctly returns unset alias + description
|
||||||
|
|
||||||
## [0.7.1] Bugfixes + Italian!
|
## [0.7.1] Bugfixes + Italian!
|
||||||
|
|
||||||
- Added support for automations that do not have an `id`
|
- Added support for automations that do not have an `id`
|
||||||
|
|||||||
@@ -330,6 +330,8 @@ def load_automation_path(
|
|||||||
def clean_automation(auto_raw: dict):
|
def clean_automation(auto_raw: dict):
|
||||||
return {
|
return {
|
||||||
**auto_raw,
|
**auto_raw,
|
||||||
|
"alias": auto_raw.get("alias", "") or "",
|
||||||
|
"description": auto_raw.get("description", "") or "",
|
||||||
"condition": ifempty_or_null_then_list(load_conditions(auto_raw.get("condition", []))),
|
"condition": ifempty_or_null_then_list(load_conditions(auto_raw.get("condition", []))),
|
||||||
"action": ifempty_or_null_then_list(load_conditions(auto_raw.get("action", []))),
|
"action": ifempty_or_null_then_list(load_conditions(auto_raw.get("action", []))),
|
||||||
"trigger": ifempty_or_null_then_list(normalize_obj(auto_raw.get("trigger", []))),
|
"trigger": ifempty_or_null_then_list(normalize_obj(auto_raw.get("trigger", []))),
|
||||||
|
|||||||
@@ -33,47 +33,35 @@ AutomationExtractedIter = Iterator[ExtractedAutomation]
|
|||||||
|
|
||||||
class BaseAutomation(BaseModel):
|
class BaseAutomation(BaseModel):
|
||||||
id: Optional[str]
|
id: Optional[str]
|
||||||
alias: Optional[str] = None
|
alias: str = ""
|
||||||
description: Optional[str] = None
|
description: str = ""
|
||||||
trigger_variables: Optional[dict[str, Union[str, int, bool, float]]] = None
|
trigger_variables: Optional[dict[str, Union[str, int, bool, float]]] = None
|
||||||
mode: str = "single"
|
mode: str = "single"
|
||||||
trigger: list[dict] = []
|
trigger: list[dict] = []
|
||||||
condition: list[dict] = []
|
condition: list[dict] = []
|
||||||
action: list[dict] = []
|
action: list[dict] = []
|
||||||
|
|
||||||
def to_primitive(self, exclude_unset=True, exclude_none=True, **kwrgs):
|
def to_primitive(self):
|
||||||
return BaseModel.dict(self, exclude_unset=exclude_unset, exclude_none=exclude_none, **kwrgs)
|
return self.dict(exclude_unset=True, exclude_none=True)
|
||||||
|
|
||||||
def dict(self, **kwrgs):
|
|
||||||
kwrgs["exclude_unset"] = True
|
|
||||||
kwrgs["exclude_none"] = True
|
|
||||||
return self.to_primitive(
|
|
||||||
**kwrgs,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Automation(BaseAutomation):
|
class Automation(BaseAutomation):
|
||||||
tags: dict[str, str] = Field(default_factory=dict)
|
tags: dict[str, str] = Field(default_factory=dict)
|
||||||
|
|
||||||
def to_primitive(self, include_tags: bool = False, **kwrgs):
|
def to_primitive(self, include_tags: bool = False):
|
||||||
out = super().to_primitive(**kwrgs)
|
out = super().to_primitive()
|
||||||
if not include_tags and out.get("tags", None) is not None:
|
if not include_tags and out.get("tags", None) is not None:
|
||||||
del out["tags"]
|
del out["tags"]
|
||||||
if include_tags and out.get("tags", None) is None:
|
|
||||||
out["tags"] = {}
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def dict(self, **kwrgs):
|
|
||||||
return BaseAutomation.dict(self, **kwrgs, include_tags=True)
|
|
||||||
|
|
||||||
|
|
||||||
class ExtenededAutomation(Automation):
|
class ExtenededAutomation(Automation):
|
||||||
source_file: str
|
source_file: str
|
||||||
source_file_type: Literal["list", "obj", "inline"]
|
source_file_type: Literal["list", "obj", "inline"]
|
||||||
configuration_key: ConfigurationKey
|
configuration_key: ConfigurationKey
|
||||||
|
|
||||||
def to_primitive(self, include_tags: bool = False, **kwrgs):
|
def to_primitive(self, include_tags: bool = False):
|
||||||
out = super().to_primitive(include_tags=include_tags, **kwrgs)
|
out = super().to_primitive(include_tags=include_tags)
|
||||||
del out["source_file"]
|
del out["source_file"]
|
||||||
del out["source_file_type"]
|
del out["source_file_type"]
|
||||||
del out["configuration_key"]
|
del out["configuration_key"]
|
||||||
|
|||||||
@@ -1,21 +1,28 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Iterator, NamedTuple, Tuple, Union
|
from typing import Iterator, NamedTuple, Tuple
|
||||||
|
|
||||||
from yaml.nodes import Node
|
from yaml.nodes import Node
|
||||||
|
|
||||||
|
from src.logger import get_logger
|
||||||
|
|
||||||
from .manager import YamlManager
|
from .manager import YamlManager
|
||||||
|
|
||||||
dump_yaml = YamlManager.dump_yaml
|
dump_yaml = YamlManager.dump_yaml
|
||||||
load_yaml = YamlManager.load_yaml
|
load_yaml = YamlManager.load_yaml
|
||||||
|
|
||||||
|
logger = get_logger(__file__)
|
||||||
|
|
||||||
|
|
||||||
def load_dir_yaml(folder_or_file: Path) -> Iterator[Tuple[Path, dict | list]]:
|
def load_dir_yaml(folder_or_file: Path) -> Iterator[Tuple[Path, dict | list]]:
|
||||||
if folder_or_file.is_dir():
|
if folder_or_file.is_dir():
|
||||||
for file in folder_or_file.iterdir():
|
for file in folder_or_file.iterdir():
|
||||||
yield from load_dir_yaml(file)
|
yield from load_dir_yaml(file)
|
||||||
else:
|
else:
|
||||||
with folder_or_file.open("r") as fp:
|
if folder_or_file.suffix.lower() == ".yaml":
|
||||||
yield folder_or_file, load_yaml(fp, root_path=folder_or_file.parent)
|
with folder_or_file.open("r") as fp:
|
||||||
|
yield folder_or_file, load_yaml(fp, root_path=folder_or_file.parent)
|
||||||
|
else:
|
||||||
|
logger.info(f"Ignoring the file {folder_or_file}")
|
||||||
|
|
||||||
|
|
||||||
@YamlManager.as_constructor("!include")
|
@YamlManager.as_constructor("!include")
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# all the packages!
|
||||||
|
|
||||||
|
This is really cool :)
|
||||||
|
|
||||||
|
- A list item!
|
||||||
|
|
||||||
|
<<more thisngs!>>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# all the packages!
|
||||||
|
|
||||||
|
This is really cool :)
|
||||||
|
|
||||||
|
- A list item!
|
||||||
|
|
||||||
|
<<more thisngs!>>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# all the packages!
|
||||||
|
|
||||||
|
This is really cool :)
|
||||||
|
|
||||||
|
- A list item!
|
||||||
|
|
||||||
|
<<more thisngs!>>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# all the packages!
|
||||||
|
|
||||||
|
This is really cool :)
|
||||||
|
|
||||||
|
- A list item!
|
||||||
|
|
||||||
|
<<more thisngs!>>
|
||||||
@@ -249,7 +249,7 @@ class automation_update_tests(BaseTestCase):
|
|||||||
)
|
)
|
||||||
autos = resp.json()["data"]
|
autos = resp.json()["data"]
|
||||||
self.assertEqual(resp.json()["totalItems"], self.test_params["total"])
|
self.assertEqual(resp.json()["totalItems"], self.test_params["total"])
|
||||||
self.assertNotIn("i am new", set([a["id"] for a in autos]))
|
self.assertNotIn("i am new", set([a.get("id", "") for a in autos]))
|
||||||
resp = self.client.post(
|
resp = self.client.post(
|
||||||
"/automations/item",
|
"/automations/item",
|
||||||
json=Automation(
|
json=Automation(
|
||||||
@@ -262,7 +262,7 @@ class automation_update_tests(BaseTestCase):
|
|||||||
)
|
)
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
self.assertEqual(data["totalItems"], self.test_params["total"] + 1)
|
self.assertEqual(data["totalItems"], self.test_params["total"] + 1)
|
||||||
self.assertIn("i am new", set([a["id"] for a in data["data"]]))
|
self.assertIn("i am new", set([a.get("id", "") for a in data["data"]]))
|
||||||
|
|
||||||
def test_update_some(self):
|
def test_update_some(self):
|
||||||
resp = self.client.post(
|
resp = self.client.post(
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
name: Shortumation
|
name: Shortumation
|
||||||
version: v0.7.1
|
version: v0.7.3
|
||||||
slug: shortumation
|
slug: shortumation
|
||||||
image: "asosnovsky/shortumation-{arch}"
|
image: "asosnovsky/shortumation-{arch}"
|
||||||
url: "https://github.com/asosnovsky/Shortumation"
|
url: "https://github.com/asosnovsky/Shortumation"
|
||||||
|
|||||||
Reference in new issue
Block a user