feature: add __getitem__ to config.

This commit is contained in:
Upstream Data
2024-05-10 13:08:45 -06:00
parent 7126e03f0d
commit 1d6618c1c0
2 changed files with 19 additions and 0 deletions

View File

@@ -36,6 +36,12 @@ class MinerConfig:
default_factory=PowerScalingConfig.default
)
def __getitem__(self, item):
try:
return getattr(self, item)
except AttributeError:
raise KeyError
def as_dict(self) -> dict:
"""Converts the MinerConfig object to a dictionary."""
return asdict(self)

View File

@@ -67,6 +67,13 @@ class MinerConfigOption(Enum):
def default(cls):
pass
def __getitem__(self, item):
try:
return getattr(self, item)
except AttributeError:
raise KeyError
@dataclass
class MinerConfigValue:
@@ -112,3 +119,9 @@ class MinerConfigValue:
def as_mara(self) -> dict:
return {}
def __getitem__(self, item):
try:
return getattr(self, item)
except AttributeError:
raise KeyError