- # XX ideally these would point a frame higher on the stack.
- prefix = self.__prefix
- if prefix is not None:
- raise InvirtConfigError('missing configuration variable %s%s'
- % (prefix, key))
- else:
- raise AttributeError("anonymous struct has no member '%s'"
- % (key,))
- def __iter__(self):
- for i in self.__keys:
- yield i
+ try:
+ return self[key]
+ except KeyError:
+ if self.__default is None:
+ # XX ideally these would point a frame higher on the stack.
+ prefix = self.__prefix
+ if prefix is not None:
+ raise InvirtConfigError('missing configuration variable '
+ '%s%s' % (prefix, key))
+ else:
+ raise AttributeError("anonymous struct has no member '%s'"
+ % (key,))
+ else:
+ return struct({}, '', self.__default)