Add a competition
()
| 22 | |
| 23 | |
| 24 | def addCompe(): |
| 25 | """ |
| 26 | Add a competition |
| 27 | """ |
| 28 | with codecs.open('competitions.json', 'r', encoding='utf-8') as f: |
| 29 | coms = json.load(f) |
| 30 | with codecs.open('solutions.json', 'r', encoding='utf-8') as f: |
| 31 | solutions = json.load(f) |
| 32 | cid = max([int(i) for i in solutions.keys()]) + 1 |
| 33 | newCom = {} |
| 34 | for i in ["name", "link", "type", "platform", "hosts", "ddl"]: |
| 35 | newCom[i] = input("Enter %s: " % (i)) |
| 36 | solution = [] |
| 37 | num = input("How many solutins you find? ") |
| 38 | for i in range(int(num)): |
| 39 | rank = input("Rank: ") |
| 40 | print("The id of this solutions is %d" % (cid)) |
| 41 | addSolutionInfo(cid) |
| 42 | solution.append({"rank": rank, "id": cid}) |
| 43 | cid += 1 |
| 44 | |
| 45 | newCom["solutions"] = solution |
| 46 | coms.append(newCom) |
| 47 | with codecs.open("competitions.json", "w", encoding='utf-8') as f: |
| 48 | json.dump(coms, f, indent=4, ensure_ascii=False) |
| 49 | |
| 50 | |
| 51 | def renderToMK(): |
nothing calls this directly
no test coverage detected