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