X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/28d85f12957a4b8609b4f419e70dd42a22b57765..e84c309296f53c13169153b46d8ba8911f6cffa8:/librarian/fb2.py diff --git a/librarian/fb2.py b/librarian/fb2.py index a1cece4..6dd1c35 100644 --- a/librarian/fb2.py +++ b/librarian/fb2.py @@ -3,9 +3,12 @@ # This file is part of Librarian, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # +from __future__ import unicode_literals + import os.path from copy import deepcopy from lxml import etree +import six from librarian import functions, OutputFile from .epub import replace_by_verse @@ -17,10 +20,11 @@ functions.reg_person_name() def sectionify(tree): """Finds section headers and adds a tree of _section tags.""" - sections = ['naglowek_czesc', - 'naglowek_akt', 'naglowek_rozdzial', 'naglowek_scena', - 'naglowek_podrozdzial'] - section_level = dict((v,k) for (k,v) in enumerate(sections)) + sections = [ + 'naglowek_czesc', + 'naglowek_akt', 'naglowek_rozdzial', 'naglowek_scena', + 'naglowek_podrozdzial'] + section_level = dict((v, k) for (k, v) in enumerate(sections)) # We can assume there are just subelements an no text at section level. for level, section_name in reversed(list(enumerate(sections))): @@ -61,6 +65,6 @@ def transform(wldoc, verbose=False, result = document.transform(style) - return OutputFile.from_string(unicode(result).encode('utf-8')) + return OutputFile.from_bytes(six.text_type(result).encode('utf-8')) # vim:et