1 # -*- coding: utf-8 -*-
3 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
7 from copy import deepcopy
10 from librarian import functions, OutputFile
11 from .epub import replace_by_verse
14 functions.reg_substitute_entities()
16 def transform(wldoc, verbose=False,
17 cover=None, flags=None):
18 """ produces a FB2 file
20 cover: a cover.Cover object or True for default
21 flags: less-advertising, working-copy
24 document = deepcopy(wldoc)
29 document.edoc.getroot().set(flag, 'yes')
31 style_filename = os.path.join(os.path.dirname(__file__), 'fb2/fb2.xslt')
32 style = etree.parse(style_filename)
34 replace_by_verse(document.edoc)
36 result = document.transform(style)
38 return OutputFile.from_string(unicode(result).encode('utf-8'))