'Write the book in the :class:`OEBBook` object :param:`oeb` to a folder
at :param:`path`.'

def __call__(self, oeb, path):

    version = int(self.version[0])
    opfname = None
    if (os.path.splitext(path)[1].lower() == '.opf'):
        opfname = os.path.basename(path)
        path = os.path.dirname(path)
    if (not os.path.isdir(path)):
        os.mkdir(path)
    output = DirContainer(path, oeb.log)
    for item in oeb.manifest.values():
        output.write(item.href, str(item))
    if (version == 1):
        metadata = oeb.to_opf1()
    elif (version == 2):
        metadata = oeb.to_opf2(page_map=self.page_map)
    else:
        raise OEBError(('Unrecognized    OPF    version    %r' % self.version))
    pretty_print = self.pretty_print
    for (mime, (href, data)) in metadata.items():
        if (opfname and (mime == OPF_MIME)):
            href = opfname
        output.write(href, xml2str(data, pretty_print=pretty_print))
    return
