def IsExpandable(self):
     """An object is expandable when it is a node which has children and
     is a container object. 
     
     """
     if not isinstance(self.node, _Node):
         return False
     else:
         if len(self.node.children) > 0:
             return True
         else:
             return muppy._is_containerobject(self.node.o)
Example #2
0
        def IsExpandable(self):
            """An object is expandable when it is a node which has children and
            is a container object.

            """
            if not isinstance(self.node, _Node):
                return False
            else:
                if len(self.node.children) > 0:
                    return True
                else:
                    return muppy._is_containerobject(self.node.o)
    def _get_objects(self, ignore=[]):
        """Get all currently existing objects.

        XXX - ToDo: This method is a copy&paste from muppy.get_objects, but
        some modifications are applied. Specifically, it allows to ignore
        objects (which includes the current frame).

        keyword arguments
        ignore -- list of objects to ignore
        """
        def remove_ignore(objects, ignore=[]):
            # remove all objects listed in the ignore list
            res = []
            for o in objects:
                if not compat.object_in_list(o, ignore):
                    res.append(o)
            return res

        tmp = gc.get_objects()
        ignore.append(inspect.currentframe()) #PYCHOK change ignore
        ignore.append(self) #PYCHOK change ignore
        if hasattr(self, 'o0'): ignore.append(self.o0) #PYCHOK change ignore
        if hasattr(self, 'o1'): ignore.append(self.o1) #PYCHOK change ignore
        ignore.append(ignore) #PYCHOK change ignore
        ignore.append(remove_ignore) #PYCHOK change ignore
        # this implies that referenced objects are also ignored
        tmp = remove_ignore(tmp, ignore)
        res = []
        for o in tmp:
            # gc.get_objects returns only container objects, but we also want
            # the objects referenced by them
            refs = muppy.get_referents(o)
            for ref in refs:
                if not muppy._is_containerobject(ref):
                    # we already got the container objects, now we only add
                    # non-container objects
                    res.append(ref)
        res.extend(tmp)
        res = muppy._remove_duplicates(res)
        if ignore is not None:
            # repeat to filter out objects which may have been referenced
            res = remove_ignore(res, ignore)
        # manual cleanup, see comment above
        del ignore[:]
        return res
        def GetSubList(self):
            """This method is the point where further referrers are computed.
            
            Thus, the computation is done on-demand and only when needed.
            
            """
            sublist = []
            
            children = self.node.children
            if (len(children) == 0) and\
                    (muppy._is_containerobject(self.node.o)):
                self.node = self.reftree._get_tree(self.node.o, 1)
                self._clear_children()
                children = self.node.children

            for child in children:
                item = _ReferrerTreeItem(self.parentwindow, child, self.reftree)
                sublist.append(item)
            return sublist
Example #5
0
        def GetSubList(self):
            """This method is the point where further referrers are computed.

            Thus, the computation is done on-demand and only when needed.

            """
            sublist = []

            children = self.node.children
            if (len(children) == 0) and\
                    (muppy._is_containerobject(self.node.o)):
                self.node = self.reftree._get_tree(self.node.o, 1)
                self._clear_children()
                children = self.node.children

            for child in children:
                item = _ReferrerTreeItem(self.parentwindow, child,
                                         self.reftree)
                sublist.append(item)
            return sublist