From 8fc128a3e70465b82605b4c0bdb3d1a6ffe87ef6 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 1 Dec 2013 13:25:28 +0000 Subject: Read numbering properties in paragraph properties --- mammoth/docx/xmlparser.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'mammoth/docx/xmlparser.py') diff --git a/mammoth/docx/xmlparser.py b/mammoth/docx/xmlparser.py index efeafcf..50c80db 100644 --- a/mammoth/docx/xmlparser.py +++ b/mammoth/docx/xmlparser.py @@ -5,10 +5,13 @@ import xml.sax XmlElementBase = collections.namedtuple("XmlElement", ["name", "attributes", "children"]) class XmlElement(XmlElementBase): def find_child_or_null(self, name): + return self.find_child(name) or _null_xml_element + + def find_child(self, name): for child in self.children: if child.name == name: return child - return _null_xml_element + def find_children(self, name): return filter(lambda child: child.name == name, self.children) @@ -19,6 +22,9 @@ class NullXmlElement(object): def find_child_or_null(self, name): return self + + def find_child(self, name): + return None _null_xml_element = NullXmlElement() -- cgit v1.2.3