From 1d2ac09c92726edadce078404b300e53283eecaf Mon Sep 17 00:00:00 2001 From: "WQY\\qiong" Date: Thu, 16 Mar 2023 00:39:33 +0800 Subject: [PATCH] Print time --- api/inp_in_new.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/api/inp_in_new.py b/api/inp_in_new.py index 13ff7bc..42d9cd1 100644 --- a/api/inp_in_new.py +++ b/api/inp_in_new.py @@ -1,3 +1,4 @@ +import datetime from .project import * from .database import ChangeSet, write, try_read from .sections import * @@ -124,7 +125,14 @@ def _get_offset(inp: str) -> dict[str, list[int]]: return offset +def print_time(desc: str) -> None: + time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') + print(f"{time}: {desc}") + + def parse_file(project: str, inp: str) -> None: + print_time(f"start reading {inp}...") + offset = _get_offset(inp) levels = _level_1 + _level_2 + _level_3 + _level_4 @@ -144,6 +152,8 @@ def parse_file(project: str, inp: str) -> None: if s not in offset: continue + print_time(f"[{s}]") + is_s = _handler[s][0] == _S handler = _handler[s][1] @@ -199,6 +209,8 @@ def parse_file(project: str, inp: str) -> None: if is_s: handler(project, sections[s]) + print_time(f"end reading {inp}") + def parse_inp(project: str, inp: str) -> None: parse_file(project, inp)