-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.py
38 lines (27 loc) · 905 Bytes
/
code.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
import json
import fastcore
import datetime
from ghapi.all import GhApi
from badges import extract_badges
ORG = 'getwilds'
api = GhApi()
repos = api.repos.list_for_org(ORG)
target_keys = ['name', 'private', 'fork', 'description', 'html_url', 'topics']
data = {}
data['repos'] = [{key: w[key] for key in target_keys} for w in repos]
for repo in data['repos']:
# print(repo['name'])
if not repo['fork'] and not repo['private']:
repo['badges'] = extract_badges(repo['name'])
# print(extract_badges(repo['name']))
else:
repo['badges'] = []
data['updated'] = datetime.datetime.now(datetime.UTC).isoformat()
class LEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, fastcore.foundation.L):
return list(obj)
return json.JSONEncoder.default(self, obj)
with open('registry.json', 'w') as file:
json.dump(data, file, cls=LEncoder, indent=2)
file.write('\n')