|
| 1 | +import os |
| 2 | +import json |
1 | 3 | import requests
|
2 | 4 | from datetime import datetime
|
3 | | -import json |
4 | 5 |
|
5 | 6 | query = '''query questionData($titleSlug: String!) {
|
6 | 7 | question(titleSlug: $titleSlug) {
|
|
9 | 10 | }
|
10 | 11 | '''
|
11 | 12 |
|
12 | | -questions_file = "../src/data/questions.json" |
| 13 | +questions_file = os.getcwd() +"/src/data/questions.json" |
13 | 14 |
|
14 | | -print("Reading questions file") |
| 15 | +print("=== Reading questions file ===") |
15 | 16 |
|
16 | 17 | try:
|
17 | 18 | with open(questions_file, "r") as file:
|
|
20 | 21 | print(e)
|
21 | 22 | exit()
|
22 | 23 |
|
23 | | -print("Updating question metadata") |
| 24 | +print("=== Updating question metadata ===") |
| 25 | + |
| 26 | +startTime = datetime.now() |
24 | 27 |
|
25 | 28 | for question in questions["data"]:
|
26 | 29 | variables = {"titleSlug": question["url"]}
|
|
36 | 39 | print(f'{question["name"]}: {our_difficulty} -> {leetcode_difficulty}')
|
37 | 40 | question["difficulty"] = leetcode_difficulty
|
38 | 41 |
|
39 | | -print("Finished checking all questions") |
| 42 | +print("=== Finished checking all questions ===") |
40 | 43 |
|
41 | 44 | try:
|
42 | 45 | with open(questions_file, "w") as file:
|
|
46 | 49 | print(e)
|
47 | 50 | exit()
|
48 | 51 |
|
49 | | -print("Wrote questions file") |
| 52 | +print("=== Wrote questions file ===") |
| 53 | +print(f'=== Script took: {datetime.now() - startTime} seconds ===') |
0 commit comments