Made the license notice a bit shorter in source code. Left the long version in script...
[librarian.git] / librarian / __init__.py
index 5997a4e..ca527f6 100644 (file)
@@ -1,5 +1,9 @@
 # -*- coding: utf-8 -*-
-# exception classes
+#
+# Copyright © 2008,2009,2010 Fundacja Nowoczesna Polska  
+#
+# This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
+# For full license text see COPYING or <http://www.gnu.org/licenses/agpl.html>  
 
 class ParseError(Exception):
     
@@ -85,4 +89,21 @@ def wrap_text(ocrtext, creation_date, bookinfo=DEFAULT_BOOKINFO):
         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)