update R6 and rebuild at 9.28
This commit is contained in:
54
reviews/__pyfunc__/r6.py
Normal file
54
reviews/__pyfunc__/r6.py
Normal file
@@ -0,0 +1,54 @@
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
def create_array_table(data: list, border: list, cnt_p1: int, cnt_p2: int) -> str:
|
||||
STYLE_ARRAY_TABLE = "border-collapse: collapse;"
|
||||
STYLE_TD_TEMPLATE = "border: 1px solid black; width: 1.2em; height: 1.6rem; text-align: center; font-size: 1.3rem;"
|
||||
|
||||
def style_with_rborder(style: str):
|
||||
style += "border-right: 6px solid black;"
|
||||
return style
|
||||
|
||||
def style_with_p1(style: str):
|
||||
style += "background-color: lightgray;"
|
||||
return style
|
||||
def style_with_p2(style: str):
|
||||
style += "background-color: gray;"
|
||||
return style
|
||||
|
||||
if len(data) != len(border):
|
||||
return ""
|
||||
|
||||
soup = BeautifulSoup("", "html.parser")
|
||||
table = soup.new_tag('table', attrs={'style': STYLE_ARRAY_TABLE})
|
||||
tr = soup.new_tag('tr')
|
||||
|
||||
for i in range(len(data)):
|
||||
style = STYLE_TD_TEMPLATE
|
||||
if i < cnt_p1:
|
||||
style = style_with_p1(style)
|
||||
if border[i]:
|
||||
style = style_with_rborder(style)
|
||||
elif cnt_p1 <= i < cnt_p1 + cnt_p2:
|
||||
style = style_with_p2(style)
|
||||
if border[i]:
|
||||
style = style_with_rborder(style)
|
||||
else:
|
||||
if border[i]:
|
||||
style = style_with_rborder(style)
|
||||
td = soup.new_tag('td', attrs={'style': style})
|
||||
td.string = str(data[i])
|
||||
|
||||
tr.append(td)
|
||||
|
||||
table.append(tr)
|
||||
soup.append(table)
|
||||
|
||||
return str(soup)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user