More tidying up

Ensure LEDCollection cleans up upon construction failure, rename some
internals to be a bit more obvious, rename PinGPIOUnsupported to
PinUnsupported, and some other stuff I've forgotten!
This commit is contained in:
Dave Jones
2016-10-21 14:54:34 +01:00
parent c570b8f09b
commit b0c807da19
9 changed files with 69 additions and 69 deletions

View File

@@ -211,20 +211,24 @@ class LEDCollection(CompositeOutputDevice):
initial_value = kwargs.pop('initial_value', False)
order = kwargs.pop('_order', None)
LEDClass = PWMLED if pwm else LED
super(LEDCollection, self).__init__(
*(
pin_or_collection
if isinstance(pin_or_collection, LEDCollection) else
LEDClass(pin_or_collection, active_high, initial_value)
for pin_or_collection in args
),
_order=order,
**{
name: pin_or_collection
if isinstance(pin_or_collection, LEDCollection) else
LEDClass(pin_or_collection, active_high, initial_value)
for name, pin_or_collection in kwargs.items()
})
try:
super(LEDCollection, self).__init__(
*(
pin_or_collection
if isinstance(pin_or_collection, LEDCollection) else
LEDClass(pin_or_collection, active_high, initial_value)
for pin_or_collection in args
),
_order=order,
**{
name: pin_or_collection
if isinstance(pin_or_collection, LEDCollection) else
LEDClass(pin_or_collection, active_high, initial_value)
for name, pin_or_collection in kwargs.items()
})
except:
self.close()
raise
leds = []
for item in self:
if isinstance(item, LEDCollection):