mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2026-01-30 21:27:17 +00:00
Move device construction into dict-comprehension
Shouldn't make any difference to object lifetimes, but makes the constructor similar to all others (which don't seem to have the same issue?)
This commit is contained in:
@@ -834,11 +834,10 @@ class StatusZero(LEDBoard):
|
|||||||
dup, count = Counter(labels).most_common(1)[0]
|
dup, count = Counter(labels).most_common(1)[0]
|
||||||
if count > 1:
|
if count > 1:
|
||||||
raise ValueError("Duplicate label %s" % dup)
|
raise ValueError("Duplicate label %s" % dup)
|
||||||
strips = OrderedDict()
|
super(StatusZero, self).__init__(_order=labels, **{
|
||||||
for (green, red), label in zip(pins, labels):
|
label: LEDBoard(red=red, green=green, _order=('red', 'green'), **kwargs)
|
||||||
strips[label] = LEDBoard(red=red, green=green,
|
for (green, red), label in zip(pins, labels)
|
||||||
_order=('red', 'green'), **kwargs)
|
})
|
||||||
super(StatusZero, self).__init__(_order=strips.keys(), **strips)
|
|
||||||
|
|
||||||
|
|
||||||
class StatusBoard(CompositeOutputDevice):
|
class StatusBoard(CompositeOutputDevice):
|
||||||
@@ -882,14 +881,14 @@ class StatusBoard(CompositeOutputDevice):
|
|||||||
dup, count = Counter(labels).most_common(1)[0]
|
dup, count = Counter(labels).most_common(1)[0]
|
||||||
if count > 1:
|
if count > 1:
|
||||||
raise ValueError("Duplicate label %s" % dup)
|
raise ValueError("Duplicate label %s" % dup)
|
||||||
strips = OrderedDict()
|
super(StatusBoard, self).__init__(_order=labels, **{
|
||||||
for (green, red, button), label in zip(pins, labels):
|
label: CompositeOutputDevice(
|
||||||
strips[label] = CompositeOutputDevice(
|
|
||||||
button=Button(button),
|
button=Button(button),
|
||||||
lights=LEDBoard(
|
lights=LEDBoard(
|
||||||
red=red, green=green, _order=('red', 'green'), **kwargs
|
red=red, green=green, _order=('red', 'green'), **kwargs
|
||||||
), _order=('button', 'lights'))
|
), _order=('button', 'lights'))
|
||||||
super(StatusBoard, self).__init__(_order=strips.keys(), **strips)
|
for (green, red, button), label in zip(pins, labels)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
class SnowPi(LEDBoard):
|
class SnowPi(LEDBoard):
|
||||||
|
|||||||
Reference in New Issue
Block a user