Return dictionary with default repo name and url
357429
def default_repository(self):
        
        default_dict_repo = {}
        for line in self.default_repositories_list.splitlines():
            line = line.lstrip()
            if not line.startswith("#"):
                if line.split()[0] in self.DEFAULT_REPOS_NAMES:
                    default_dict_repo[line.split()[0]] = line.split()[1]
                else:
                    print("\nslpkg: Error: Repository name '{0}' is not "
                          "default.\n              Please check file: "
                          "/etc/slpkg/default-repositories\n".format(
                              line.split()[0]))
                    raise SystemExit()
        return default_dict_repo
179857
def custom_repository(self):
        
        custom_dict_repo = {}
        for line in self.custom_repositories_list.splitlines():
            line = line.lstrip()
            if not line.startswith("#"):
                custom_dict_repo[line.split()[0]] = line.split()[1]
        return custom_dict_repo
370410
def repo_context(url, branch=None, quiet=True, dest_ctx=temp_dir):
	
	exe = 'git' if 'git' in url else 'hg'
	with dest_ctx() as repo_dir:
		cmd = [exe, 'clone', url, repo_dir]
		if branch:
			cmd.extend(['--branch', branch])
		devnull = open(os.path.devnull, 'w')
		stdout = devnull if quiet else None
		subprocess.check_call(cmd, stdout=stdout)
		yield repo_dir
439146
def get_image_uri(region_name, repo_name, repo_version=1):
    """"""
    repo = '{}:{}'.format(repo_name, repo_version)
    return '{}/{}'.format(registry(region_name, repo_name), repo)
907420
def parse_url(self):
        """"""
        url = urlparse(self.url).path

        # handle git
        url = url.split('.git')[0]

        if ':' in url:
            url = url.split(':')[1]

        # Ony capture last two list items
        try:
            project, repo = url.split('/')[-2:]
        except ValueError:
            raise ParserError('"{}" is not a valid repository URL.'.format(self.url))

        return project, repo
403401
def get_path(self, repo):
        
        if repo.endswith('.git'):
            repo = repo.split('.git')[0]
        org, name = repo.split('/')[-2:]
        path = self.plugins_dir
        path = join(path, org, name)
        return path, org, name
1057097
def to_package(self, repo_url):
        """"""
        return Package(name=self.name, url=repo_url + self.name)
1269206
def get_default_repo(self):
        
        for repo in self.get_repos():
            if self.get_safe(repo, 'default') and self.getboolean(repo, 'default'):
                return repo
        return False
749449
def get_repos(path):
    
    p = str(path)
    ret = []
    if not os.path.exists(p):
        return ret
    for d in os.listdir(p):
        pd = os.path.join(p, d)
        if os.path.exists(pd) and is_repo(pd):
            ret.append(Local(pd))
    return ret
1347780
def repository(name):
    """"""
    user_id = current_user.id
    github = GitHubAPI(user_id=user_id)
    token = github.session_token

    if token:
        repos = github.account.extra_data.get('repos', [])
        repo = next((repo for repo_id, repo in repos.items()
                     if repo.get('full_name') == name), {})
        if not repo:
            abort(403)

        try:
            # NOTE: Here we do not check for repository ownership, since it
            # might have changed even though the user might have made releases
            # in the past.
            repo_instance = Repository.get(user_id=user_id,
                                           github_id=repo['id'],
                                           check_owner=False)
        except RepositoryAccessError:
            abort(403)
        except NoResultFound:
            repo_instance = Repository(name=repo['full_name'],
                                       github_id=repo['id'])

        releases = [
            current_github.release_api_class(r) for r in (
                repo_instance.releases.order_by(db.desc(Release.created)).all()
                if repo_instance.id else []
            )
        ]
        return render_template(
            current_app.config['GITHUB_TEMPLATE_VIEW'],
            repo=repo_instance,
            releases=releases,
            serializer=current_github.record_serializer,
        )

    abort(403)
799907
def where(i):
    

    o=i.get('out','')

    duoa=i.get('data_uoa','')
    r=ck.find_path_to_repo({'repo_uoa':duoa})
    if r['return']>0: return r

    d=r.get('dict',{})
    url=d.get('url','')

    p=r['path']
    if p=='':
       p=url

    if o=='con':
       ck.out(p)

    return r
804880
def get_commit_url(repo_url):
    """"""
    if "github.com" in repo_url:
        return repo_url[:-4] if repo_url.endswith(".git") else repo_url
    if "git.openstack.org" in repo_url:
        uri = '/'.join(repo_url.split('/')[-2:])
        return "https://github.com/{0}".format(uri)

    # If it didn't match these conditions, just return it.
    return repo_url
1226997
def show_repo(self, repo_names=[], envs=[], query='/repositories/'):
        
        juicer.utils.Log.log_debug("Show Repo(s): %s", str(repo_names))

        repo_objects = {}
        for env in envs:
            repo_objects[env] = []

        for env in envs:
            juicer.utils.Log.log_debug("scanning environment: %s", env)
            for repo_name in repo_names:
                juicer.utils.Log.log_debug("looking for repo: %s", repo_name)
                url = "%s%s-%s/?details=true" % (query, repo_name, env)
                _r = self.connectors[env].get(url)
                if _r.status_code == Constants.PULP_GET_OK:
                    juicer.utils.Log.log_debug("found repo: %s", repo_name)
                    repo = juicer.utils.load_json_str(_r.content)
                    repo_object = PulpRepo(repo_name, env, repo_def=repo)
                    repo_objects[env].append(repo_object)
                else:
                    if _r.status_code == Constants.PULP_GET_NOT_FOUND:
                        juicer.utils.Log.log_warn("could not find repo '%s' in %s" % (repo_name, env))
                    else:
                        _r.raise_for_status()
        for k, v in repo_objects.iteritems():
            juicer.utils.Log.log_debug("environment %s: found %d repos" % (k, len(v)))
        return repo_objects
1029974
def require_repo(directory=None):
    """"""
    if directory and not os.path.isdir(directory):
        raise ValueError('Directory not found: ' + repr(directory))
    repo = repo_path(directory)
    if not os.path.isdir(repo):
        raise RepositoryNotFoundError(directory)
    return repo
124817
def _repo_url_to_path(self, repo):
        """"""
        repo = repo.replace('http://', '')
        repo = repo.replace('https://', '')
        repo = repo.replace('/', '_')

        return os.sep.join([self._data_directory, repo])
628500
def get_configuration_dict(self, secret_attrs=False):
        """"""
        rd = {'name': self.name,
              'path': self.path,
              'git_dir': self.git_dir,
              'assumed_doc_version': self.assumed_doc_version,
              'doc_dir': self.doc_dir,
              'git_ssh': self.git_ssh, }
        if secret_attrs:
            rd['pkey'] = self.pkey
        with self._index_lock:
            si = self._doc_index
        r = _invert_dict_list_val(si)
        key_list = list(r.keys())
        rd['number of documents'] = len(key_list)
        key_list.sort()
        m = []
        for k in key_list:
            v = r[k]
            fp = k[2]
            assert fp.startswith(self.doc_dir)
            rp = fp[len(self.doc_dir) + 1:]
            m.append({'keys': v, 'relpath': rp})
        rd['documents'] = m
        return rd
802509
def _read_repos(conf_file, repos, filename, regex):
    '''
    
    '''
    for line in conf_file:
        line = salt.utils.stringutils.to_unicode(line)
        if not regex.search(line):
            continue
        repo = _create_repo(line, filename)

        # do not store duplicated uri's
        if repo['uri'] not in repos:
            repos[repo['uri']] = [repo]