Пример #1
0
def test_dict_to_html():
    from bs4 import BeautifulSoup
    from collections import OrderedDict
    data = OrderedDict()
    data['A'] = 1
    data['B'] = 2
    data['C'] = [{'D': 3}, {'E': 4}]
    html = dict_to_html(data)
    soup = BeautifulSoup(html, 'html.parser')
    tr = soup.find_all('tr')
    sub_tr = tr[2].find_all('tr')

    actual = (len(tr), len(sub_tr))
    expected = (6, 3)

    assert actual == expected
Пример #2
0
    def _repr_html_(self):
        df = self.get_document_information()
        columns = df.columns.tolist()
        dict_info = df.set_index(columns[1]).to_dict()
        info = None
        header = None
        for key, value in dict_info.items():
            if key != 'label_ko':
                info = value
                keys = list(info.keys())
                header = ['', keys[0]]
                info.pop(keys[0])

        df = self.get_entity_information()
        columns = df.columns.tolist()
        df = df.drop(columns[0], axis=1).set_index(columns[1])
        info['Company name'] = df.loc['Entity iegistrant name'][0]

        return dict_to_html(info, header=header)
Пример #3
0
 def _repr_html_(self):
     return dict_to_html(self.to_dict(),
                         exclude=['pages'],
                         header=['Label', 'Data'])
Пример #4
0
 def _repr_html_(self) -> str:
     return dict_to_html(self.to_dict(), header=['Label', 'Data'])
Пример #5
0
 def _repr_html_(self):
     return dict_to_html(self.to_dict(summary=False), header=['Label', 'Data'])