Add more property aliases and do them properly (no more lambdas and
string lookups) which means we can remove `_alias`. This commit also
defines `__slots__` for all classes which should prevent assignation of
invalid attributes with an AttributeError (more friendly than silently
doing the wrong thing). Finally, it cleans up all the property defs to
use Ben's preferred decorator style.
This commit is contained in:
Dave Jones
2015-10-17 20:29:33 +01:00
parent cc79749758
commit 6583223299
3 changed files with 138 additions and 74 deletions

View File

@@ -47,7 +47,11 @@ class GPIODevice(object):
The GPIO pin (in BCM numbering) that the device is connected to. If
this is `None` a `GPIODeviceError` will be raised.
"""
__slots__ = ('_pin', '_active_state', '_inactive_state')
def __init__(self, pin=None):
super(GPIODevice, self).__init__()
# self._pin must be set before any possible exceptions can be raised
# because it's accessed in __del__. However, it mustn't be given the
# value of pin until we've verified that it isn't already allocated