Skip to content

Commit 1b02af5

Browse files
committed
Fix reading query
1 parent f717565 commit 1b02af5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

scripts/graphql.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@
1111

1212
URL = "https://api.github.com/graphql"
1313

14+
base_dir = pathlib.Path(sys.argv[1])
15+
16+
resp_dir = base_dir / "assets/contrib/"
17+
card_dir = base_dir / "flask_app/static/img/gh_cards/"
18+
resp_dir.mkdir(exist_ok=True)
19+
card_dir.mkdir(exist_ok=True)
20+
1421
with open("/etc/config.json", encoding="utf-8") as jsonfile:
1522
config = json.load(jsonfile)
1623

17-
with open("assets/graphql_query.txt", encoding="utf-8") as queryfile:
24+
with open(base_dir / "assets/graphql_query.txt", encoding="utf-8") as queryfile:
1825
query_param = {"query": queryfile.read()}
1926

2027
resp = requests.post(
@@ -27,13 +34,8 @@
2734
)
2835

2936
json_resp = json.loads(resp.content)["data"]["user"]
30-
base_dir = pathlib.Path(sys.argv[1])
31-
resp_dir = base_dir / "assets/contrib/"
32-
card_dir = base_dir / "flask_app/static/img/gh_cards/"
33-
resp_dir.mkdir(exist_ok=True)
34-
card_dir.mkdir(exist_ok=True)
3537

36-
with open(str(resp_dir / "recent.json"), mode="w", encoding="utf-8") as contribfile:
38+
with open(resp_dir / "recent.json", mode="w", encoding="utf-8") as contribfile:
3739
json.dump(json_resp, contribfile)
3840

3941

0 commit comments

Comments
 (0)