# -*- coding: utf-8 -*-
-# exception classes
-
+#
+# This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
class ParseError(Exception):
def __init__(self, cause, message=None):
method='xml', encoding=unicode, pretty_print=True)
return u'<utwor>\n' + dcstring + u'\n<plain-text>\n' + ocrtext +\
- u'\n</plain-text>\n</utwor>';
\ No newline at end of file
+ u'\n</plain-text>\n</utwor>';
+
+
+def serialize_raw(element):
+ b = u'' + (element.text or '')
+
+ for child in element.iterchildren():
+ e = etree.tostring(child, method='xml', encoding=unicode, pretty_print=True)
+ b += e
+
+ return b
+
+SERIALIZERS = {
+ 'raw': serialize_raw,
+}
+
+def serialize_children(element, format='raw'):
+ return SERIALIZERS[format](element)