Package: hubcap
hubcapA py2store (i.e. dict-like) interface to githubTo install:pip install hubcapExamplesBasicsThe simplest facade to github data.Interact with github like you'd interact with adictobject.Warning: You'll need to have a github api token (google it if you don't have one;
it's easy to get). You'll have to specify this token when making hubcap objects,
or put it in an environmental variable under the nameGITHUB_TOKENorHUBCAP_GITHUB_TOKEN(useful since github actions doesn't allow you to have env variables starting withGITHUB).>>>s=GitHubReader('thorwhalen')# connnecting to a particular user/organization>>>list(s)# doctest: +SKIP['agen','aix',...'viral','wealth','wrapt']>>>'a_non_existing_repository_name'insFalse>>>'hubcap'ins# of course, this will be true, it's what you're using now!True>>>repo=s['hubcap']>>>list(repo)['master']>>>branch=repo['master']>>>list(branch)# doctest: +NORMALIZE_WHITESPACE['/.gitattributes','/.github/','/.gitignore','/LICENSE','/README.md','/docsrc/','/hubcap/','/setup.cfg','/setup.py']>>>content=branch['/setup.cfg']>>>print(content[:32].decode())[metadata]name=hubcapversionListing repositories and information about themList repositories for a given user or organization, along with 78 fields of info.>>>fromhubcap.examplesimportrepos_info,actions_info>>>>>>repos=repos_info('i2mint')# doctest: +SKIP>>>print(repos.shape)# doctest: +SKIP(60,78)>>>repos.head()# doctest: +SKIPidnode_idname...watchersdefault_branchpermissionsfull_name...i2mint/py2mqtt425694616R_kgDOGV-VmApy2mqtt...0main{'admin':True,'maintain':True,'push':True...i2mint/mongodol341721959MDEwOlJlcG9zaXRvcnkzNDE3MjE5NTk=mongodol...0master{'admin':True,'maintain':True,'push':True...i2mint/dol299438731MDEwOlJlcG9zaXRvcnkyOTk0Mzg3MzE=dol...4master{'admin':True,'maintain':True,'push':True...i2mint/stream2py238989487MDEwOlJlcG9zaXRvcnkyMzg5ODk0ODc=stream2py...2master{'admin':True,'maintain':True,'push':True...i2mint/creek321448350MDEwOlJlcG9zaXRvcnkzMjE0NDgzNTA=creek...0master{'admin':True,'maintain':True,'push':True...[5rowsx78columns]>>>list(repos.columns)# doctest: +SKIP['id','node_id','name','full_name','private','owner','html_url','description','fork','url','forks_url','keys_url','collaborators_url','teams_url','hooks_url', 'issue_events_url', 'events_url', 'assignees_url', 'branches_url', 'tags_url','blobs_url','git_tags_url','git_refs_url','trees_url','statuses_url','languages_url', 'stargazers_url', 'contributors_url', 'subscribers_url', 'subscription_url','commits_url','git_commits_url','comments_url','issue_comment_url','contents_url','compare_url','merges_url','archive_url','downloads_url','issues_url','pulls_url','milestones_url','notifications_url','labels_url','releases_url','deployments_url', 'created_at', 'updated_at', 'pushed_at', 'git_url', 'ssh_url', 'clone_url', 'svn_url','homepage','size','stargazers_count','watchers_count','language','has_issues', 'has_projects', 'has_downloads', 'has_wiki', 'has_pages', 'forks_count','mirror_url','archived','disabled','open_issues_count','license','allow_forking','is_template','topics','visibility','forks','open_issues','watchers','default_branch','permissions']Get info about github actions for a given repository.>>>actions=actions_info('i2mint/mongodol')# doctest: +SKIP>>>print(actions.shape)# doctest: +SKIP(10,30)>>>actions.head()# doctest: +SKIPidname...repositoryhead_repository01468986198ContinuousIntegration...{'id':341721959,'node_id':'MDEwOlJlcG9zaXRv...  {'id': 341721959, 'node_id': 'MDEwOlJlcG9zaXRv...11445456774ContinuousIntegration...{'id':341721959,'node_id':'MDEwOlJlcG9zaXRv...  {'id': 341721959, 'node_id': 'MDEwOlJlcG9zaXRv...21437461380ContinuousIntegration...{'id':341721959,'node_id':'MDEwOlJlcG9zaXRv...  {'id': 341721959, 'node_id': 'MDEwOlJlcG9zaXRv...31343133456ContinuousIntegration...{'id':341721959,'node_id':'MDEwOlJlcG9zaXRv...  {'id': 341721959, 'node_id': 'MDEwOlJlcG9zaXRv...41262878182ContinuousIntegration...{'id':341721959,'node_id':'MDEwOlJlcG9zaXRv...  {'id': 341721959, 'node_id': 'MDEwOlJlcG9zaXRv...[5rowsx30columns]>>>>>>list(actions.columns)# doctest: +SKIP['id','name','node_id','head_branch','head_sha','run_number','event','status','conclusion','workflow_id','check_suite_id','check_suite_node_id','url','html_url','pull_requests','created_at','updated_at','run_attempt','run_started_at','jobs_url','logs_url','check_suite_url','artifacts_url','cancel_url','rerun_url','previous_attempt_url','workflow_url','head_commit','repository','head_repository']Find most recently changed repositories and check if their CI failed or not.>>>fromhubcap.examplesimportdate_selection_lidx>>>updated_recently=repos.iloc...[date_selection_lidx(repos,hours_ago=24)]# doctest: +SKIP>>>{repo:get_last_build_status(repo)...forrepoinupdated_recently['full_name']}# doctest: +SKIP{'i2mint/py2mqtt':'failure','i2mint/mongodol':'success','i2mint/dol':'success','i2mint/stream2py':'success','i2mint/creek':'success'}Note: You can get this directly using theci_statusfunction>>>fromhubcap.examplesimportci_status>>>ci_status('i2mint',hours_ago=24)# doctest: +SKIP{'i2mint/py2mqtt':'failure','i2mint/mongodol':'success','i2mint/dol':'success','i2mint/stream2py':'success','i2mint/creek':'success'}