Change CompositeDevice to reject invalid identifiers

Also updated StatusBoard and StatusZero to reject duplicate identifiers
(namedtuple doesn't pick 'em up because they're passed in a dict and
thus the dups are squashed prior to the call). Added tests for all the
relevant stuff.
This commit is contained in:
Dave Jones
2017-06-25 20:44:13 +01:00
parent c9857d55ce
commit 56f2152daf
4 changed files with 43 additions and 20 deletions

View File

@@ -330,8 +330,7 @@ class CompositeDevice(Device):
raise CompositeDeviceBadDevice("%s doesn't inherit from Device" % dev)
self._named = frozendict(kwargs)
self._namedtuple = namedtuple('%sValue' % self.__class__.__name__, chain(
(str(i) for i in range(len(args))), self._order),
rename=True)
('device_%d' % i for i in range(len(args))), self._order))
def __getattr__(self, name):
# if _named doesn't exist yet, pretend it's an empty dict