'Produce OPF 2.0 representing the book\'s metadata and structure.
Returns a dictionary in which the keys are MIME types and the values
are tuples of (default) filenames and lxml.etree element structures.'

def to_opf2(self, page_map=False):

    results = {}
    package = etree.Element(OPF('package'), attrib={'version': '2.0', 'unique-identifier': self.uid.id}, nsmap={None: OPF2_NS})
    self.metadata.to_opf2(package)
    manifest = self.manifest.to_opf2(package)
    spine = self.spine.to_opf2(package)
    self.guide.to_opf2(package)
    results[OPF_MIME] = ('content.opf', package)
    (id, href) = self.manifest.generate('ncx', 'toc.ncx')
    etree.SubElement(manifest, OPF('item'), id=id, href=href, attrib={'media-type': NCX_MIME})
    spine.attrib['toc'] = id
    results[NCX_MIME] = (href, self._to_ncx())
    if (page_map and (len(self.pages) > 0)):
        (id, href) = self.manifest.generate('page-map', 'page-map.xml')
        etree.SubElement(manifest, OPF('item'), id=id, href=href, attrib={'media-type': PAGE_MAP_MIME})
        spine.attrib['page-map'] = id
        results[PAGE_MAP_MIME] = (href, self.pages.to_page_map())
    if (self.spine.page_progression_direction in {'ltr', 'rtl'}):
        spine.attrib['page-progression-direction'] = self.spine.page_progression_direction
    return results
