+ return toc, chunk_counter, chars
+
+ # read metadata from the first file
+ input_xml = etree.parse(provider[slug])
+ metadata = input_xml.find('.//'+RDFNS('Description'))
+ if metadata is None:
+ raise NoDublinCore('Document has no DublinCore - which is required.')
+ book_info = BookInfo.from_element(input_xml)
+ metadata = etree.ElementTree(metadata)
+
+ # if output to dir, create the file
+ if output_dir is not None:
+ author = unicode(book_info.author)
+ author_dir = os.path.join(output_dir, author)
+ try:
+ os.makedirs(author_dir)
+ except OSError:
+ pass
+ output_file = open(os.path.join(author_dir, '%s.epub' % slug), 'w')