daemon: added class variable type hinting to core.config
This commit is contained in:
parent
6201875b78
commit
b28ef76d65
1 changed files with 20 additions and 17 deletions
|
@ -4,7 +4,7 @@ Common support for configurable CORE objects.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Type, Union
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union
|
||||||
|
|
||||||
from core.emane.nodes import EmaneNet
|
from core.emane.nodes import EmaneNet
|
||||||
from core.emulator.enumerations import ConfigDataTypes
|
from core.emulator.enumerations import ConfigDataTypes
|
||||||
|
@ -29,9 +29,9 @@ class ConfigGroup:
|
||||||
:param start: configurations start index for this group
|
:param start: configurations start index for this group
|
||||||
:param stop: configurations stop index for this group
|
:param stop: configurations stop index for this group
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name: str = name
|
||||||
self.start = start
|
self.start: int = start
|
||||||
self.stop = stop
|
self.stop: int = stop
|
||||||
|
|
||||||
|
|
||||||
class Configuration:
|
class Configuration:
|
||||||
|
@ -56,18 +56,21 @@ class Configuration:
|
||||||
:param default: default value for configuration
|
:param default: default value for configuration
|
||||||
:param options: list options if this is a configuration with a combobox
|
:param options: list options if this is a configuration with a combobox
|
||||||
"""
|
"""
|
||||||
self.id = _id
|
self.id: str = _id
|
||||||
self.type = _type
|
self.type: ConfigDataTypes = _type
|
||||||
self.default = default
|
self.default: str = default
|
||||||
if not options:
|
if not options:
|
||||||
options = []
|
options = []
|
||||||
self.options = options
|
self.options: List[str] = options
|
||||||
if not label:
|
if not label:
|
||||||
label = _id
|
label = _id
|
||||||
self.label = label
|
self.label: str = label
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.__class__.__name__}(id={self.id}, type={self.type}, default={self.default}, options={self.options})"
|
return (
|
||||||
|
f"{self.__class__.__name__}(id={self.id}, type={self.type}, "
|
||||||
|
f"default={self.default}, options={self.options})"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ConfigurableOptions:
|
class ConfigurableOptions:
|
||||||
|
@ -75,9 +78,9 @@ class ConfigurableOptions:
|
||||||
Provides a base for defining configuration options within CORE.
|
Provides a base for defining configuration options within CORE.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name = None
|
name: Optional[str] = None
|
||||||
bitmap = None
|
bitmap: Optional[str] = None
|
||||||
options = []
|
options: List[Configuration] = []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def configurations(cls) -> List[Configuration]:
|
def configurations(cls) -> List[Configuration]:
|
||||||
|
@ -115,8 +118,8 @@ class ConfigurableManager:
|
||||||
nodes.
|
nodes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_default_node = -1
|
_default_node: int = -1
|
||||||
_default_type = _default_node
|
_default_type: int = _default_node
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -243,8 +246,8 @@ class ModelManager(ConfigurableManager):
|
||||||
Creates a ModelManager object.
|
Creates a ModelManager object.
|
||||||
"""
|
"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.models = {}
|
self.models: Dict[str, Any] = {}
|
||||||
self.node_models = {}
|
self.node_models: Dict[int, str] = {}
|
||||||
|
|
||||||
def set_model_config(
|
def set_model_config(
|
||||||
self, node_id: int, model_name: str, config: Dict[str, str] = None
|
self, node_id: int, model_name: str, config: Dict[str, str] = None
|
||||||
|
|
Loading…
Reference in a new issue