Created
May 3, 2017 14:00
-
-
Save tacaswell/c347b06739d9a201a8774c9d603692f9 to your computer and use it in GitHub Desktop.
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 aiohttp | |
import gidgethub | |
import gidgethub.aiohttp | |
try: | |
with open(os.path.expanduser('~/.ghoauth'), 'r') as f: | |
oauth_token = f.read() | |
except FileNotFoundError: | |
oauth_token = None | |
bl_list = ['SIX', 'HXN', 'XFM', 'ISR', 'SRX', 'BBM', 'QAS', 'SST-1', | |
'SST-2', 'TES', 'ISS', 'IXS', 'CMS', 'CHX', 'SMI', 'LIX', | |
'XFP', 'FMX', 'AMX', 'FXI', 'NYX', 'ESM', 'FIS', 'MET', | |
'CSX', 'CSX', 'CSX2', 'PDF', 'XPD'] | |
async def get_repo_list(org, requester, oauth_token): | |
async with aiohttp.ClientSession() as session: | |
gh = gidgethub.aiohttp.GitHubAPI(session, requester, | |
oauth_token=oauth_token) | |
try: | |
data = await gh.getitem("/users/{}/repos".format(org)) | |
except gidgethub.BadRequest: | |
data = [] | |
return data | |
async def get_all_repos(requester, oauth_token): | |
all_repos = {} | |
for bl in bl_list: | |
data = await get_repo_list('nsls-ii-{}'.format(bl), | |
requester, oauth_token) | |
all_repos[bl] = [d['name'] for d in data] | |
return all_repos | |
all_repos = loop.run_until_complete(get_all_repos('tacaswell', oauth_token)) | |
for k, v in all_repos.items(): | |
print('mkdir {}'.format(k)) | |
print('pushd {}'.format(k)) | |
for repo in v: | |
print('git clone nsls-ii-{}/{}'.format(k, repo)) | |
print('popd') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment