Skip to content

Commit

Permalink
Support github3.py version 1.0.0
Browse files Browse the repository at this point in the history
Originally, these tools were written against version 0.9 of github3. The
api changed significantly as of 1.0.0a4, which includes support for some
of the new repository permissions structure we use.

These changes make the lesser used scripts operate with the new API.
  • Loading branch information
hwine committed May 22, 2016
1 parent 0c59ca7 commit 43e59fc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
23 changes: 21 additions & 2 deletions contributing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
import sys

from client import get_github3_client
from github3.exceptions import UnprocessableResponseBody

def get_files(repo, directory):
""" Get the files from this repo
The interface on this for github3.py version 1.0.0a4 is not yet
stable, so some coding-by-coincidence is used.
"""
names = None
response = repo.file_contents(directory)
if isinstance(response, UnprocessableResponseBody):
# response.body contains json of the directory contents as a list of
# dictionaries. The calling code wants a dictionary with file
# names as keys.
names = dict(((x['name'], None) for x in response.body))
else:
raise Exception("github3.py behavior changed")
return names


if __name__ == '__main__':
gh = get_github3_client()
Expand All @@ -10,11 +29,11 @@
good_repos = []
bad_repos = []

repos = gh.organization('mozilla').iter_repos(type='sources')
repos = gh.organization('mozilla').repositories(type='sources')
for repo in repos:
# All files in this repo's default branch.
# {'filename.md': Content(), 'filename2.txt': Contents(), ...}
files = repo.contents('/')
files = get_files(repo, '/')

if files:
contrib_files = [f for f in files.keys() if
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github3.py==0.9.3
requests==2.5.1
github3.py==1.0.0a4
PyYaml==3.11

0 comments on commit 43e59fc

Please sign in to comment.