Skip to content

Commit 3e4a126

Browse files
committed
contest: faker: support combining infos
Faker is a convenient places to combine the branch infos. Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4b04eda commit 3e4a126

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

contest/results-faker.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,33 @@
1616
1717
[input]
1818
branches=/path/to/branches.json,/path/to/branches2.json
19+
infos=/path/to/infos.json,/path/to/infos2.json
1920
[output]
2021
dir=/path/to/output
2122
url_pfx=relative/within/server
23+
info=/path/to/info.json
2224
"""
2325

26+
def combine_infos(config):
27+
paths = config.get("input", "infos", fallback="").split(',')
28+
if not paths:
29+
return
30+
31+
infos = {}
32+
for path in paths:
33+
with open(path, "r") as fp:
34+
infos.update(json.load(fp))
35+
36+
with open(config.get("output", "info"), 'w') as fp:
37+
json.dump(infos, fp)
38+
39+
2440
def main() -> None:
2541
config = configparser.ConfigParser()
2642
config.read(['faker.config'])
2743

44+
combine_infos(config)
45+
2846
branches = []
2947
paths = config.get("input", "branches")
3048
for path in paths.split(','):

0 commit comments

Comments
 (0)