aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mammoth/docx/__init__.py2
-rw-r--r--mammoth/lists.py13
2 files changed, 3 insertions, 12 deletions
diff --git a/mammoth/docx/__init__.py b/mammoth/docx/__init__.py
index d944a2d..47e7a21 100644
--- a/mammoth/docx/__init__.py
+++ b/mammoth/docx/__init__.py
@@ -31,7 +31,7 @@ def _read_notes(zip_file, body_readers):
endnotes = _try_read_entry_or_default(
zip_file, "word/endnotes.xml", read_endnotes_xml, default=empty_result)
- return results.combine([footnotes, endnotes]).map(lists.collect)
+ return results.combine([footnotes, endnotes]).map(lists.flatten)
def _read_document(zip_file, body_readers, notes):
with zip_file.open("word/document.xml") as document_fileobj:
diff --git a/mammoth/lists.py b/mammoth/lists.py
index e8477cb..db1f9ca 100644
--- a/mammoth/lists.py
+++ b/mammoth/lists.py
@@ -1,19 +1,10 @@
import sys
-def collect(values):
- result = []
- _collect(values, result)
- return result
+def flatten(values):
+ return flat_map(lambda x: x, values)
-def _collect(values, result):
- for value in values:
- if isinstance(value, list):
- _collect(value, result)
- elif value is not None:
- result.append(value)
-
def unique(values):
output = []
seen = set()