def children(self, filter=Filter()): """ Get only the I{direct} or non-attribute content. @param filter: A filter to constrain the result. @type filter: L{Filter} @return: A list tuples: (child, ancestry) @rtype: [(L{SchemaObject}, [L{SchemaObject},..]),..] """ result = [] for child, ancestry in self: if not child.isattr() and child in filter: result.append((child, ancestry)) return result
def append(cls, d, s, filter=Filter()): """ Append schema object's from B{s}ource list to the B{d}estination list while applying the filter. @param d: The destination list. @type d: list @param s: The source list. @type s: list @param filter: A filter that allows items to be appended. @type filter: L{Filter} """ for item in s: if item in filter: d.append(item)
def prepend(cls, d, s, filter=Filter()): """ Prepend schema object's from B{s}ource list to the B{d}estination list while applying the filter. @param d: The destination list. @type d: list @param s: The source list. @type s: list @param filter: A filter that allows items to be prepended. @type filter: L{Filter} """ i = 0 for x in s: if x in filter: d.insert(i, x) i += 1
def content(self, collection=None, filter=Filter(), history=None): """ Get a I{flattened} list of this nodes contents. @param collection: A list to fill. @type collection: list @param filter: A filter used to constrain the result. @type filter: L{Filter} @param history: The history list used to prevent cyclic dependency. @type history: list @return: The filled list. @rtype: list """ if collection is None: collection = [] if history is None: history = [] if self in history: return collection history.append(self) if self in filter: collection.append(self) for c in self.rawchildren: c.content(collection, filter, history[:]) return collection
def merge(self, other): SchemaObject.merge(self, other) filter = Filter(False, self.rawchildren) self.prepend(self.rawchildren, other.rawchildren, filter)