Created
August 28, 2020 02:32
-
-
Save robgjansen/62504e2d9bf2bfd42aa45b23ea7bbe0f to your computer and use it in GitHub Desktop.
Fetch milestones and related issues from Shadow repo.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from github import Github | |
''' | |
pip install PyGithub | |
https://pygithub.readthedocs.io/en/latest | |
''' | |
#ACCESS_TOKEN="xxx" | |
ACCESS_TOKEN=None | |
def main(): | |
repo_name = "shadow/shadow" | |
gh = Github(ACCESS_TOKEN) if ACCESS_TOKEN is not None else Github() | |
repo = gh.get_repo(repo_name) | |
print(f"{repo_name} has {repo.stargazers_count} stargazers") | |
if ACCESS_TOKEN is not None: | |
views = repo.get_views_traffic() | |
clones = repo.get_clones_traffic() | |
print(f"{repo_name} has {views['count']} views ({views['uniques']} unique) and {clones['count']} clones ({clones['uniques']} unique) over the last 14 days") | |
milestones = repo.get_milestones(state='all') | |
milestonemap = {m.id: m for m in milestones} | |
issues = repo.get_issues(state='all') | |
issuemap = {i.id: i for i in issues} | |
print("Milestones:") | |
for mid in milestonemap: | |
m = milestonemap[mid] | |
if not m.title.startswith("release-"): | |
print("****************************************************") | |
print(f"**{m.title}**") | |
print(m.description.replace("\n", " ")) | |
print(m.url.replace('https://api.github.com/repos', 'https://github.com')) | |
for iid in issuemap: | |
i = issuemap[iid] | |
if i.milestone and i.milestone.id == mid: | |
print(f" * {i.title}")# ({i.url.replace('https://api.github.com/repos', 'https://github.com')})") | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment