|
6 | 6 |
|
7 | 7 | import github3 |
8 | 8 | from dotenv import load_dotenv |
9 | | -from ratelimiter import RateLimiter |
10 | 9 |
|
11 | 10 | if __name__ == "__main__": |
12 | 11 |
|
|
17 | 16 | # Auth to GitHub.com |
18 | 17 | gh = github3.login(token=os.getenv("GH_TOKEN")) |
19 | 18 |
|
20 | | - # Get all repos from organization |
21 | | - all_repos = gh.repositories() |
22 | | - rate_limiter = RateLimiter(max_calls=10, period=1) |
23 | | - repo_list = [] |
24 | 19 | # Set the topic |
25 | 20 | topic = os.getenv("TOPIC") |
| 21 | + organization = os.getenv("ORGANIZATION") |
| 22 | + |
| 23 | + # Get all repos from organization |
| 24 | + search_string = "org:" + organization + " topic:" + topic |
| 25 | + all_repos = gh.search_repositories(search_string) |
| 26 | + repo_list = [] |
26 | 27 |
|
27 | | - with rate_limiter: |
28 | | - for repo in all_repos: |
29 | | - if repo is not None: |
30 | | - try: |
31 | | - repo_topic = repo.topics() |
32 | | - except Exception: |
33 | | - print("skipping 404") |
34 | | - else: |
35 | | - if topic in repo_topic.names: |
36 | | - print("{0}".format(repo)) |
37 | | - full_repository = repo.refresh() |
38 | | - # TODO: #7 For each resulting project add a key _InnerSourceMetadata |
39 | | - # Add stuff here about innersource.json data before appending to list |
40 | | - repo_list.append(full_repository.as_dict()) |
| 28 | + for repo in all_repos: |
| 29 | + if repo is not None: |
| 30 | + # TODO: #7 For each resulting project add a key _InnerSourceMetadata |
| 31 | + print("{0}".format(repo.repository)) |
| 32 | + full_repository = repo.repository.refresh() |
| 33 | + # Add stuff here about innersource.json data before appending to list |
| 34 | + repo_list.append(repo.as_dict()) |
41 | 35 |
|
42 | 36 | # Write each repository to a repos.json file |
43 | 37 | with open("repos.json", "w") as f: |
|
0 commit comments