-
Notifications
You must be signed in to change notification settings - Fork 3
/
update_js.py
50 lines (43 loc) · 1.08 KB
/
update_js.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import asyncio
from pathlib import Path
import httpx
BASE_URL = "https://compass.scouts.org.uk/Scripts_v4.07/JS"
files = [
"adultjoining",
"assignnewrole",
"Dates",
"editprofile",
"extenders",
"Grids",
"hierarchy",
"jQuery191",
"master",
"memberprofile",
"membersearch",
"membertraining",
"Menu",
"neworgentity",
"newpermit",
"newrole",
"newsection",
"Popup",
"QAS",
"reports",
"roles",
"Scouts",
"scoutsportal",
"searchresults",
"settings",
"traininghours",
"trainingogl",
"updatetraining",
]
async def main() -> list[str]:
async with httpx.AsyncClient() as client:
tasks = [client.get(f"{BASE_URL}/{filename}.js") for filename in files]
responses = await asyncio.gather(*tasks, return_exceptions=True)
return [resp.content for resp in responses]
if __name__ == '__main__':
files_contents = asyncio.run(main())
for i, filename in enumerate(files):
Path(f"js/{filename}.js").write_bytes(files_contents[i].decode("utf-8-sig").encode("utf-8"))