Skip to content

Commit

Permalink
removed old model definition
Browse files Browse the repository at this point in the history
  • Loading branch information
rsnodgrass committed Feb 19, 2024
1 parent 4c382af commit c6aeeb5
Showing 1 changed file with 2 additions and 35 deletions.
37 changes: 2 additions & 35 deletions pyavcontrol/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class _Config:

CONFIG = _Config()

# FIXME: see schema!

# FIXME: other explorations below
# https://dev.to/eblocha/using-dataclasses-for-configuration-in-python-4o53
#
Expand All @@ -30,41 +32,6 @@ class _Config:
# config.customer.first_name


@dataclass
class ManufacturerInfo:
name: str
model: str

def __init__(self, conf):
self.name = conf[CONFIG.name]
self.model = conf[CONFIG.model]

def __post_init__(self):
if not self.name:
raise ValueError('name must be defined')
if not self.model:
raise ValueError('model must be defined')


@dataclass
class ModelDefinition:
id: str
description: str
urls: list[str]

manufacturer: ManufacturerInfo

def __init__(self, conf: dict):
self.id = conf[CONFIG.id]
self.description = conf[CONFIG.description]
self.urls = conf[CONFIG.urls]

self.manufacturer = ManufacturerInfo(conf)

def __post_init__(self):
if not self.id:
raise ValueError('id must be defined')


# FIXME: if we want completely dynamic config we can use below
# https://alexandra-zaharia.github.io/posts/python-configuration-and-dataclasses/
Expand Down

0 comments on commit c6aeeb5

Please sign in to comment.