style: ruff format

This commit is contained in:
2026-11-06 00:44:49 +01:00
parent 6fe6fe5a9f
commit 84310ed364
3 changed files with 13 additions and 5 deletions
+1
View File
@@ -7,6 +7,7 @@ from ..forge_data import ForgeData
log = logging.getLogger(__name__)
def debug_image(im: Image.Image) -> None:
im = im.resize((1280, 640)).convert("RGB")
+1
View File
@@ -10,6 +10,7 @@ from ..display import BLANK_IMG, FONT_1, FONT_2
log = logging.getLogger(__name__)
def generate_loading_image() -> None:
im = BLANK_IMG.copy()
+11 -5
View File
@@ -29,20 +29,23 @@ const int lengths[] = int[SENTENCE_COUNT](
log = logging.getLogger(__name__)
def read_mapping() -> dict[str, str]:
mapping = {' ': '0x20'}
mapping = {" ": "0x20"}
with CP437_FILE.open() as cp437:
for line in cp437:
if (match := re.match(r'.*// (0x\w\w), (.)$', line)):
if match := re.match(r".*// (0x\w\w), (.)$", line):
mapping[match.group(2)] = match.group(1)
return mapping
def read_sentences() -> list[str]:
if SENTENCES_FILE.exists():
return SENTENCES_FILE.read_text().splitlines()
log.warning("sentences.txt not found, using backup")
return BACKUP_SENTENCES_FILE.read_text().splitlines()
def convert(sentence: str, mapping: dict[str, str], max_len: int) -> str:
out = []
for i in range(max_len):
@@ -55,6 +58,7 @@ def convert(sentence: str, mapping: dict[str, str], max_len: int) -> str:
out += [mapping[sentence[i]]]
return ", ".join(out)
def main():
mapping = read_mapping()
sentences = read_sentences()
@@ -66,15 +70,17 @@ def main():
len(sentences),
max_len,
"".join(
" " + convert(sentence, mapping, max_len) + ("," if i < len(sentences) - 1 else " ") + f" // {sentence}\n"
" "
+ convert(sentence, mapping, max_len)
+ ("," if i < len(sentences) - 1 else " ")
+ f" // {sentence}\n"
for i, sentence in enumerate(sentences)
),
" " + ", ".join(str(len(sentence)) for sentence in sentences) + "\n"
" " + ", ".join(str(len(sentence)) for sentence in sentences) + "\n",
)
)
log.info(f"Wrote {len(sentences)} sentences to {TARGET_FILE}")
if __name__ == "__main__":
main()