aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mammoth/conversion.py6
-rw-r--r--mammoth/docx/body_xml.py10
-rw-r--r--mammoth/docx/files.py4
3 files changed, 6 insertions, 14 deletions
diff --git a/mammoth/conversion.py b/mammoth/conversion.py
index 185225d..dca86aa 100644
--- a/mammoth/conversion.py
+++ b/mammoth/conversion.py
@@ -7,6 +7,7 @@ import random
from . import documents, results, html_paths, images, writers
from .html_generation import HtmlGenerator, satisfy_html_path, append_html_path
+from .docx.files import InvalidFileReferenceError
def convert_document_element_to_html(element,
@@ -78,7 +79,10 @@ class _DocumentConverter(documents.ElementVisitor):
)
def visit_image(self, image):
- self._convert_image(image, self._html_generator)
+ try:
+ self._convert_image(image, self._html_generator)
+ except InvalidFileReferenceError as error:
+ self._messages.append(results.warning(str(error)))
def visit_document(self, document):
self._visit_all(document.children)
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py
index 2b04985..680dede 100644
--- a/mammoth/docx/body_xml.py
+++ b/mammoth/docx/body_xml.py
@@ -4,7 +4,6 @@ from .. import documents
from .. import results
from .. import lists
from .xmlparser import node_types
-from .files import InvalidFileReferenceError
def reader(numbering=None,
@@ -202,13 +201,8 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
return _read_image(lambda: _find_blip_image(element), alt_text)
def _read_image(find_image, alt_text):
- try:
- image_path, open_image = find_image()
- except InvalidFileReferenceError as error:
- return _empty_result_with_messages([results.warning(str(error))])
-
+ image_path, open_image = find_image()
content_type = content_types.find_content_type(image_path)
-
image = documents.image(alt_text=alt_text, content_type=content_type, open=open_image)
if content_type in ["image/png", "image/gif", "image/jpeg", "image/svg+xml", "image/tiff"]:
@@ -245,8 +239,6 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
def open_image():
return files.open(image_path)
- files.verify(image_path)
-
return image_path, open_image
def read_imagedata(element):
diff --git a/mammoth/docx/files.py b/mammoth/docx/files.py
index dc5146e..61cf8d5 100644
--- a/mammoth/docx/files.py
+++ b/mammoth/docx/files.py
@@ -14,10 +14,6 @@ class Files(object):
def __init__(self, base):
self._base = base
- def verify(self, uri):
- with self.open(uri):
- pass
-
def open(self, uri):
try:
if _is_absolute(uri):