Skip to content

Commit

Permalink
Lint all python files
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-ballarin committed Feb 6, 2024
1 parent 399f256 commit 2bacdd5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mathrace_compatibility/scripts/mathrace_log_to_turing_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@
import sys


def convert(mathrace_log_filename: str, turing_json_filename: str):
def convert(mathrace_log_filename: str, turing_json_filename: str) -> None:
"""Convert a race from mathrace log format to turing json format."""
with open(mathrace_log_filename) as mathrace_log_file:
mathrace_log = [line.strip("\n") for line in mathrace_log_file.readlines()]

turing_dict = dict()
turing_dict: dict[str, int | str | list[dict[str, int | str]] | None] = dict()

# Race name
race_name = pathlib.Path(mathrace_log_filename).name.replace(".extracted.log", "")
turing_dict["nome"] = race_name

# Race year
race_year = int(race_name.replace("journal_", ""))
race_start = datetime.datetime(race_year, 1, 1, tzinfo=datetime.timezone.utc)
race_start = datetime.datetime(race_year, 1, 1, tzinfo=datetime.UTC)
turing_dict["inizio"] = race_start.isoformat()

# Line counter
Expand Down Expand Up @@ -86,7 +87,7 @@ def convert(mathrace_log_filename: str, turing_json_filename: str):
turing_dict["cutoff"] = None

# Next lines starting with --- 004 contain the definition of the initial score for each question
questions = list()
questions: list[dict[str, int | str]] = list()
for q in range(num_questions):
question_def = mathrace_log[line]
line += 1
Expand All @@ -106,7 +107,7 @@ def convert(mathrace_log_filename: str, turing_json_filename: str):
line += 1

# Loop over events during the race
events = list()
events: list[dict[str, int | str]] = list()
manual_bonuses = list()
timestamp_offset = None
while True:
Expand Down

0 comments on commit 2bacdd5

Please sign in to comment.