clean up
This commit is contained in:
1 parent
b0d924f63a
commit
02cbacabe0
10 files changed
+47
-44
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.responses import RedirectResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
from src.automations.manager import AutomationManager
|
||||
from src.env import API_PREFIX, ORIGIN, ROOT_FOLDER
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import base64
|
||||
import json
|
||||
import sqlite3
|
||||
import base64
|
||||
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from typing import Iterable, Iterator, List, Optional
|
||||
|
||||
from src.logger import get_logger
|
||||
from .types import ExtenededAutomation
|
||||
|
||||
from .errors import DBDataError, DBError, DBNoAutomationFound
|
||||
from .types import ExtenededAutomation
|
||||
|
||||
logger = get_logger(__file__)
|
||||
|
||||
@@ -99,19 +99,6 @@ class AutomationDBConnection:
|
||||
""",
|
||||
)
|
||||
|
||||
def delete_automations(self, automations: List[ExtenededAutomation]):
|
||||
with self.get_cur() as cur:
|
||||
cur.executemany(
|
||||
f"DELETE FROM {automations_tbl} WHERE id = ?", [(a.id,) for a in automations]
|
||||
)
|
||||
|
||||
def delete_automations_in_source_file(self, source_file: Path):
|
||||
with self.get_cur() as cur:
|
||||
cur.execute(
|
||||
f"DELETE FROM {automations_tbl} WHERE source_file = ?",
|
||||
(str(source_file.absolute()),),
|
||||
)
|
||||
|
||||
def get_automation(self, automation_id: str) -> ExtenededAutomation:
|
||||
with self.get_cur() as cur:
|
||||
cur.execute(
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from pathlib import Path
|
||||
from typing import Any, Iterator, Tuple, Union
|
||||
from ..hass_config.loader import HassConfig
|
||||
|
||||
from src.json_serializer import normalize_obj
|
||||
from src.logger import get_logger
|
||||
from src.utils import extract_files
|
||||
from src.yaml_serializer import load_yaml
|
||||
from src.yaml_serializer.types import IncludedYaml, IncludedYamlDir
|
||||
from src.utils import extract_files
|
||||
|
||||
from ..hass_config.loader import HassConfig
|
||||
from .errors import InvalidAutomationFile
|
||||
from .types import ExtenededAutomation
|
||||
|
||||
|
||||
@@ -2,17 +2,19 @@ from pathlib import Path
|
||||
from tempfile import mktemp
|
||||
from typing import Optional, Union
|
||||
|
||||
from ..errors import ErrorSet
|
||||
|
||||
from ..logger import get_logger
|
||||
from .errors import AttemptingToOverwriteAnIncompatibleFileError, DBError, InvalidAutomationFile
|
||||
|
||||
from src.hass_config.loader import HassConfig
|
||||
from src.yaml_serializer import dump_yaml, load_yaml
|
||||
|
||||
from ..errors import ErrorSet
|
||||
from ..logger import get_logger
|
||||
from .db import AutomationDBConnection
|
||||
from .errors import (
|
||||
AttemptingToOverwriteAnIncompatibleFileError,
|
||||
DBError,
|
||||
InvalidAutomationFile,
|
||||
)
|
||||
from .loader import extract_automation_paths, load_automation_path
|
||||
from .types import ExtenededAutomation
|
||||
from .db import AutomationDBConnection
|
||||
|
||||
logger = get_logger(__file__)
|
||||
|
||||
|
||||
Reference in new issue
Block a user