-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.py
25 lines (22 loc) · 895 Bytes
/
update.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
import requests
from datetime import datetime, timezone
emoji_data = requests.get("https://api.github.com/emojis", headers={
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28"
}
)
formatted_data = [ f"Latest update: `{datetime.now(timezone.utc).strftime("%d/%m/%Y %H:%M:%S")} UTC`", "||||", "|---|---|---|" ]
line_components = []
for key, value in emoji_data.json().items():
line_components.append(f":{key}: `{key}`|")
if (len(line_components) == 3):
formatted_data.append(f"|{''.join(line_components)}")
line_components.clear()
if (len(line_components) > 0):
for i in range(3 - len(line_components)):
line_components.append("|")
formatted_data.append(f"|{''.join(line_components)}")
line_components.clear()
readme_file = open("README.md", "w+")
readme_file.write('\n'.join(formatted_data))
readme_file.close()