-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
30 lines (22 loc) · 865 Bytes
/
main.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
import ghapi.all as ghapi
import requests
from collections import OrderedDict
def define_env(env):
"Hook function"
@env.macro
def get_user(owner: str):
g = ghapi.GhApi()
user = g.users.get_by_username(owner)
return user
@env.macro
def list_projects(owner: str, topics: list):
g = ghapi.GhApi()
searchStr = f"org:{owner} "
for topic in topics:
searchStr += f"topic:{topic} "
output = {}
# TODO - Add Pagination. Right now it assumes that each search will return less than 100 results
repos = g.search.repos(searchStr, order="asc", sort="name", per_page=100)
for repo in repos['items']:
output[repo['name']] = {'url': repo['homepage'] if repo['homepage'] else repo['html_url'], 'description': repo['description']}
return output