aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx/__init__.py
blob: bb268268d89af4e293bcdb5d9d8d03cae1a89b72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import zipfile

from ..results import Result
from .xmlparser import parse_xml
from .document_xml import read_document_xml_element


_namespaces = [
    ("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"),
]


def read(fileobj):
    zip_file = zipfile.ZipFile(fileobj)
    document_fileobj = zip_file.open("word/document.xml")
    document_xml = parse_xml(document_fileobj, _namespaces)
    return read_document_xml_element(document_xml)