def prepare_github(github_user, github_repo, token=None): if token: output("Authenticating to GitHub using token\n") github = Github(token) else: output("Log into Gituhub as {0}\n".format(github_user)) while True: github_password = getpass.getpass("Github password: "******"Bad credentials, try again.\n") github = Github(github_user, github_password) github_user = github.get_user() # If the project name is specified as owner/project, assume that it's owned by either # a different user than the one we have credentials for, or an organization. if "/" in github_repo: gh_user, gh_repo = github_repo.split('/') try: github_owner = github.get_user(gh_user) except GithubException: try: github_owner = github.get_organization(gh_user) except GithubException: github_owner = github_user else: github_owner = github_user gh_repo_obj = github_owner.get_repo(gh_repo) return gh_repo_obj
def do_awesome_page_excluded(args): ''' Do a task. ''' # Get context from CLI, environment variables, and ini files. config = get_configuration(args) # Validate input. validate_configuration(config) # Pull variables from config. github_access_token = config.get("github_access_token") organization = config.get("organization") # Log into GitHub. github = Github(github_access_token) # Iterate through all repositories. github_organization = github.get_organization(organization) for repo in github_organization.get_repos(): # Get topics for the repository. topics = repo.get_topics() # Black-listed topics. if "archived" in topics: print(" Archived: {}".format(repo.name)) elif "deprecated" in topics: print("Deprecated: {}".format(repo.name)) elif "not-in-awesome" in topics: print(" Excluded: {}".format(repo.name)) elif len(topics) == 0: print("No topics: {}".format(repo.name)) else: found = False for topic in topics: if topic in awesome_topics.keys(): found = True if not found: print("Not found: {}".format(repo.name))
def do_awesome_page(args): ''' Do a task. ''' # Get context from CLI, environment variables, and ini files. config = get_configuration(args) # Validate input. validate_configuration(config) # Pull variables from config. github_access_token = config.get("github_access_token") organization = config.get("organization") # Log into GitHub. github = Github(github_access_token) # Iterate through all repositories. github_organization = github.get_organization(organization) for repo in github_organization.get_repos(): # Get topics for the repository. topics = repo.get_topics() # Black-listed topics. if "archived" in topics: continue elif "deprecated" in topics: continue elif "not-in-awesome" in topics: continue # Separate out "obsolete" repositories. elif "obsolete" in topics: continue # Separate out "obsolete" repositories. elif "under-construction" in topics: member = { "name": repo.name, "url": repo.html_url, "description": repo.description } awesome_topics.get("under-construction", []).get("members", []).append(member) # After passing the "guards" (obsolete, deprecated, archived), process repository. else: # Process only specified topics. for topic in topics: if topic in awesome_topics.keys(): member = { "name": repo.name, "url": repo.html_url, "description": repo.description } awesome_topics.get(topic, []).get("members", []).append(member) # Print prolog. for prolog_line in prolog_lines: print(prolog_line) # Print groups. for topic_key, topic_value in awesome_topics.items(): print("\n## {0}".format(topic_value.get("title", "Unknown"))) print("\n*{0}*\n".format(topic_value.get("description", "Unknown"))) # Print members in alphabetical order. members = sorted(topic_value.get("members", []), key=key_member_name) for member in members: print("1. [{0}]({1}) - {2}".format(member.get("name"), member.get("url"), member.get("description", ""))) # Print epilog. for epilog_line in epilog_lines: print(epilog_line)
def do_awesome_groups(args): ''' Do a task. ''' # Get context from CLI, environment variables, and ini files. config = get_configuration(args) # Prolog. logging.info(entry_template(config)) # Validate input. validate_configuration(config) # Pull variables from config. github_access_token = config.get("github_access_token") organization = config.get("organization") # Log into GitHub. github = Github(github_access_token) # Iterate through all repositories. github_organization = github.get_organization(organization) for repo in github_organization.get_repos(): # Get topics for the repository. topics = repo.get_topics() # Black-listed topics. if "deprecated" in topics: continue if "obsolete" in topics: continue if "archived" in topics: continue # Process only specified topics. for topic in topics: if topic in awesome_topics.keys(): member = { "name": repo.name, "url": repo.html_url, "description": repo.description } awesome_topics.get(topic, []).get("members", []).append(member) # Print groups. for topic_key, topic_value in awesome_topics.items(): print("\n## {0}".format(topic_value.get("title", "Unknown"))) print("\n*{0}*\n".format(topic_value.get("description", "Unknown"))) # Print members in alphabetical order. members = sorted(topic_value.get("members", []), key=key_member_name) for member in members: print("1. [{0}]({1}) - {2}".format(member.get("name"), member.get("url"), member.get("description", ""))) # Epilog. logging.info(exit_template(config))
prerelease=prerelease) def upload_files(repo, release, files): release = repo.get_release('llvmorg-{}'.format(release)) for f in files: print('Uploading {}'.format(f)) release.upload_asset(f) print("Done") parser = argparse.ArgumentParser() parser.add_argument('command', type=str, choices=['create', 'upload']) # All args parser.add_argument('--token', type=str) parser.add_argument('--release', type=str) # Upload args parser.add_argument('--files', nargs='+', type=str) args = parser.parse_args() github = github.Github(args.token) llvm_repo = github.get_organization('llvm').get_repo('llvm-project') if args.command == 'create': create_release(llvm_repo, args.release) if args.command == 'upload': upload_files(llvm_repo, args.release, args.files)