aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx/__init__.py
blob: 6e1013b5472728052290e504e71c3aca30a0b6ba (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 Result(read_document_xml_element(document_xml), [])