def check_repo_exists(deploy_repo, service='<STR_LIT>', *, auth=None,<EOL>headers=None, ask=False):
headers = headers or {}<EOL>if deploy_repo.count("<STR_LIT:/>") != <NUM_LIT:1>:<EOL><INDENT>raise RuntimeError('<STR_LIT>'.format(deploy_repo=deploy_repo))<EOL><DEDENT>user, repo = deploy_repo.split('<STR_LIT:/>')<EOL>if service == '<STR_LIT>':<EOL><INDENT>REPO_URL = '<STR_LIT>'<EOL><DEDENT>elif service == '<STR_LIT>' or service == '<STR_LIT>':<EOL><INDENT>REPO_URL = '<STR_LIT>'<EOL>headers = {**headers, **Travis_APIv3}<EOL><DEDENT>elif service == '<STR_LIT>':<EOL><INDENT>REPO_URL = '<STR_LIT>'<EOL>headers = {**headers, **Travis_APIv3}<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>wiki = False<EOL>if repo.endswith('<STR_LIT>') and service == '<STR_LIT>':<EOL><INDENT>wiki = True<EOL>repo = repo[:-<NUM_LIT:5>]<EOL><DEDENT>def _try(url):<EOL><INDENT>r = requests.get(url, auth=auth, headers=headers)<EOL>if r.status_code in [requests.codes.not_found, requests.codes.forbidden]:<EOL><INDENT>return False<EOL><DEDENT>if service == '<STR_LIT>':<EOL><INDENT>GitHub_raise_for_status(r)<EOL><DEDENT>else:<EOL><INDENT>r.raise_for_status()<EOL><DEDENT>return r<EOL><DEDENT>r = _try(REPO_URL.format(user=urllib.parse.quote(user),<EOL>repo=urllib.parse.quote(repo)))<EOL>r_active = r and (service == '<STR_LIT>' or r.json().get('<STR_LIT>', False))<EOL>if service == '<STR_LIT>':<EOL><INDENT>REPO_URL = '<STR_LIT>'<EOL>r_org = _try(REPO_URL.format(user=urllib.parse.quote(user),<EOL>repo=urllib.parse.quote(repo)))<EOL>r_org_active = r_org and r_org.json().get('<STR_LIT>', False)<EOL>if not r_active:<EOL><INDENT>if not r_org_active:<EOL><INDENT>raise RuntimeError('<STR_LIT>'.format(user=user, repo=repo))<EOL><DEDENT>r = r_org<EOL>r_active = r_org_active<EOL>service = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>if r_active and r_org_active:<EOL><INDENT>if ask:<EOL><INDENT>while True:<EOL><INDENT>print(green("<STR_LIT>".format(user=user, repo=repo)))<EOL>preferred = input("<STR_LIT>".format(default=blue("<STR_LIT>")))<EOL>preferred = preferred.lower().strip()<EOL>if preferred in ['<STR_LIT:o>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>r = r_org<EOL>service = '<STR_LIT>'<EOL>break<EOL><DEDENT>elif preferred in ['<STR_LIT:c>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>service = '<STR_LIT>'<EOL>break<EOL><DEDENT>else:<EOL><INDENT>print(red("<STR_LIT>"))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>service = '<STR_LIT>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>service = '<STR_LIT>'<EOL><DEDENT><DEDENT><DEDENT>if not r_active:<EOL><INDENT>msg = '<STR_LIT>' if auth else '<STR_LIT>'<EOL>raise RuntimeError('<STR_LIT>'.format(user=user,<EOL>repo=repo,<EOL>service=service,<EOL>msg=msg))<EOL><DEDENT>private = r.json().get('<STR_LIT>', False)<EOL>if wiki and not private:<EOL><INDENT>p = subprocess.run(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'.format(<EOL>user=user, repo=repo)], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)<EOL>if p.stderr or p.returncode:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT><DEDENT>return {<EOL>'<STR_LIT>': private,<EOL>'<STR_LIT>': service,<EOL>}<EOL>
Checks that the repository exists on GitHub.

This should be done before attempting generate a key to deploy to that
repo.

Raises ``RuntimeError`` if the repo is not valid.

Returns a dictionary with the following keys:

- 'private': Indicates whether or not the repo requires authorization to
  access. Private repos require authorization.
- 'service': For service='travis', is 'travis-ci.com' or 'travis-ci.org',
  depending on which should be used. Otherwise it is just equal to ``service``.

For service='travis', if ask=True, it will ask at the command line if both
travis-ci.org and travis-ci.com exist. If ask=False, service='travis' will
check travis-ci.com first and only check travis-ci.org if it doesn't
exist. ask=True does nothing for service='github',
service='travis-ci.com', service='travis-ci.org'.