Example #1
0
def _read_content_types_xml(fileobj):
    with open_zip(fileobj, "r") as zip_file:
        return xml.parse_xml(
            io.StringIO(zip_file.read_str("[Content_Types].xml")),
            [("ct",
              "http://schemas.openxmlformats.org/package/2006/content-types")],
        )
def images_have_alt_tags_if_available():
    image = documents.image(alt_text="It's a hat",
                            content_type="image/png",
                            open=lambda: io.BytesIO(b"abc"))
    result = convert_document_element_to_html(image)
    image_html = parse_xml(io.StringIO(result.value))
    assert_equal('It\'s a hat', image_html.attributes["alt"])
Example #3
0
def _read_relationships_xml(fileobj):
    with open_zip(fileobj, "r") as zip_file:
        return xml.parse_xml(
            io.StringIO(zip_file.read_str("word/_rels/document.xml.rels")),
            [("r",
              "http://schemas.openxmlformats.org/package/2006/relationships")],
        )
def images_have_alt_tags_if_available():
    image = documents.image(alt_text="It's a hat", content_type="image/png", open=lambda: io.BytesIO(b"abc"))
    result = convert_document_element_to_html(image)
    image_html = parse_xml(io.StringIO(result.value))
    assert_equal('It\'s a hat', image_html.attributes["alt"])
Example #5
0
def _parse_xml_string(string, namespace_mapping=None):
    return parse_xml(io.BytesIO(string), namespace_mapping)
def _parse_xml_string(string, namespace_mapping=None):
    return parse_xml(io.BytesIO(string), namespace_mapping)
def _read_content_types_xml(fileobj):
    with open_zip(fileobj, "r") as zip_file:
        return xml.parse_xml(
            io.StringIO(zip_file.read_str("[Content_Types].xml")),
            [("ct", "http://schemas.openxmlformats.org/package/2006/content-types")],
        )
def _read_relationships_xml(fileobj):
    with open_zip(fileobj, "r") as zip_file:
        return xml.parse_xml(
            io.StringIO(zip_file.read_str("word/_rels/document.xml.rels")),
            [("r", "http://schemas.openxmlformats.org/package/2006/relationships")],
        )