summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-14 16:26:35 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-14 16:26:35 +0000
commitf1791fd544d01c118951fdca96b63a151d808941 (patch)
tree397e1a122f826ab87f0b23ad6cbf2ce355390034
parent90a19c890a3634f9ba8d8435af04982f9a8b76da (diff)
Don't drop result messages
-rw-r--r--mammoth/__init__.py4
-rw-r--r--mammoth/results.py6
2 files changed, 4 insertions, 6 deletions
diff --git a/mammoth/__init__.py b/mammoth/__init__.py
index 1fca3d6..92278f7 100644
--- a/mammoth/__init__.py
+++ b/mammoth/__init__.py
@@ -3,6 +3,4 @@ from . import docx, conversion
def convert_to_html(fileobj):
- document = docx.read(fileobj).value
- html = conversion.convert_document_element_to_html(document).value
- return Result(html, [])
+ return docx.read(fileobj).bind(conversion.convert_document_element_to_html)
diff --git a/mammoth/results.py b/mammoth/results.py
index ab29b25..b4bedbd 100644
--- a/mammoth/results.py
+++ b/mammoth/results.py
@@ -9,9 +9,9 @@ class Result(object):
def map(self, func):
return Result(func(self.value), self.messages)
- #~ def bind(self, func):
- #~ result = func(self.value)
- #~ return Result(result.value, self.messages + result.messages)
+ def bind(self, func):
+ result = func(self.value)
+ return Result(result.value, self.messages + result.messages)
Message = collections.namedtuple("Message", ["type", "message"])