def delete_embedded(self, rel=None, href=lambda _: True):
        """Removes an embedded resource from this document.

        Calling code should use this method to remove embedded resources
        instead of modifying ``embedded`` directly.

        The optional arguments, ``rel`` and ``href`` are used to select the
        embedded resources that will be removed. If neither of the optional
        arguments are given, this method removes every embedded resource from
        this document. If ``rel`` is given, only embedded resources for the
        matching link relationship type are removed. If ``href`` is given, only
        embedded resources with a ``self`` link matching ``href`` are deleted.
        If both ``rel`` and ``href`` are given, only embedded resources with
        matching ``self`` link for the matching link relationship type are
        removed.

        Arguments:

        - ``rel``: an optional string specifying the link relationship type of
                   the embedded resources to be removed.
        - ``href``: optionally, a string specifying the ``href`` of the
                    ``self`` links of the resources to be removed, or a
                    callable that returns true when its single argument matches
                    the ``href`` of the ``self`` link of one of the resources
                    to be removed.

        """
        if EMBEDDED_KEY not in self.o:
            return

        if rel is None:
            for rel in list(self.o[EMBEDDED_KEY].keys()):
                self.delete_embedded(rel, href)
            return

        if rel not in self.o[EMBEDDED_KEY]:
            return

        if callable(href):
            url_filter = href
        else:
            url_filter = lambda x: x == href

        rel_embeds = self.o[EMBEDDED_KEY][rel]

        if isinstance(rel_embeds, dict):
            del self.o[EMBEDDED_KEY][rel]

            if not self.o[EMBEDDED_KEY]:
                del self.o[EMBEDDED_KEY]
            return

        new_rel_embeds = []
        for embedded in list(rel_embeds):
            embedded_doc = Document(embedded, self.base_uri)
            if not url_filter(embedded_doc.url()):
                new_rel_embeds.append(embedded)

        if not new_rel_embeds:
            del self.o[EMBEDDED_KEY][rel]
        elif len(new_rel_embeds) == 1:
            self.o[EMBEDDED_KEY][rel] = new_rel_embeds[0]
        else:
            self.o[EMBEDDED_KEY][rel] = new_rel_embeds

        if not self.o[EMBEDDED_KEY]:
            del self.o[EMBEDDED_KEY]
def delete_embedded ( self , rel = None , href = lambda _ : True ) : if EMBEDDED_KEY not in self . o : return if rel is None : for rel in list ( self . o [ EMBEDDED_KEY ] . keys ( ) ) : self . delete_embedded ( rel , href ) return if rel not in self . o [ EMBEDDED_KEY ] : return if callable ( href ) : url_filter = href else : url_filter = lambda x : x == href rel_embeds = self . o [ EMBEDDED_KEY ] [ rel ] if isinstance ( rel_embeds , dict ) : del self . o [ EMBEDDED_KEY ] [ rel ] if not self . o [ EMBEDDED_KEY ] : del self . o [ EMBEDDED_KEY ] return new_rel_embeds = [ ] for embedded in list ( rel_embeds ) : embedded_doc = Document ( embedded , self . base_uri ) if not url_filter ( embedded_doc . url ( ) ) : new_rel_embeds . append ( embedded ) if not new_rel_embeds : del self . o [ EMBEDDED_KEY ] [ rel ] elif len ( new_rel_embeds ) == 1 : self . o [ EMBEDDED_KEY ] [ rel ] = new_rel_embeds [ 0 ] else : self . o [ EMBEDDED_KEY ] [ rel ] = new_rel_embeds if not self . o [ EMBEDDED_KEY ] : del self . o [ EMBEDDED_KEY ]
Removes an embedded resource from this document.

        Calling code should use this method to remove embedded resources
        instead of modifying ``embedded`` directly.

        The optional arguments, ``rel`` and ``href`` are used to select the
        embedded resources that will be removed. If neither of the optional
        arguments are given, this method removes every embedded resource from
        this document. If ``rel`` is given, only embedded resources for the
        matching link relationship type are removed. If ``href`` is given, only
        embedded resources with a ``self`` link matching ``href`` are deleted.
        If both ``rel`` and ``href`` are given, only embedded resources with
        matching ``self`` link for the matching link relationship type are
        removed.

        Arguments:

        - ``rel``: an optional string specifying the link relationship type of
                   the embedded resources to be removed.
        - ``href``: optionally, a string specifying the ``href`` of the
                    ``self`` links of the resources to be removed, or a
                    callable that returns true when its single argument matches
                    the ``href`` of the ``self`` link of one of the resources
                    to be removed.