List repo attributes
187843
def do_show(self, repo):
        '''
        
        '''
        self.abort_on_nonexisting_effective_repo(repo, 'show')

        repo = self.network.get_repo(repo)
        repo.print_attributes()
1262024
def format_repo_status(repo):
    
    commit = repo.commit()
    return {
        'name': os.path.basename(repo.working_dir),
        'commit': commit.hexsha,
        'timestamp': datetime.fromtimestamp(
            commit.committed_date).isoformat(),
    }
1225624
def _get_repos(self):
        
        result = {}
        for xmlpath in self.installed:
            repo = RepositorySettings(self, xmlpath)
            result[repo.name.lower()] = repo

        return result
286776
def _get_bookmark(repo, name):
    '''
    
    '''
    try:
        return [x for x in _all_bookmarks(repo) if x[0] == name][0]
    except IndexError:
        return False
290521
def list_repos(**kwargs):  # pylint: disable=unused-argument
    '''
    
    '''
    repos = {}
    regex = re.compile(REPO_REGEXP)
    for filename in os.listdir(OPKG_CONFDIR):
        if not filename.endswith(".conf"):
            continue
        with salt.utils.files.fopen(os.path.join(OPKG_CONFDIR, filename)) as conf_file:
            _read_repos(conf_file, repos, filename, regex)
    return repos
623104
def repositories(doc):
    """"""
    for repository_id, repo in doc.get('repositories', {}).items():
        repo['id'] = repository_id
        repo['organisation_id'] = doc['_id']

        yield repository_id, repo
1239233
def get_repository_names(path):
    
    return [subdir
            for subdir in os.listdir(path)
            if os.path.isdir(os.path.join(path, subdir, '.git'))]
419108
def list(self, path=None, with_metadata=False, include_partitions=False):
        ''''''
        from os import walk
        import json

        l = {}

        if not path:
            start_path = self.cache_dir
        else:
            start_path = os.path.join(self.cache_dir, path)

        for root, dirs, files in os.walk(start_path):

            root = root.replace(self.cache_dir, '', 1).strip('/')

            if root.startswith('meta') or root.startswith('_'):
                continue

            if not include_partitions and root.count('/') > 0:
                continue  # partition files

            for f in files:
                rel_path = os.path.join(root, f)
                d = self.metadata(rel_path) if with_metadata else {}

                if d and 'identity' in d:
                    d['identity'] = json.loads(d['identity'])

                d['caches'] = [self.repo_id]

                l[rel_path] = d

        if self.upstream:
            for k, v in self.upstream.list(path, with_metadata, include_partitions).items():
                upstreams = (l[k]['caches'] if k in l else []) + \
                    v.get('caches', self.upstream.repo_id)

                l[k] = v
                l[k]['caches'] = upstreams

        return l
1283829
def get_repo(repo, **kwargs):  # pylint: disable=unused-argument
    '''
    
    '''
    repos = list_repos()

    if repos:
        for source in six.itervalues(repos):
            for sub in source:
                if sub['name'] == repo:
                    return sub
    return {}
237074
def _get_configured_repos(root=None):
    '''
    
    '''

    repos = os.path.join(root, os.path.relpath(REPOS, os.path.sep)) if root else REPOS
    repos_cfg = configparser.ConfigParser()
    if os.path.exists(repos):
        repos_cfg.read([repos + '/' + fname for fname in os.listdir(repos) if fname.endswith(".repo")])
    else:
        log.warning('Repositories not found in %s', repos)

    return repos_cfg
498067
def repo_values(self):
        
        branches = []
        commits = {}
        m_helper = Tools()
        status = m_helper.repo_branches(self.parentApp.repo_value['repo'])
        # branches and commits must both be retrieved successfully
        if status[0]:
            branches = status[1]
            status = m_helper.repo_commits(self.parentApp.repo_value['repo'])
            if status[0]:
                r_commits = status[1]
                for commit in r_commits:
                    commits[commit[0]] = commit[1]
            else:
                # if commits failed, return commit errors
                return status
        else:
            # if branch failed, return branch errors
            return status
        # if everything is good, return branches with commits
        return branches, commits
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
328726
def list_content_types(repo):
    
    schema_files = glob.glob(
        os.path.join(repo.working_dir, '_schemas', '*.avsc'))
    return [os.path.splitext(os.path.basename(schema_file))[0]
            for schema_file in schema_files]
84614
def repo_commits(self, repo):
        
        commits = []
        try:
            status = self.path_dirs.apply_path(repo)
            # switch to directory where repo will be cloned to
            if status[0]:
                cwd = status[1]
            else:
                self.logger.error('apply_path failed. Exiting repo_commits with'
                                  ' status: ' + str(status))
                return status

            status = self.repo_branches(repo)
            if status[0]:
                branches = status[1]
                for branch in branches:
                    try:
                        branch_output = check_output(shlex
                                                     .split('git rev-list origin/' +
                                                            branch),
                                                     stderr=STDOUT,
                                                     close_fds=True).decode('utf-8')
                        branch_output = branch_output.split('\n')[:-1]
                        branch_output += ['HEAD']
                        commits.append((branch, branch_output))
                    except Exception as e:  # pragma: no cover
                        self.logger.error('repo_commits failed with error: ' +
                                          str(e) + ' on branch: ' +
                                          str(branch))
                        status = (False, e)
                        return status
            else:
                self.logger.error('repo_branches failed. Exiting repo_commits'
                                  ' with status: ' + str(status))
                return status

            chdir(cwd)
            status = (True, commits)
        except Exception as e:  # pragma: no cover
            self.logger.error('repo_commits failed with error: ' + str(e))
            status = (False, e)

        return status
306408
def listdir_find_repos(where):
    
    stack = deque([(convert_path(where), '')])
    while stack:
        where, prefix = stack.pop()
        try:
            for name in sorted(os.listdir(where), reverse=True):
                fn = os.path.join(where, name)
                if name in REPO_PREFIXES:
                    if 1:  # os.path.exists(fn):
                        # yield name[1:], fn.rstrip(name)[:-1] # abspath
                        repo = REPO_PREFIXES[name](fn.rstrip(name)[:-1])
                        yield repo
                    stack.append((fn, prefix + name + '/'))
        except OSError as e:
            if e.errno == errno.EACCES:
                log.error("Skipping: %s", e)
            else:
                raise
1229289
def get_repos(self):
        
        url_parameters = dict()

        return github.PaginatedList.PaginatedList(
            contentClass=github.Repository.Repository,
            requester=self._requester,
            firstUrl="/installation/repositories",
            firstParams=url_parameters,
            headers=INTEGRATION_PREVIEW_HEADERS,
            list_item='repositories'
        )
319334
def _repr_attributes(self):
        """"""
        if self._repr_attributes_override is None:
            # Default to init arguments
            attrs = getfullargspec(self.__init__).args[1:]
            mapping = self._repr_attributes_mapping
            if mapping:
                attrs = [mapping[a] if a in mapping else a for a in attrs]
            return attrs

        return self._repr_attributes_override