

@ensure_tag(['tr'])
def build_tr(tr, meta_data, row_spans):
    '\n    This will return a single tr element, with all tds already populated.\n    '
    tr_el = etree.Element('tr')
    w_namespace = get_namespace(tr, 'w')
    visited_nodes = []
    for el in tr:
        if (el in visited_nodes):
            continue
        visited_nodes.append(el)
        if (el.tag == ('%stc' % w_namespace)):
            v_merge = get_v_merge(el)
            if ((v_merge is not None) and (v_merge.get(('%sval' % w_namespace)) != 'restart')):
                continue
            texts = []
            for td_content in el:
                if (td_content in visited_nodes):
                    continue
                if is_li(td_content, meta_data):
                    li_nodes = get_single_list_nodes_data(td_content, meta_data)
                    (list_el, list_visited_nodes) = build_list(li_nodes, meta_data)
                    visited_nodes.extend(list_visited_nodes)
                    texts.append(etree.tostring(list_el))
                elif (td_content.tag == ('%stbl' % w_namespace)):
                    (table_el, table_visited_nodes) = build_table(td_content, meta_data)
                    visited_nodes.extend(table_visited_nodes)
                    texts.append(etree.tostring(table_el))
                elif (td_content.tag == ('%stcPr' % w_namespace)):
                    visited_nodes.append(td_content)
                    continue
                else:
                    text = get_element_content(td_content, meta_data, is_td=True)
                    texts.append(text)
            data = '<br />'.join((t for t in texts if (t is not None)))
            td_el = etree.XML(('<td>%s</td>' % data))
            colspan = get_grid_span(el)
            if (colspan > 1):
                td_el.set('colspan', ('%d' % colspan))
            v_merge = get_v_merge(el)
            if ((v_merge is not None) and (v_merge.get(('%sval' % w_namespace)) == 'restart')):
                rowspan = next(row_spans)
                td_el.set('rowspan', ('%d' % rowspan))
            tr_el.append(td_el)
    return tr_el

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