def main(): args = parse_args() gh = get_github3_client() json_fout = jsonstreams.Stream(jsonstreams.Type.array, args.json, indent=4) if args.json else None for org in args.orgs: full_query = 'org:{} {}'.format(org, args.query) if args.verbose: print('searching with query {}'.format(full_query)) sleep_if_rate_limited(gh, verbose=args.verbose) print("{0:<16}{1:<32}{2:<64}".format('org', 'repo', 'file path')) for result in gh.search_code(full_query): print("{0:<16}{1.repository.name:<32}{1.path:<64}".format( org, result)) if json_fout: json_fout.write(result.to_json()) if json_fout: # must explicitly close -- that's what outputs the closing delimiter json_fout.close()
def main(): args = parse_args() if args.orgs: gh = get_github3_client() for org in args.orgs: if len(args.orgs) > 1: print("Processing org {}".format(org)) check_invites(gh, org, args.cancel, args.cutoff)
def main(): args = parse_args() if args.orgs: gh = get_github3_client() for org in args.orgs: if len(args.orgs) > 1: print("Processing org {}".format(org)) show_info(gh, org)
def main(): args = parse_args() global VERBOSE VERBOSE = args.verbose if args.orgs: gh = get_github3_client() for org in args.orgs: check_users(gh, org, args.owners, args.update_team)
def main(): args = parse_args() global dry_run dry_run = args.dry_run global gh gh = get_github3_client() for org in args.orgs: remove_login_from_org(args.login, org)
def main(): args = parse_args() if args.debug: logger.setLevel(logging.DEBUG) logging.getLogger('github3').setLevel(logging.DEBUG) gh = get_github3_client() me = gh.me() logger.debug("I'm %s (%s)", me.name, me.login) if args.only: org, repo = args.only.split('/') close_prs(gh, organization=org, repository=repo, close=args.close, lock=args.lock, message=args.message) else: close_configured_prs(gh, args.config, args.dry_run)
def __init__(self, live=True): self.live = live self.new_contents = "" self.gh = get_github3_client() global gh gh = self.gh my_login = gh.me().login approved_login = my_login.lower() == APPROVED_ACCOUNT.lower() if not approved_login: logger.warning( "Unapproved user {}, no changes allowed.".format(my_login)) # don't allow changes if live: raise SystemExit("Terminating update run. User unapproved") if live: # Cache the CoC file r = requests.get(COC_CONTENTS_URL) self.new_contents = r.content
def main(): args = parse_args() if args.orgs or args.all_my_orgs: gh = get_github3_client() if args.all_my_orgs: authorized_user = gh.me() me = gh.user(authorized_user.login) my_orgs = MyOrganizationsIterator(me) for org in my_orgs: owner_logins = [u.login for u in org.members(role="admin")] if me.login in owner_logins: args.orgs.append(org.login) if args.names_only: print("\n".join(sorted(args.orgs))) return newline = "" for org in args.orgs: if len(args.orgs) > 1: print("{}Processing org {}".format(newline, org)) newline = "\n" show_info(gh, org, args.owners, args.email)
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() # Divvy up into repositories that need/do not need a CONTRIBUTING file. good_repos = [] bad_repos = [] 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 = get_files(repo, '/') if files: contrib_files = [ f for f in files.keys() if f.startswith('CONTRIBUTING') ]
def main(): args = parse_args() gh = client.get_github3_client() for org in args.org: report_hooks(gh, org, args.active, args.unique, args.ping, args.yaml)
def main(): args = parse_args() if args.orgs: gh = get_github3_client() for org in args.orgs: check_users(gh, org, args.admins, args.update_team)
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() # Divvy up into repositories that need/do not need a CONTRIBUTING file. good_repos = [] bad_repos = [] 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 = get_files(repo, '/') if files: contrib_files = [f for f in files.keys() if f.startswith('CONTRIBUTING')] else: