

def _get_document_data(f, image_handler=None):
    '\n    ``f`` is a ``ZipFile`` that is open\n    Extract out the document data, numbering data and the relationship data.\n    '
    if (image_handler is None):

        def image_handler(image_id, relationship_dict):
            return relationship_dict.get(image_id)
    document_xml = None
    numbering_xml = None
    relationship_xml = None
    styles_xml = None
    parser = etree.XMLParser(strip_cdata=False)
    (path, _) = os.path.split(f.filename)
    media = {
        
    }
    image_sizes = {
        
    }
    for item in f.infolist():
        if (item.filename == 'word/document.xml'):
            xml = f.read(item.filename)
            document_xml = etree.fromstring(xml, parser)
        elif (item.filename == 'word/numbering.xml'):
            xml = f.read(item.filename)
            numbering_xml = etree.fromstring(xml, parser)
        elif (item.filename == 'word/styles.xml'):
            xml = f.read(item.filename)
            styles_xml = etree.fromstring(xml, parser)
        elif (item.filename == 'word/_rels/document.xml.rels'):
            xml = f.read(item.filename)
            try:
                relationship_xml = etree.fromstring(xml, parser)
            except XMLSyntaxError:
                relationship_xml = etree.fromstring('<xml></xml>', parser)
        if item.filename.startswith('word/media/'):
            media[item.filename[len('word/'):]] = f.extract(item.filename, path)
    f.close()
    numbering_dict = get_numbering_info(numbering_xml)
    image_sizes = get_image_sizes(document_xml)
    relationship_dict = get_relationship_info(relationship_xml, media, image_sizes)
    styles_dict = get_style_dict(styles_xml)
    font_sizes_dict = defaultdict(int)
    if DETECT_FONT_SIZE:
        font_sizes_dict = get_font_sizes_dict(document_xml, styles_dict)
    meta_data = MetaData(numbering_dict=numbering_dict, relationship_dict=relationship_dict, styles_dict=styles_dict, font_sizes_dict=font_sizes_dict, image_handler=image_handler, image_sizes=image_sizes)
    return (document_xml, meta_data)

dataset/ETHPy150Open PolicyStat/docx2html/docx2html/core.py _get_document_data/original