diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-06-27 15:07:59 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-08-29 17:48:45 +0200 |
commit | f41343abe847fa88a4cbb46d856bfc44efa8595a (patch) | |
tree | 47b4e7f2d5aa43ce85470ac65814339cd96ac864 /CC | |
parent | 6398d0947673a75cf15544af34f038ff8b18b51b (diff) | |
download | rules-cc-f41343abe847fa88a4cbb46d856bfc44efa8595a.tar.gz |
python: Add type hints and fix style in rules scripts
Diffstat (limited to 'CC')
-rwxr-xr-x | CC/auto/runner | 18 | ||||
-rwxr-xr-x | CC/test/runner | 12 |
2 files changed, 15 insertions, 15 deletions
diff --git a/CC/auto/runner b/CC/auto/runner index f938c27..27aef0c 100755 --- a/CC/auto/runner +++ b/CC/auto/runner @@ -24,7 +24,6 @@ param_file = argv[2] magic_string = argv[3] at_only = argv[4] == "true" - with open(param_file) as f: param = json.loads(f.read()) @@ -41,8 +40,8 @@ with open(input_file) as i: with open("out", "w") as o: for line in i.readlines(): if x := re.search( - r"#(.*)(" + magic_string + r" )([ \t]*)([a-zA-Z0-9_]+)", line - ): + r"#(.*)(" + magic_string + r" )([ \t]*)([a-zA-Z0-9_]+)", + line): # get the VAR key = x.groups()[-1] if key in param: @@ -52,16 +51,16 @@ with open(input_file) as i: line, ) else: - line = f"/* #undef {x.groups()[-1]} */\n" + line = f"/* #undef {x.groups()[-1]} */\n" if x := re.search( - r"#(.*)(" + magic_string + "01 )([ \t]*)([a-zA-Z0-9_]+)", line - ): + r"#(.*)(" + magic_string + "01 )([ \t]*)([a-zA-Z0-9_]+)", + line): # get the VAR key = x.groups()[-1] line = sub( f"{x.group()[1:]}", - f"{x.groups()[0]}define {x.groups()[2]}{key} " - + str(1 if key in param else 0), + f"{x.groups()[0]}define {x.groups()[2]}{key} " + + str(1 if key in param else 0), line, ) if match("#[ \t]*define", line): @@ -71,6 +70,7 @@ with open(input_file) as i: if not at_only: if x := re.search(r"\${([a-zA-Z0-9-_]+)}", line): key = x.groups()[0] - line = sub(r"\${" + key + r"}", param.get(key, ""), line) + line = sub(r"\${" + key + r"}", param.get(key, ""), + line) print(line, end="", file=o) diff --git a/CC/test/runner b/CC/test/runner index 0647621..fc1f04c 100755 --- a/CC/test/runner +++ b/CC/test/runner @@ -18,14 +18,14 @@ import os import subprocess import time -time_start = time.time() -time_stop = 0 -result = "UNKNOWN" -stderr = "" -stdout = "" +time_start: float = time.time() +time_stop: float = 0 +result: str = "UNKNOWN" +stderr: str = "" +stdout: str = "" -def dump_results(): +def dump_results() -> None: with open("result", "w") as f: f.write("%s\n" % (result, )) with open("time-start", "w") as f: |