keyboard.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:vyper 作者: CrispyBacon1999 项目源码 文件源码
def load_from_excel(self, file, click_type='callback_data', default_click='default_blank_callback'):
        buttons = []
        wb = open_workbook(file, formatting_info=True)
        sheet = wb.sheet_by_name("Sheet1")
        print('Reading keyboard from:', file)
        for col in range(sheet.ncols):
            text = data = ''
            buttons.append([])
            for row in range(sheet.nrows):
                cell = sheet.cell(row, col)
                fmt = wb.xf_list[cell.xf_index]
                border = fmt.border
                has_bottom = bool(border.bottom_line_style)
                if not has_bottom:
                    text = str(cell.value)
                else:
                    data = str(cell.value)
                    if data and text:
                        buttons[col].append({'text': text, click_type: data})
                    else:
                        buttons[col].append({'text': data, click_type: default_click})
                    text = ''
                    data = ''

            if not has_bottom and text:
                raise ExcelNoBottomException('Cell({0},{1}) has no bottom border.'.format(row, col))

        # Flip columns and rows
        buttons = list(map(list, itertools.zip_longest(*buttons)))
        buttons = [[button for button in row if button is not None] for row in buttons]
        self.keyboard['inline_keyboard'] = buttons
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号