-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4527a06
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import requests | ||
from urlparse import urljoin | ||
|
||
whitelist = [ | ||
'README.md', | ||
'LICENSE.TXT', | ||
'CONTRIBUTING.md', | ||
'.gitignore', | ||
'.travis.yml' | ||
] | ||
|
||
|
||
class Repo: | ||
def __init__(self, owner, repo): | ||
self.repo = repo | ||
self.owner = owner | ||
self.files = None | ||
|
||
def get_contents(self): | ||
uri = "https://api.github.com/repos/%s/%s/contents" % (self.owner, self.repo) | ||
resp = requests.get(uri) | ||
|
||
print(uri) | ||
|
||
if resp.status_code is not 200: | ||
print(resp.status_code) | ||
raise Exception | ||
else: | ||
self.files = [each['name'] for each in resp.json()] | ||
|
||
def check_file(self, file): | ||
return file in self.files | ||
|
||
|
||
r = Repo("onyb", "cling") | ||
r.get_contents() | ||
for stuff in whitelist: | ||
print(stuff, ':', r.check_file(stuff)) |