class AllElements(_MultipleElements): """Form: ref.elements(code) A reference to all elements of container, where code is elements' class code. """ _keyForm = base.packEnum(kAE.formAbsolutePosition) _kAll = base.packAbsoluteOrdinal(kAE.kAEAll) def __init__(self, wantcode, container): # An AllElements object is a wrapper around an UnkeyedElements object; when selecting one or more of these elements, the AllElements wrapper is skipped and the UnkeyedElements object is used as the 'container' for the new specifier. _PositionSpecifier.__init__(self, wantcode, UnkeyedElements(wantcode, container), self._kAll) def __repr__(self): return repr(self._container) def _packKey(self, codecs): return self._kAll def AEM_trueSelf( self ): # override default implementation to return the UnkeyedElements object stored inside of this AllElements instance return self._container def AEM_resolve(self, obj): return self._container.AEM_resolve(obj) # forward to UnkeyedElements
class _MultipleElements(_PositionSpecifier): """Base class for all multiple element specifiers.""" _kFirst = base.packAbsoluteOrdinal(kAE.kAEFirst) _kMiddle = base.packAbsoluteOrdinal(kAE.kAEMiddle) _kLast = base.packAbsoluteOrdinal(kAE.kAELast) _kAny = base.packAbsoluteOrdinal(kAE.kAEAny) first = property(lambda self: ElementByOrdinal(self.AEM_want, self, self. _kFirst, 'first'), doc="first --> element") middle = property(lambda self: ElementByOrdinal(self.AEM_want, self, self. _kMiddle, 'middle'), doc="middle --> element") last = property(lambda self: ElementByOrdinal(self.AEM_want, self, self. _kLast, 'last'), doc="last --> element") any = property( lambda self: ElementByOrdinal(self.AEM_want, self, self._kAny, 'any'), doc="any --> element") def byname(self, name): """byname(name) --> element""" return ElementByName(self.AEM_want, self, name) def byindex(self, index): """byindex(index) --> element""" return ElementByIndex(self.AEM_want, self, index) def byid(self, id): """byid(id) --> element""" return ElementByID(self.AEM_want, self, id) def byrange(self, start, stop): """byrange(start, stop) --> elements""" return ElementsByRange(self.AEM_want, self, (start, stop)) def byfilter(self, expression): """byfilter(start, expression) --> elements""" return ElementsByFilter(self.AEM_want, self, expression)