Beispiel #1
0
    async def render_to_wiki(self, base_url, token_str):
        ToolOutput.anchor('Wiki出力を開始')

        wiki = GitWikiUploader(base_url, token_str)

        page_list = await wiki.get_page_list()
        page_slug_list = [v['slug'] for v in page_list]

        d: DefaultDict[str, List[MasterDataWikiRenderUnit]] = defaultdict(list)
        ToolOutput.anchor('YAML読み込み')
        for k, table in self.master_loader.iter():
            ru = MasterDataWikiRenderUnit(table)
            ToolOutput.out(f'{ru.page_name} # {ru.data.excel_sheet_name}')
            d[ru.page_name].append(ru)
        ToolOutput.pop('OK')

        ToolOutput.anchor('書き出し')
        num = 1
        index = MarkdownTableRenderer(
            ['ID', 'Book', 'Client', 'Server', 'Planner', 'Table'])
        for p, rus in d.items():
            ToolOutput.anchor(p)
            u = IndentString()
            for r in rus:
                u.add(r.render())
                idx = r.render_index()
                idx['ID'] = str(num)
                num += 1
                index.append(idx)

            if p in page_slug_list:
                ToolOutput.print(f'{p}更新します')
                await wiki.update_page(content=u.render(), page_name=p)
            else:
                ToolOutput.print(f'{p}作成します')
                await wiki.create_page(content=u.render(), page_name=p)
            ToolOutput.pop('OK')

        ix = self.render_index(index)

        index_title = 'MasterData/☆INDEX☆'
        if index_title in page_slug_list:
            ToolOutput.print(f'{index_title}更新します')
            await wiki.update_page(content=ix.render(), page_name=index_title)
        else:
            ToolOutput.print(f'{index_title}作成します')
            await wiki.create_page(content=ix.render(), page_name=index_title)

        ToolOutput.pop('OK')
Beispiel #2
0
    def render(self):
        body = IndentString()
        body.add(self.render_header())
        body.add(self.render_units())

        return body.render()