def ancestors(self, recurs=True, context=None): yielded = set([self]) if context is None: context = InferenceContext() for stmt in self.bases: path = set(context.path) try: for baseobj in stmt.infer(context): if not isinstance(baseobj, logilab.astng.scoped_nodes.Class): # duh ? continue if baseobj in yielded: continue # cf xxx above yielded.add(baseobj) yield baseobj if recurs: for grandpa in baseobj.ancestors(True, context): if grandpa in yielded: continue # cf xxx above yielded.add(grandpa) yield grandpa except InferenceError: # XXX log error ? pass context.path = path
def ancestors(self, recurs=True, context=None): yielded = set([self]) if context is None: context = InferenceContext() for stmt in self.bases: path = set(context.path) try: for baseobj in stmt.infer(context): if not isinstance(baseobj, logilab.astng.scoped_nodes.Class): # duh ? continue if baseobj in yielded: continue # cf xxx above yielded.add(baseobj) yield baseobj if recurs: for grandpa in baseobj.ancestors(True, context): if grandpa in yielded: continue # cf xxx above yielded.add(grandpa) yield grandpa except InferenceError: # XXX log error ? pass context.path = path