import os
import re
import traceback
import uuid
from typing import List, Union
import aiohttp
import ujson as json
from tabulate import tabulate
from config import Config
web_render = Config('web_render')
class ImageTable:
def __init__(self, data, headers):
self.data = data
self.headers = headers
async def image_table_render(table: Union[ImageTable, List[ImageTable]]):
if not web_render:
return False
try:
tblst = []
if isinstance(table, ImageTable):
table = [table]
max_width = 500
for tbl in table:
d = []
for row in tbl.data:
cs = []
for c in row:
cs.append(re.sub(r'\n', '
', c))
d.append(cs)
w = len(tbl.headers) * 500
if w > max_width:
max_width = w
tblst.append(re.sub(r'