File: rebuild_routes.py

package info (click to toggle)
zwave-js-server-python 0.68.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,824 kB
  • sloc: python: 15,927; sh: 21; javascript: 16; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,073 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Provide models for rebuilding routes."""

from __future__ import annotations

from dataclasses import dataclass
from enum import StrEnum
from typing import TypedDict


class RebuildRoutesOptionsDataType(TypedDict, total=False):
    """Represent a rebuild routes options data dict type."""

    includeSleeping: bool


@dataclass
class RebuildRoutesOptions:
    """Represent options for rebuilding routes."""

    include_sleeping: bool | None = None

    @classmethod
    def from_dict(cls, data: RebuildRoutesOptionsDataType) -> RebuildRoutesOptions:
        """Return options from data."""
        return cls(include_sleeping=data.get("includeSleeping"))

    def to_dict(self) -> RebuildRoutesOptionsDataType:
        """Return dict representation of data."""
        if self.include_sleeping is None:
            return {}
        return {"includeSleeping": self.include_sleeping}


class RebuildRoutesStatus(StrEnum):
    """Enum of all known rebuild routes status values."""

    PENDING = "pending"
    DONE = "done"
    FAILED = "failed"
    SKIPPED = "skipped"