changed interpolation to format string

This commit is contained in:
scuti 2024-10-12 09:17:04 -07:00
parent 4c6310343d
commit 3496759430
2 changed files with 10 additions and 5 deletions

View File

@ -1,13 +1,13 @@
import sqlite3 as sql import sqlite3 as sql
import subprocess import subprocess
# get all maps in database
def getmaps(database): def getmaps(database):
output = [] output = []
con = sql.connect(database) con = sql.connect(database)
with con: with con:
cursor = con.cursor() cursor = con.cursor()
try: try:
# get all maps in database
cursor.execute("select distinct mapid from Cts_times;") cursor.execute("select distinct mapid from Cts_times;")
output = cursor.fetchall() output = cursor.fetchall()
except sql.Error: except sql.Error:
@ -47,7 +47,12 @@ def main():
filename = ("./output/maps/%s.html" % map_name) filename = ("./output/maps/%s.html" % map_name)
with open(filename, 'w+') as fout: with open(filename, 'w+') as fout:
title = map_name title = map_name
fout.write(template % (title, map_name, table)) fout.write(template.format(
title=title,
map_name=map_name,
table=table)
)
# fout.write(template % (title, map_name, table))
pass pass
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- %s = map name --> <!-- %s = map name -->
<title>%s - Leaderboards - Minimal Working Example</title> <title>{title} - Leaderboards - Minimal Working Example</title>
<link href="/style.css" rel="stylesheet" type="text/css" media="all"> <link href="/style.css" rel="stylesheet" type="text/css" media="all">
<!-- <link href="../style.css" rel="stylesheet" type="text/css" media="all"> --> <!-- <link href="../style.css" rel="stylesheet" type="text/css" media="all"> -->
<link href="../leaderboard.css" rel="stylesheet" type="text/css" media="all"> <link href="../leaderboard.css" rel="stylesheet" type="text/css" media="all">
@ -12,10 +12,10 @@
<body> <body>
<!-- map name --> <!-- map name -->
<h1>%s</h1> <h1>{map_name}</h1>
<!-- code generated table goes here --> <!-- code generated table goes here -->
%s {table}
<footer> <footer>
<p>Page generated using <a href="https://notabug.org/scuti/xdfcgi">xdfcgi</a> by <a href="https://scuti.neocities.org/">scuti</a></p> <p>Page generated using <a href="https://notabug.org/scuti/xdfcgi">xdfcgi</a> by <a href="https://scuti.neocities.org/">scuti</a></p>