blob: b9b0362ac657444cf9ab3c5b91490b1d78232f7c (
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
|
from .. import lists
def create_reader(note_type):
def read_notes_xml_element(element):
note_elements = lists.filter(
_is_note_element,
element.find_children("w:" + note_type),
)
return 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 NoteElement(note_type, element.attributes["w:id"], element.children)
return read_notes_xml_element
class NoteElement(object):
def __init__(self, note_type, id, body):
self.note_type = note_type
self.id = id
self.body = body
read_footnotes_xml_element = create_reader("footnote")
read_endnotes_xml_element = create_reader("endnote")
|