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
 
  13 functions.reg_substitute_entities()
 
  15 def transform(wldoc, verbose=False,
 
  16               cover=None, flags=None):
 
  17     """ produces a FB2 file
 
  19     cover: a cover.Cover object or True for default
 
  20     flags: less-advertising, working-copy
 
  23     document = deepcopy(wldoc)
 
  28             document.edoc.getroot().set(flag, 'yes')
 
  30     style_filename = os.path.join(os.path.dirname(__file__), 'fb2/fb2.xslt')
 
  31     style = etree.parse(style_filename)
 
  33     result = document.transform(style)
 
  35     return OutputFile.from_string(unicode(result).encode('utf-8'))