aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Medina <davidmedina9@gmail.com>2012-03-01 14:10:48 +0100
committerDavid Medina <davidmedina9@gmail.com>2012-03-01 14:10:48 +0100
commit614ed5b2acf916b71803532e499df9068b6273bd (patch)
tree9e5ed8fa41c824047e73ca7a1ede33e3e66941f2
parentRestructure modules and packages in a clean way (diff)
downloadpython-github3-614ed5b2acf916b71803532e499df9068b6273bd.tar.xz
python-github3-614ed5b2acf916b71803532e499df9068b6273bd.zip
WIP on services.repos doc
+services.repos.collaborators doc +services.repos.commits doc
-rw-r--r--docs/repos.rst14
-rw-r--r--docs/services.rst14
-rw-r--r--pygithub3/services/repos/__init__.py8
-rw-r--r--pygithub3/services/repos/collaborators.py50
-rw-r--r--pygithub3/services/repos/commits.py116
5 files changed, 190 insertions, 12 deletions
diff --git a/docs/repos.rst b/docs/repos.rst
index 2a5bbe2..f42796f 100644
--- a/docs/repos.rst
+++ b/docs/repos.rst
@@ -82,6 +82,7 @@ Collaborators
--------------
.. autoclass:: pygithub3.services.repos.Collaborators
+ :members:
.. _Commits service:
@@ -89,6 +90,7 @@ Commits
----------
.. autoclass:: pygithub3.services.repos.Commits
+ :members:
.. _Downloads service:
@@ -96,6 +98,7 @@ Downloads
------------
.. autoclass:: pygithub3.services.repos.Downloads
+ :members:
.. _Forks service:
@@ -104,6 +107,7 @@ Forks
---------
.. autoclass:: pygithub3.services.repos.Forks
+ :members:
.. _RepoKeys service:
@@ -112,6 +116,7 @@ Keys
----------
.. autoclass:: pygithub3.services.repos.Keys
+ :members:
.. _Watchers service:
@@ -120,5 +125,12 @@ Watchers
---------
.. autoclass:: pygithub3.services.repos.Watchers
+ :members:
-.. _github repo doc: http://developer.github.com/v3/repos
+.. _github repos doc: http://developer.github.com/v3/repos
+.. _github collaborators doc: http://developer.github.com/v3/repos
+.. _github commits doc: http://developer.github.com/v3/repos
+.. _github downloads doc: http://developer.github.com/v3/repos
+.. _github forks doc: http://developer.github.com/v3/repos
+.. _github watching doc: http://developer.github.com/v3/repos
+.. _github hooks doc: http://developer.github.com/v3/repos
diff --git a/docs/services.rst b/docs/services.rst
index 8611455..7dfec34 100644
--- a/docs/services.rst
+++ b/docs/services.rst
@@ -5,7 +5,7 @@ Services
start
Overview
-..........
+----------
You can access to the API requests through the different services.
@@ -28,7 +28,7 @@ from the rest**.
.. _config each service:
Config each service
-.....................................
+----------------------
Each service can be configurated with some variables (behind the scenes, each
service has her client which is configurated with this variables).
@@ -40,8 +40,16 @@ service has her client which is configurated with this variables).
.. autoclass:: pygithub3.services.base.Service
:members:
+.. _mimetypes:
+
+MimeTypes
+----------
+
+.. autoclass:: pygithub3.services.base.MimeTypeMixin
+ :members:
+
List of services
-..................
+-------------------
.. toctree::
:maxdepth: 2
diff --git a/pygithub3/services/repos/__init__.py b/pygithub3/services/repos/__init__.py
index 6e3627f..e1ed1d8 100644
--- a/pygithub3/services/repos/__init__.py
+++ b/pygithub3/services/repos/__init__.py
@@ -26,7 +26,7 @@ class Repos(Service):
""" Get user's repositories
:param str user: Username
- :param str type: Filter by type (optional). See `github repo doc`_
+ :param str type: Filter by type (optional). See `github repos doc`_
:returns: A :doc:`result`
If you call it without user and you are authenticated, get the
@@ -48,7 +48,7 @@ class Repos(Service):
""" Get organization's repositories
:param str org: Organization name
- :param str type: Filter by type (optional). See `github repo doc`_
+ :param str type: Filter by type (optional). See `github repos doc`_
:returns: A :doc:`result`
::
@@ -61,7 +61,7 @@ class Repos(Service):
def create(self, data, in_org=None):
""" Create a new repository
- :param dict data: Input. See `github repo doc`_
+ :param dict data: Input. See `github repos doc`_
:param str in_org: Organization where create the repository (optional)
.. warning::
@@ -96,7 +96,7 @@ class Repos(Service):
def update(self, data, user=None, repo=None):
""" Update a single repository
- :param dict data: Input. See `github repo doc`_
+ :param dict data: Input. See `github repos doc`_
:param str user: Username
:param str repo: Repository
diff --git a/pygithub3/services/repos/collaborators.py b/pygithub3/services/repos/collaborators.py
index 3bc4c9d..5f0703a 100644
--- a/pygithub3/services/repos/collaborators.py
+++ b/pygithub3/services/repos/collaborators.py
@@ -5,23 +5,73 @@ from . import Service
class Collaborators(Service):
+ """ Consume `Repo Collaborators API
+ <http://developer.github.com/v3/repos/collaborators>`_ """
def list(self, user=None, repo=None):
+ """ Get repository's collaborators
+
+ :param str user: Username
+ :param str repo: Repository
+ :returns: A :doc:`result`
+
+ .. note::
+
+ Remember :ref:`config precedence`
+ """
request = self.make_request('repos.collaborators.list',
user=user, repo=repo)
return self._get_result(request)
def add(self, collaborator, user=None, repo=None):
+ """ Add collaborator to a repository
+
+ :param str collaborator: Collaborator's username
+ :param str user: Username
+ :param str repo: Repository
+
+ .. note::
+
+ Remember :ref:`config precedence`
+
+ .. warning::
+
+ You must be authenticated and have perms in repository
+ """
request = self.make_request('repos.collaborators.add',
collaborator=collaborator, user=user, repo=repo)
return self._put(request)
def is_collaborator(self, collaborator, user=None, repo=None):
+ """ Check if a user is collaborator on repository
+
+ :param str collaborator: Collaborator's username
+ :param str user: Username
+ :param str repo: Repository
+
+ .. note::
+
+ Remember :ref:`config precedence`
+ """
request = self.make_request('repos.collaborators.is_collaborator',
collaborator=collaborator, user=user, repo=repo)
return self._bool(request)
def delete(self, collaborator, user=None, repo=None):
+ """ Remove collaborator from repository
+
+ :param str collaborator: Collaborator's username
+ :param str user: Username
+ :param str repo: Repository
+
+ .. note::
+
+ Remember :ref:`config precedence`
+
+ .. warning::
+
+ You must be authenticated and have perms in repository
+ """
request = self.make_request('repos.collaborators.delete',
collaborator=collaborator, user=user, repo=repo)
self._delete(request)
diff --git a/pygithub3/services/repos/commits.py b/pygithub3/services/repos/commits.py
index 3d5abb6..23e6842 100644
--- a/pygithub3/services/repos/commits.py
+++ b/pygithub3/services/repos/commits.py
@@ -5,44 +5,152 @@ from . import Service, MimeTypeMixin
class Commits(Service, MimeTypeMixin):
+ """ Consume `Commits API
+ <http://developer.github.com/v3/repos/commits>`_
- """ TODO: Pagination structure differs from usual
- def list(self, user=None, repo=None, sha='', path=''):
- request = self.make_request('repos.commits.list', user=user, repo=repo)
- return self._get_result(request, sha=sha, path=path)
+ .. note::
+ This service support :ref:`mimetypes` configuration
"""
+ #TODO: Pagination structure differs from usual
+ #def list(self, user=None, repo=None, sha='', path=''):
+ #request = self.make_request('repos.commits.list', user=user, repo=repo)
+ #return self._get_result(request, sha=sha, path=path)
+
def get(self, sha, user=None, repo=None):
+ """ Get a single commit
+
+ :param str sha: Commit's sha
+ :param str user: Username
+ :param str repo: Repository
+
+ .. note::
+
+ Remember :ref:`config precedence`
+ """
request = self.make_request('repos.commits.get',
sha=sha, user=user, repo=repo)
return self._get(request)
def list_comments(self, sha=None, user=None, repo=None):
+ """ Get commit's comments
+
+ :param str sha: Commit's sha
+ :param str user: Username
+ :param str repo: Repository
+
+ .. note::
+
+ Remember :ref:`config precedence`
+
+ If you call it without ``sha``, get all commit's comments of a
+ repository
+ ::
+
+ commits_service.list_comments('6dcb09', user='octocat',
+ repo='oct_repo')
+ commits_service.list_comments(user='octocat', repo='oct_repo')
+ """
request = self.make_request('repos.commits.list_comments',
sha=sha, user=user, repo=repo)
return self._get_result(request, **self._get_mimetype_as_header())
def create_comment(self, data, sha, user=None, repo=None):
+ """ Create a commit comment
+
+ :param dict data: Input. See `github commits doc`_
+ :param str sha: Commit's sha
+ :param str user: Username
+ :param str repo: Repository
+
+ .. note::
+
+ Remember :ref:`config precedence`
+
+ ::
+
+ data = {
+ "body": "Nice change",
+ "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
+ "line": 1,
+ "path": "file1.txt",
+ "position": 4
+ }
+ commits_service.create_comment(data, '6dcb09', user='octocat',
+ repo='oct_repo')
+ """
request = self.make_request('repos.commits.create_comment',
sha=sha, user=user, repo=repo, body=data)
return self._post(request, **self._get_mimetype_as_header())
def get_comment(self, cid, user=None, repo=None):
+ """ Get a single commit comment
+
+ :param int cid: Commit comment id
+ :param str user: Username
+ :param str repo: Repository
+
+ .. note::
+
+ Remember :ref:`config precedence`
+ """
request = self.make_request('repos.commits.get_comment',
comment_id=cid, user=user, repo=repo)
return self._get(request, **self._get_mimetype_as_header())
def update_comment(self, data, cid, user=None, repo=None):
+ """ Update a single commit comment
+
+ :param dict data: Input. See `github commits doc`_
+ :param int cid: Commit comment id
+ :param str user: Username
+ :param str repo: Repository
+
+ .. note::
+
+ Remember :ref:`config precedence`
+
+ ::
+
+ commits_service.update_comment(dict(body='nice change'), 42,
+ user='octocat', repo='oct_repo')
+ """
request = self.make_request('repos.commits.update_comment',
comment_id=cid, user=user, repo=repo, body=data)
return self._patch(request, **self._get_mimetype_as_header())
def compare(self, base, head, user=None, repo=None):
+ """ Compare two commits
+
+ :param str base: Base commit sha
+ :param str head: Head commit sha
+ :param str user: Username
+ :param str repo: Repository
+
+ .. note::
+
+ Remember :ref:`config precedence`
+
+ ::
+
+ commits_service.compare('6dcb09', 'master', user='octocat',
+ repo='oct_repo')
+ """
request = self.make_request('repos.commits.compare',
base=base, head=head, user=user, repo=repo)
return self._get(request)
def delete_comment(self, cid, user=None, repo=None):
+ """ Delete a single commit comment
+
+ :param int cid: Commit comment id
+ :param str user: Username
+ :param str repo: Repository
+
+ .. note::
+
+ Remember :ref:`config precedence`
+ """
request = self.make_request('repos.commits.delete_comment',
comment_id=cid, user=user, repo=repo)
self._delete(request)