8000 Create the StarredRepository object by sigmavirus24 · Pull Request #620 · sigmavirus24/github3.py · GitHub
[go: up one dir, main page]

Skip to content

Create the StarredRepository object #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/repos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Repository
This part of the documentation covers:

- :class:`Repository <github3.repos.repo.Repository>`
- :class:`StarredRepository <github3.repos.repo.StarredRepository>`
- :class:`Asset <github3.repos.release.Asset>`
- :class:`Branch <github3.repos.branch.Branch>`
- :class:`Contents <github3.repos.contents.Contents>`
Expand Down Expand Up @@ -45,6 +46,11 @@ Repository Objects

---------

.. autoclass:: github3.repos.repo.StarredRepository
:inherited-members:

---------

.. module:: github3.repos.branch

.. autoclass:: github3.repos.branch.Branch
Expand Down
3 changes: 2 additions & 1 deletion github3/repos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"""

from .repo import Repository
from .repo import StarredRepository

__all__ = [Repository]
__all__ = ('Repository', 'StarredRepository')
21 changes: 21 additions & 0 deletions github3/repos/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,27 @@ def weekly_commit_count(self):
return json


class StarredRepository(GitHubCore):

"""The :class:`~github3.repos.repo.StarredRepository` object.

It represents how GitHub sends back a repository a user has starred, e.g.,
from :meth:`~github3.users.User.starred_repositories`.

See also:
https://developer.github.com/v3/activity/starring/#list-repositories-being-starred

"""

def _update_attributes(self, starred_repository):
self.starred_at = self._strptime(starred_repository.get('starred_at'))
self.repository = Repository(starred_repository.get('repo'), self)
self.repo = self.repository

def _repr(self):
return '<StarredRepository [{0!r}]>'.format(self.repository)


def repo_issue_params(milestone=None,
state=None,
assignee=None,
Expand Down
6 changes: 3 additions & 3 deletions github3/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,14 @@ def starred_repositories(self, sort=None, direction=None, number=-1,
'desc'
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :class:`Repository <github3.repos.Repository>`
:returns: generator of :class:`~github3.repos.repo.StarredRepository`
"""
from .repos import Repository
from .repos import Repository, StarredRepository

params = {'sort': sort, 'direction': direction}
self._remove_none(params)
url = self.starred_urlt.expand(owner=None, repo=None)
return self._iter(int(number), url, Repository, params, etag,
return self._iter(int(number), url, StarredRepository, params, etag,
headers=Repository.STAR_HEADERS)

def subscriptions(self, number=-1, etag=None):
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_starred_repositories(self):

assert len(repos) > 0
for starred in repos:
assert isinstance(starred, github3.repos.Repository)
assert isinstance(starred, github3.repos.StarredRepository)
assert isinstance(starred.starred_at, datetime.datetime)

def test_subscriptions(self):
Expand Down
0