+ @classmethod
+ def import_xml_text(cls, text=u'', creator=None, previous_book=None,
+ *args, **kwargs):
+
+ texts = split_xml(text)
+ if previous_book:
+ instance = previous_book
+ else:
+ instance = cls(*args, **kwargs)
+ instance.save()
+
+ # if there are more parts, set the rest to empty strings
+ book_len = len(instance)
+ for i in range(book_len - len(texts)):
+ texts.append(u'pusta część %d' % (i + 1), u'')
+
+ i = 0
+ for i, (title, text) in enumerate(texts):
+ if not title:
+ title = u'część %d' % (i + 1)
+
+ slug = slughifi(title)
+
+ if i < book_len:
+ chunk = instance[i]
+ chunk.slug = slug
+ chunk.comment = title
+ chunk.save()
+ else:
+ chunk = instance.add(slug, title, creator, adjust_slug=True)
+
+ chunk.commit(text, author=creator)
+
+ return instance
+