def run():
args = parse_args()<EOL>codetools.setup_logging(args.debug)<EOL>global g<EOL>g = pygithub.login_github(token_path=args.token_path, token=args.token)<EOL>org = g.get_organization(args.org)<EOL>try:<EOL><INDENT>teams = list(org.get_teams())<EOL><DEDENT>except github.RateLimitExceededException:<EOL><INDENT>raise<EOL><DEDENT>except github.GithubException as e:<EOL><INDENT>msg = '<STR_LIT>'<EOL>raise pygithub.CaughtOrganizationError(org, e, msg) from None<EOL><DEDENT>old_team = find_team(teams, args.oldteam)<EOL>new_team = find_team(teams, args.newteam)<EOL>move_me = args.repos<EOL>debug(len(move_me), '<STR_LIT>')<EOL>added = []<EOL>removed = []<EOL>for name in move_me:<EOL><INDENT>try:<EOL><INDENT>r = org.get_repo(name)<EOL><DEDENT>except github.RateLimitExceededException:<EOL><INDENT>raise<EOL><DEDENT>except github.GithubException as e:<EOL><INDENT>msg = "<STR_LIT>".format(r=name)<EOL>raise pygithub.CaughtOrganizationError(org, e, msg) from None<EOL><DEDENT>debug("<STR_LIT>".format(<EOL>repo=r.full_name,<EOL>team=args.newteam<EOL>))<EOL>if not args.dry_run:<EOL><INDENT>try:<EOL><INDENT>new_team.add_to_repos(r)<EOL>added += r.full_name<EOL>debug('<STR_LIT>')<EOL><DEDENT>except github.RateLimitExceededException:<EOL><INDENT>raise<EOL><DEDENT>except github.GithubException:<EOL><INDENT>debug('<STR_LIT>')<EOL><DEDENT><DEDENT>if old_team.name in '<STR_LIT>':<EOL><INDENT>warn("<STR_LIT>"<EOL>.format(repo=r.full_name))<EOL><DEDENT>debug("<STR_LIT>".format(<EOL>repo=r.full_name,<EOL>team=args.oldteam<EOL>))<EOL>if not args.dry_run:<EOL><INDENT>try:<EOL><INDENT>old_team.remove_from_repos(r)<EOL>removed += r.full_name<EOL>debug('<STR_LIT>')<EOL><DEDENT>except github.RateLimitExceededException:<EOL><INDENT>raise<EOL><DEDENT>except github.GithubException:<EOL><INDENT>debug('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>info('<STR_LIT>', added)<EOL>info('<STR_LIT>', removed)<EOL>
Move the repos