def replace_self(self, new):
        update = new
        if not isinstance(new, Node):
            # `new` is a list; update first child.
            try:
                update = new[0]
            except IndexError:
                update = None
        if isinstance(update, Element):
            update.update_basic_atts(self)
        else:
            # `update` is a Text node or `new` is an empty list.
            # Assert that we aren't losing any attributes.
            for att in ('ids', 'names', 'classes', 'dupnames'):
                assert not self[att], \
                       'Losing "%s" attribute: %s' % (att, self[att])
        self.parent.replace(self, new)
Returns whether the toolbar action should be defined in the user
dataset/ETHPy150Open adieu/allbuttonspressed/docutils/nodes.py/Element.replace_self--crossover with--dataset/ETHPy150Open enthought/pyface/pyface/dock/dock_window.py/DockWindow.can_add_to_toolbar