feature: add __getitem__ to config.
This commit is contained in:
@@ -36,6 +36,12 @@ class MinerConfig:
|
|||||||
default_factory=PowerScalingConfig.default
|
default_factory=PowerScalingConfig.default
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def __getitem__(self, item):
|
||||||
|
try:
|
||||||
|
return getattr(self, item)
|
||||||
|
except AttributeError:
|
||||||
|
raise KeyError
|
||||||
|
|
||||||
def as_dict(self) -> dict:
|
def as_dict(self) -> dict:
|
||||||
"""Converts the MinerConfig object to a dictionary."""
|
"""Converts the MinerConfig object to a dictionary."""
|
||||||
return asdict(self)
|
return asdict(self)
|
||||||
|
|||||||
@@ -67,6 +67,13 @@ class MinerConfigOption(Enum):
|
|||||||
def default(cls):
|
def default(cls):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def __getitem__(self, item):
|
||||||
|
try:
|
||||||
|
return getattr(self, item)
|
||||||
|
except AttributeError:
|
||||||
|
raise KeyError
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class MinerConfigValue:
|
class MinerConfigValue:
|
||||||
@@ -112,3 +119,9 @@ class MinerConfigValue:
|
|||||||
|
|
||||||
def as_mara(self) -> dict:
|
def as_mara(self) -> dict:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
def __getitem__(self, item):
|
||||||
|
try:
|
||||||
|
return getattr(self, item)
|
||||||
|
except AttributeError:
|
||||||
|
raise KeyError
|
||||||
|
|||||||
Reference in New Issue
Block a user