Change namedtuple to OrderedDict for conflayers
This commit is contained in:
parent
e7c23312d7
commit
b0792203a5
@ -90,7 +90,7 @@ class KeyValue:
|
|||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
layer: The layer to set the value on, an element name of the
|
layer: The layer to set the value on, an element name of the
|
||||||
ValueLayers namedtuple.
|
ValueLayers dict.
|
||||||
key: The key of the element to set.
|
key: The key of the element to set.
|
||||||
value: The value to set.
|
value: The value to set.
|
||||||
"""
|
"""
|
||||||
@ -195,7 +195,7 @@ class ValueList:
|
|||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
layer: The layer to set the value on, an element name of the
|
layer: The layer to set the value on, an element name of the
|
||||||
ValueLayers namedtuple.
|
ValueLayers dict.
|
||||||
key: The key of the element to set.
|
key: The key of the element to set.
|
||||||
value: The value to set.
|
value: The value to set.
|
||||||
"""
|
"""
|
||||||
|
@ -17,9 +17,7 @@
|
|||||||
|
|
||||||
"""A single value (with multiple layers possibly) in the config."""
|
"""A single value (with multiple layers possibly) in the config."""
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import OrderedDict
|
||||||
|
|
||||||
ValueLayers = namedtuple('ValueLayers', 'temp, conf, default')
|
|
||||||
|
|
||||||
|
|
||||||
class SettingValue:
|
class SettingValue:
|
||||||
@ -31,7 +29,7 @@ class SettingValue:
|
|||||||
Attributes:
|
Attributes:
|
||||||
typ: A BaseType subclass.
|
typ: A BaseType subclass.
|
||||||
value: (readonly property) The currently valid, most important value.
|
value: (readonly property) The currently valid, most important value.
|
||||||
_values: A namedtuple with the values on different layers, with the
|
_values: An OrderedDict with the values on different layers, with the
|
||||||
most significant layer first.
|
most significant layer first.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -43,8 +41,9 @@ class SettingValue:
|
|||||||
default: Raw value to set.
|
default: Raw value to set.
|
||||||
"""
|
"""
|
||||||
self.typ = typ()
|
self.typ = typ()
|
||||||
self._values = ValueLayers(None, None, None)
|
self._values = OrderedDict.fromkeys(['temp', 'conf', 'default'])
|
||||||
self._values.default = default
|
self._values['default'] = default
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""Get raw string value."""
|
"""Get raw string value."""
|
||||||
@ -53,7 +52,7 @@ class SettingValue:
|
|||||||
@property
|
@property
|
||||||
def value(self):
|
def value(self):
|
||||||
"""Get the currently valid value."""
|
"""Get the currently valid value."""
|
||||||
for val in self._values:
|
for val in self._values.values():
|
||||||
if val is not None:
|
if val is not None:
|
||||||
return val
|
return val
|
||||||
else:
|
else:
|
||||||
@ -74,8 +73,8 @@ class SettingValue:
|
|||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
layer: The layer to set the value on, an element name of the
|
layer: The layer to set the value on, an element name of the
|
||||||
ValueLayers namedtuple.
|
ValueLayers dict.
|
||||||
value: The value to set.
|
value: The value to set.
|
||||||
"""
|
"""
|
||||||
self.typ.validate(value)
|
self.typ.validate(value)
|
||||||
setattr(self._values, layer, value)
|
self._values[layer] = value
|
||||||
|
Loading…
Reference in New Issue
Block a user