def assemble_repolist(args: Namespace, org: Organization) -> List[Repository]: repolist = [] if not args.skip_repo_changes: print_info("Assembling repository list...") if args.repos: for reponame in args.repos: try: r = org.get_repo(reponame) repolist.append(r) except GithubException: raise utils.ErrorMessage( "Repository %s not found. At least with this API key." % utils.highlight(reponame)) if args.reporegexes: for reporegex in args.reporegexes: try: regex = re.compile(reporegex) except error as e: raise utils.ErrorMessage( "Not a valid regular expression %s (%s)" % (utils.highlight(reporegex), str(e))) for repo in org.get_repos(): if regex.match(repo.name): repolist.append(repo) if not args.repos and not args.reporegexes: print_info( "No repository regex or name specified, run against %s repos" % utils.highlight("all")) repolist = list(org.get_repos()) elif not repolist: if args.skip_org_changes: print_warning( "No repos matched and skipping org changes. Nothing to do." ) else: print_warning("No repos matched!") return repolist
def get_repos(org: Organization): return org.get_repos()