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

from .. import documents
from ..results import Result
from .xmlparser import parse_xml, node_types
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), [])