[scripts/supportedsites] update 'generate_output()'
use f-strings etc
This commit is contained in:
@@ -682,52 +682,50 @@ COLUMNS = (
|
|||||||
def generate_output(columns, categories, domains):
|
def generate_output(columns, categories, domains):
|
||||||
|
|
||||||
thead = []
|
thead = []
|
||||||
append = thead.append
|
thead.append("<tr>")
|
||||||
append("<tr>")
|
|
||||||
for column in columns:
|
for column in columns:
|
||||||
append(" <th>" + column[0] + "</th>")
|
thead.append(f" <th>{column[0]}</th>")
|
||||||
append("</tr>")
|
thead.append("</tr>")
|
||||||
|
|
||||||
tbody = []
|
tbody = []
|
||||||
append = tbody.append
|
|
||||||
|
|
||||||
for bcat, base in categories.items():
|
for bcat, base in categories.items():
|
||||||
|
|
||||||
if bcat and base:
|
if bcat and base:
|
||||||
name = BASE_MAP.get(bcat) or (bcat.capitalize() + " Instances")
|
name = BASE_MAP.get(bcat) or (bcat.capitalize() + " Instances")
|
||||||
append('\n<tr>\n <td colspan="4"><strong>' +
|
tbody.append(f"""
|
||||||
name + '</strong></td>\n</tr>')
|
<tr>
|
||||||
|
<td colspan="4"><strong>{name}</strong></td>
|
||||||
|
</tr>\
|
||||||
|
""")
|
||||||
clist = base.items()
|
clist = base.items()
|
||||||
else:
|
else:
|
||||||
clist = sorted(base.items(), key=category_key)
|
clist = sorted(base.items(), key=category_key)
|
||||||
|
|
||||||
for category, subcategories in clist:
|
for category, subcategories in clist:
|
||||||
append("<tr>")
|
tbody.append("<tr>")
|
||||||
for column in columns:
|
for column in columns:
|
||||||
domain = domains[category]
|
domain = domains[category]
|
||||||
content = column[2](bcat, category, subcategories, domain)
|
content = column[2](bcat, category, subcategories, domain)
|
||||||
append(" <td>" + content + "</td>")
|
tbody.append(f" <td>{content}</td>")
|
||||||
append("</tr>")
|
tbody.append("</tr>")
|
||||||
|
|
||||||
TEMPLATE = """# Supported Sites
|
NL = "\n"
|
||||||
|
GENERATOR = "/".join(os.path.normpath(__file__).split(os.sep)[-2:])
|
||||||
|
return f"""\
|
||||||
|
# Supported Sites
|
||||||
|
|
||||||
<!-- auto-generated by {} -->
|
<!-- auto-generated by {GENERATOR} -->
|
||||||
Consider all listed sites to potentially be NSFW.
|
Consider all listed sites to potentially be NSFW.
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<thead valign="bottom">
|
<thead valign="bottom">
|
||||||
{}
|
{NL.join(thead)}
|
||||||
</thead>
|
</thead>
|
||||||
<tbody valign="top">
|
<tbody valign="top">
|
||||||
{}
|
{NL.join(tbody)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
"""
|
"""
|
||||||
return TEMPLATE.format(
|
|
||||||
"/".join(os.path.normpath(__file__).split(os.sep)[-2:]),
|
|
||||||
"\n".join(thead),
|
|
||||||
"\n".join(tbody),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
categories, domains = build_extractor_list()
|
categories, domains = build_extractor_list()
|
||||||
|
|||||||
Reference in New Issue
Block a user