def fetch_metadata(self, package): github = self._github_client() username, repo_name = package.repo_name().split('/') repo = github.repos[username][repo_name]() if repo.get('message', '') == u'Not Found': return package package.repo_watchers = repo['watchers'] package.repo_forks = repo['forks'] package.repo_description = repo['description'] #/repos/:user/:repo/collaborators collaborators = [ x['login'] for x in github.repos[username][repo_name].collaborators() ] collaborators += [ x['login'] for x in github.repos[username][repo_name].contributors() ] if collaborators: package.participants = ','.join(uniquer(collaborators)) return package
def fetch_metadata(self, package): github = self._github_client() repo_name = package.repo_name() repo = github.repos.show(repo_name) package.repo_watchers = repo.watchers package.repo_forks = repo.forks package.repo_description = repo.description collaborators = github.repos.list_collaborators(repo_name) + [x['login'] for x in github.repos.list_contributors(repo_name)] if collaborators: package.participants = ','.join(uniquer(collaborators)) return package
def pull(package): github = Github() repo_name = package.repo_name() repo = github.repos.show(repo_name) package.repo_watchers = repo.watchers package.repo_forks = repo.forks package.repo_description = repo.description collaborators = github.repos.list_collaborators(repo_name) + [x['login'] for x in github.repos.list_contributors(repo_name)] if collaborators: package.participants = ','.join(uniquer(collaborators)) return package
def fetch_metadata(self, package): username, repo_name = package.repo_name().split('/') repo = self.github.repository(username, repo_name) if repo is None: return package package.repo_watchers = repo.watchers package.repo_forks = repo.forks package.repo_description = repo.description contributors = [x.login for x in repo.iter_contributors()] if contributors: package.participants = ','.join(uniquer(contributors)) return package
def fetch_metadata(self, package): github = self._github_client() username, repo_name = package.repo_name().split('/') repo = github.repos[username][repo_name]() package.repo_watchers = repo['watchers'] package.repo_forks = repo['forks'] package.repo_description = repo['description'] #/repos/:user/:repo/collaborators collaborators = [x['login'] for x in github.repos[username][repo_name].collaborators()] collaborators += [x['login'] for x in github.repos[username][repo_name].contributors()] if collaborators: package.participants = ','.join(uniquer(collaborators)) return package
def pull(package): if hasattr(settings, "GITHUB_ACCOUNT") and hasattr(settings, "GITHUB_KEY"): github = Github(username=settings.GITHUB_ACCOUNT, api_token=settings.GITHUB_KEY) else: github = Github() repo_name = package.repo_name() repo = github.repos.show(repo_name) package.repo_watchers = repo.watchers package.repo_forks = repo.forks package.repo_description = repo.description collaborators = github.repos.list_collaborators(repo_name) + [x['login'] for x in github.repos.list_contributors(repo_name)] if collaborators: package.participants = ','.join(uniquer(collaborators)) return package
def fetch_metadata(self, package): self.manage_ratelimit() repo = self._get_repo(package) if repo is None: return package package.repo_watchers = repo.watchers package.repo_forks = repo.forks package.repo_description = repo.description contributors = [] for contributor in repo.iter_contributors(): contributors.append(contributor.login) self.manage_ratelimit() if contributors: package.participants = ','.join(uniquer(contributors)) return package
def pull(package): if hasattr(settings, "GITHUB_ACCOUNT") and hasattr(settings, "GITHUB_KEY"): github = Github(username=settings.GITHUB_ACCOUNT, api_token=settings.GITHUB_KEY) else: github = Github() repo_name = package.repo_name() repo = github.repos.show(repo_name) package.repo_watchers = repo.watchers package.repo_forks = repo.forks package.repo_description = repo.description collaborators = github.repos.list_collaborators(repo_name) + [ x['login'] for x in github.repos.list_contributors(repo_name) ] if collaborators: package.participants = ','.join(uniquer(collaborators)) return package
def fetch_metadata(self, package): self.manage_ratelimit() repo_name = package.repo_name() if repo_name.endswith("/"): repo_name = repo_name[:-1] try: username, repo_name = package.repo_name().split('/') except ValueError: return package repo = self.github.repository(username, repo_name) if repo is None: return package package.repo_watchers = repo.watchers package.repo_forks = repo.forks package.repo_description = repo.description contributors = [x.login for x in repo.iter_contributors()] if contributors: package.participants = ','.join(uniquer(contributors)) return package
def test_uniquer(self): items = ['apple', 'apple', 'apple', 'banana', 'cherry'] unique_items = ['apple', 'banana', 'cherry'] self.assertEqual(uniquer(items), unique_items)
def test_uniquer(self): items = ["apple", "apple", "apple", "banana", "cherry"] unique_items = ["apple", "banana", "cherry"] self.assertEqual(uniquer(items), unique_items)