'Remove the item identified by name from this container. This removes all
references to the item in the OPF manifest, guide and spine as well as from
any internal caches.'

def remove_item(self, name, remove_from_guide=True):

    removed = set()
    for elem in self.opf_xpath(u'//opf:manifest/opf:item[@href]'):
        if (self.href_to_name(elem.get(u'href'), self.opf_name) == name):
            id_ = elem.get(u'id', None)
            if (id_ is not None):
                removed.add(id_)
            self.remove_from_xml(elem)
            self.dirty(self.opf_name)
    if removed:
        for spine in self.opf_xpath(u'//opf:spine'):
            tocref = spine.attrib.get(u'toc', None)
            if (tocref and (tocref in removed)):
                spine.attrib.pop(u'toc', None)
                self.dirty(self.opf_name)
        for item in self.opf_xpath(u'//opf:spine/opf:itemref[@idref]'):
            idref = item.get(u'idref')
            if (idref in removed):
                self.remove_from_xml(item)
                self.dirty(self.opf_name)
        for meta in self.opf_xpath(u'//opf:meta[@name="cover"    and    @content]'):
            if (meta.get(u'content') in removed):
                self.remove_from_xml(meta)
                self.dirty(self.opf_name)
    if remove_from_guide:
        for item in self.opf_xpath(u'//opf:guide/opf:reference[@href]'):
            if (self.href_to_name(item.get(u'href'), self.opf_name) == name):
                self.remove_from_xml(item)
                self.dirty(self.opf_name)
    path = self.name_path_map.pop(name, None)
    if (path and os.path.exists(path)):
        os.remove(path)
    self.mime_map.pop(name, None)
    self.parsed_cache.pop(name, None)
    self.dirtied.discard(name)
