Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_instance_for_repo(repo):
holder_class = HolderFactory.HOLDERS['github']
hostname = None
known_repo = None
for k, sc in HolderFactory.HOLDERS.items():
known_repo = sc.is_official_for_repo(repo)
if known_repo:
holder_class = sc
log.info('Using {} adapter'.format(k))
break
# TODO now easy multiple default hostnames per holder
hostname = sc.get_matching_hostname(repo)
if hostname:
holder_class = sc
break
if known_repo:
repo = known_repo['repo']
# known repo tells us hosted domain of e.g. mercurical web
if 'hostname' in known_repo:
hostname = known_repo['hostname']
elif repo.startswith(('https://', 'http://')):