-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathget_community_team_data.py
79 lines (66 loc) · 1.95 KB
/
get_community_team_data.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Standard library
import logging
import re
# Third-party
import requests
# Constants should match 'ccos/data/push_data_via_git.py'
GITHUB_ORGANIZATION = "creativecommons"
GITHUB_REPO_NAME = "creativecommons.github.io-source"
# Constants should match 'push_data_to_ccos.py'
CT_MEMBERS = "community_team_members.json"
DATABAG_URL = (
f"https://raw.githubusercontent.com/{GITHUB_ORGANIZATION}/"
f"{GITHUB_REPO_NAME}/main/databags/{CT_MEMBERS}"
)
LOG = logging.root
def fetch_databag():
"""
This method pulls the team members from CCOS and
and loads them into the databag after a little
formatting. The databag schema is below.
databag schema
{
"projects": [
{
"name": "",
"repos: [
"",
...
],
"members": [
{
"name": "",
"github": ""
},
...
]
},
...
]
}
"""
LOG.info("Pulling from OS@CC...")
databag = {"projects": []}
request = requests.get(DATABAG_URL)
request.raise_for_status()
projects = request.json()["projects"]
LOG.info("Team members pulled.")
LOG.info("Processing team members...")
for project in projects:
formatted_project = {
"name": project["name"],
"repos": re.split(r",\s?", project["repos"]),
"roles": {},
}
members = project["members"]
for member in members:
role = member["role"]
if role not in formatted_project["roles"]:
formatted_project["roles"][role] = []
del member["role"]
formatted_project["roles"][role].append(member)
databag["projects"].append(formatted_project)
LOG.success("done.")
return databag
def get_community_team_data():
return fetch_databag()