Add pin_factory param to all devices

And some docs ...
This commit is contained in:
Dave Jones
2017-07-14 10:44:24 +01:00
parent 1ca017fc6d
commit 8958874a77
16 changed files with 619 additions and 196 deletions

View File

@@ -197,7 +197,11 @@ class Device(ValuesMixin, GPIOBase):
def __init__(self, **kwargs):
# Force pin_factory to be keyword-only, even in Python 2
self.pin_factory = kwargs.pop('pin_factory', Device.pin_factory)
pin_factory = kwargs.pop('pin_factory', None)
if pin_factory is None:
self.pin_factory = Device.pin_factory
else:
self.pin_factory = pin_factory
if kwargs:
raise TypeError("Device.__init__() got unexpected keyword "
"argument '%s'" % kwargs.popitem()[0])
@@ -281,8 +285,7 @@ class CompositeDevice(Device):
dev.close()
raise
self._all = args + tuple(kwargs[v] for v in self._order)
kwargs = {'pin_factory': pin_factory} if pin_factory is not None else {}
super(CompositeDevice, self).__init__(**kwargs)
super(CompositeDevice, self).__init__(pin_factory=pin_factory)
def __getattr__(self, name):
# if _named doesn't exist yet, pretend it's an empty dict