blob: 5e4ea4e92443565463213f35e1d12f1d1bd00569 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import functools
from .. import lists
from .. import documents
from .. import results
def _read_notes(note_type, element, body_reader):
def read_notes_xml_element(element):
note_elements = lists.filter(
_is_note_element,
element.find_children("w:" + note_type),
)
return results.combine(lists.map(_read_note_element, note_elements))
def _is_note_element(element):
return element.attributes.get("w:type") not in ["continuationSeparator", "separator"]
def _read_note_element(element):
return body_reader.read_all(element.children).map(lambda body:
documents.note(
note_type=note_type,
note_id=element.attributes["w:id"],
body=body
))
return read_notes_xml_element(element)
read_footnotes_xml_element = functools.partial(_read_notes, "footnote")
read_endnotes_xml_element = functools.partial(_read_notes, "endnote")
|