X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5913c54d19b8f6775633176032161d49f9b2f1aa..ad2f309daa381e9a7a2b7a8a17ef494b60f838b2:/src/catalogue/xml_tools.py diff --git a/src/catalogue/xml_tools.py b/src/catalogue/xml_tools.py index 242714b6..917e62ac 100644 --- a/src/catalogue/xml_tools.py +++ b/src/catalogue/xml_tools.py @@ -1,4 +1,6 @@ -# -*- coding: utf-8 -*- +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# from copy import deepcopy import re @@ -60,7 +62,7 @@ def add_trim_begin(text): master.insert(0, trim_tag) trim_tag.tail = '\n\n\n' + (master.text or '') master.text = '\n' - return unicode(etree.tostring(e, encoding="utf-8"), 'utf-8') + return str(etree.tostring(e, encoding="utf-8"), 'utf-8') def add_trim_end(text): @@ -79,7 +81,7 @@ def add_trim_end(text): prev.tail = (prev.tail or '') + '\n\n\n' else: master.text = (master.text or '') + '\n\n\n' - return unicode(etree.tostring(e, encoding="utf-8"), 'utf-8') + return str(etree.tostring(e, encoding="utf-8"), 'utf-8') def split_xml(text): @@ -124,13 +126,13 @@ def split_xml(text): del parent[0] element, parent = parent, parent.getparent() chunks[:0] = [[name, - unicode(etree.tostring(copied, encoding='utf-8'), 'utf-8') + str(etree.tostring(copied, encoding='utf-8'), 'utf-8') ]] parts = src.findall('.//naglowek_rozdzial') chunks[:0] = [[u'początek', - unicode(etree.tostring(src, encoding='utf-8'), 'utf-8') + str(etree.tostring(src, encoding='utf-8'), 'utf-8') ]] for ch in chunks[1:]: