aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx/comments_xml.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-07-03 12:16:50 +0100
committerMichael Williamson <mike@zwobble.org>2016-07-03 12:16:50 +0100
commit05d9ac1031dcf83c6d99fa2218ee45a6d7b4d746 (patch)
treec03911389cf037c2f71c55cf450647939e7710b4 /mammoth/docx/comments_xml.py
parentaf8cdba7bd607c85a67148af99231975a892f5e2 (diff)
Add reader for comments.xml
Diffstat (limited to 'mammoth/docx/comments_xml.py')
-rw-r--r--mammoth/docx/comments_xml.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/mammoth/docx/comments_xml.py b/mammoth/docx/comments_xml.py
new file mode 100644
index 0000000..9a92552
--- /dev/null
+++ b/mammoth/docx/comments_xml.py
@@ -0,0 +1,19 @@
+from .. import lists
+from .. import documents
+from .. import results
+
+
+def create_comments_reader(body_reader):
+ def read_comments_xml_element(element):
+ comment_elements = element.find_children("w:comment")
+ return results.combine(lists.map(_read_comment_element, comment_elements))
+
+
+ def _read_comment_element(element):
+ return body_reader.read_all(element.children).map(lambda body:
+ documents.comment(
+ comment_id=element.attributes["w:id"],
+ body=body
+ ))
+
+ return read_comments_xml_element