Correct linting errors and tests
parent
e5a18757ba
commit
9499f2e6ee
|
@ -12,7 +12,9 @@ class ValidList(list):
|
||||||
|
|
||||||
|
|
||||||
class PinConfig(config.ConfigValue):
|
class PinConfig(config.ConfigValue):
|
||||||
tuple_pinconfig = namedtuple("PinConfig", ("event", "active", "bouncetime", "options"))
|
tuple_pinconfig = namedtuple(
|
||||||
|
"PinConfig", ("event", "active", "bouncetime", "options")
|
||||||
|
)
|
||||||
|
|
||||||
valid_events = ValidList(
|
valid_events = ValidList(
|
||||||
["play_pause", "prev", "next", "volume_up", "volume_down"]
|
["play_pause", "prev", "next", "volume_up", "volume_down"]
|
||||||
|
@ -31,7 +33,8 @@ class PinConfig(config.ConfigValue):
|
||||||
|
|
||||||
value = value.split(",")
|
value = value.split(",")
|
||||||
|
|
||||||
if len(value) < 3: # At least Event, Active and Bouncetime settings required
|
# At least Event, Active and Bouncetime settings required
|
||||||
|
if len(value) < 3:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
event, active, bouncetime = value[0:3]
|
event, active, bouncetime = value[0:3]
|
||||||
|
@ -64,6 +67,6 @@ class PinConfig(config.ConfigValue):
|
||||||
def serialize(self, value, display=False):
|
def serialize(self, value, display=False):
|
||||||
if value is None:
|
if value is None:
|
||||||
return ""
|
return ""
|
||||||
options = ",".join({f'{k}={v}' for k, v in value.options.items()})
|
options = ",".join({f"{k}={v}" for k, v in value.options.items()})
|
||||||
value = f"{value.event},{value.active},{value.bouncetime}"
|
value = f"{value.event},{value.active},{value.bouncetime},{options}"
|
||||||
return types.encode(value)
|
return types.encode(value)
|
||||||
|
|
|
@ -76,4 +76,4 @@ def test_pinconfig_serialize():
|
||||||
schema = ext.get_config_schema()
|
schema = ext.get_config_schema()
|
||||||
|
|
||||||
bcm1 = schema["bcm1"].deserialize("volume_up,active_low,30,steps=1")
|
bcm1 = schema["bcm1"].deserialize("volume_up,active_low,30,steps=1")
|
||||||
assert bcm1.serialize() == "volume_up,active_low,30,steps=1"
|
assert schema["bcm1"].serialize(bcm1) == "volume_up,active_low,30,steps=1"
|
||||||
|
|
Loading…
Reference in New Issue