+ # WTF xpath may be unused; also: too broad except
+ unmerged.append(repr((key, xpath, e)))
+
+ return unmerged
+
+ def clean_ed_note(self):
+ """ deletes forbidden tags from nota_red """
+
+ forbidden_tags = ('pa', 'pe', 'pr', 'pt', 'begin', 'end', 'motyw')
+ for node in self.edoc.xpath('|'.join('//nota_red//%s' % tag for tag in forbidden_tags)):
+ tail = node.tail
+ node.clear()
+ node.tag = 'span'
+ node.tail = tail
+
+ # Converters
+
+ def as_html(self, *args, **kwargs):
+ from librarian import pyhtml as html
+ return html.transform(self, *args, **kwargs)
+
+ def as_text(self, *args, **kwargs):
+ from librarian import text
+ return text.transform(self, *args, **kwargs)
+
+ def as_epub(self, *args, **kwargs):
+ from librarian import epub
+ return epub.transform(self, *args, **kwargs)
+
+ def as_pdf(self, *args, **kwargs):
+ from librarian import pypdf
+ return pypdf.EduModulePDFFormat(self).build(*args, **kwargs)
+
+ def as_mobi(self, *args, **kwargs):
+ from librarian import mobi
+ return mobi.transform(self, *args, **kwargs)
+
+ def as_fb2(self, *args, **kwargs):
+ from librarian import fb2
+ return fb2.transform(self, *args, **kwargs)
+
+ def as_cover(self, cover_class=None, *args, **kwargs):
+ if cover_class is None:
+ from librarian.styles.wolnelektury.cover import WLCover
+ cover_class = WLCover
+ return cover_class(self.book_info, *args, **kwargs).output_file()
+
+ def save_output_file(self, output_file, output_path=None, output_dir_path=None, make_author_dir=False, ext=None):
+ if output_dir_path:
+ save_path = output_dir_path
+ if make_author_dir:
+ save_path = os.path.join(save_path, unicode(self.book_info.author).encode('utf-8'))
+ save_path = os.path.join(save_path, self.book_info.uri.slug)
+ if ext:
+ save_path += '.%s' % ext
+ else:
+ save_path = output_path