Skip to content

Commit 8430f64

Browse files
committed
Merged pull request copitux#3 from natw/git_data
2 parents 6dfa63b + ffa3643 commit 8430f64

File tree

22 files changed

+650
-10
lines changed

22 files changed

+650
-10
lines changed

AUTHORS.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ Forked and redesign from Kenneth Reitz's repo
1111

1212
Forked from https://github.com/kennethreitz/python-github3
1313

14-
Kenneth Reitz is also the author of the awesome `requests <https://github.com/kennethreitz/requests>`_ library
15-
which `python-github3` needs it
14+
Kenneth Reitz is also the author of the awesome
15+
`requests <https://github.com/kennethreitz/requests>`_ library, which
16+
`python-github3` requires.
1617

1718
Patches and Suggestions
1819
.........................
@@ -21,3 +22,4 @@ Patches and Suggestions
2122
- Rok Garbas
2223
- Antti Kaihola <[email protected]>
2324
- Francisco Marcos <[email protected]>
25+
- Nathaniel Williams <[email protected]>

README.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ Achievements
4141
- `Users service <http://developer.github.com/v3/users/>`_
4242
- `Repos service <http://developer.github.com/v3/repos/>`_
4343
- `Gists service <http://developer.github.com/v3/gists/>`_
44+
- `Git Data service <http://developer.github.com/v3/git/>`_
4445

4546
TODO
4647
-----
4748

48-
- Services: Git Data, Issues, Orgs, Pull Requests, Events
49+
- Services: Issues, Orgs, Pull Requests, Events
4950
- Oauth authorization API (service?)
5051
- Proxy methods into resources (e.g copitux.followers())
5152

@@ -55,8 +56,12 @@ Contribute
5556
1. Fork the `repository <https://github.com/copitux/python-github3>`_
5657
2. Write a test to cover new feature or to reproduce bug
5758
3. Code with `pep8 <http://www.python.org/dev/peps/pep-0008/>`_ rules
58-
4. Add you to ``AUTHORS``
59+
4. Add yourself to ``AUTHORS``
5960
5. Pull request it
6061

61-
**Note**: I use `nose <http://readthedocs.org/docs/nose/en/latest/>`_ test environment,
62-
with `mock <http://www.voidspace.org.uk/python/mock/>`_ ``pip install nose mock``
62+
Tests
63+
-----
64+
65+
Test and docs requirements are listed in ``test_requirements.txt``.
66+
Run ``pip install -r test_requirements.txt`` to install them and ``nosetests``
67+
to run tests.

docs/git_data.rst

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
.. _Git Data service:
2+
3+
Git Data services
4+
=================
5+
6+
**Example**::
7+
8+
from pygithub3 import Github
9+
10+
gh = Github(user='someone', repo='some_repo')
11+
12+
a_blob = gh.git_data.blobs.get('a long sha')
13+
14+
dev_branch = gh.git_data.references.get('heads/add_a_thing')
15+
16+
17+
GitData
18+
-------
19+
20+
.. autoclass:: pygithub3.services.git_data.GitData
21+
:members:
22+
23+
.. attribute:: blobs
24+
25+
:ref:`Blobs service`
26+
27+
.. attribute:: commits
28+
29+
:ref:`Commits service`
30+
31+
.. attribute:: references
32+
33+
:ref:`References service`
34+
35+
.. attribute:: tags
36+
37+
:ref:`Tags service`
38+
39+
.. attribute:: trees
40+
41+
:ref:`Trees service`
42+
43+
44+
.. _Blobs service:
45+
46+
Blobs
47+
-----
48+
49+
.. autoclass:: pygithub3.services.git_data.Blobs
50+
:members:
51+
52+
53+
.. _Commits service:
54+
55+
Commits
56+
-------
57+
58+
.. autoclass:: pygithub3.services.git_data.Commits
59+
:members:
60+
61+
62+
.. _References service:
63+
64+
References
65+
----------
66+
67+
.. autoclass:: pygithub3.services.git_data.References
68+
:members:
69+
70+
71+
.. _Tags service:
72+
73+
Tags
74+
----
75+
76+
.. autoclass:: pygithub3.services.git_data.Tags
77+
:members:
78+
79+
80+
.. _Trees service:
81+
82+
Trees
83+
-----
84+
85+
.. autoclass:: pygithub3.services.git_data.Trees
86+
:members:

docs/installation.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@ Dependencies
1515
Required
1616
.........
1717

18-
This library only depends on `request library`_ module.
18+
This library depends only on the `requests`_ module.
1919

20-
If you install ``pygithub3`` with ``pip`` all is done. The best option
20+
If you install ``pygithub3`` with ``pip`` all is done. This is the best option.
2121

2222
Optional
2323
.........
2424

25-
If you want to run the test suite, you must install `nose`_ and `mock`_
25+
The test suite uses `nose`_, `mock`_, and `unittest2`_. Compiling the
26+
documentation requires `sphinx`_.
2627

27-
.. _request library: http://docs.python-requests.org/en/v0.10.6/index.html
28+
Install all of these by running ``pip install -r test_requirements.txt``. Then
29+
just run ``nosetests`` to run the tests.
30+
31+
.. _requests: http://docs.python-requests.org/en/v0.10.6/index.html
2832
.. _nose: http://readthedocs.org/docs/nose/en/latest
2933
.. _mock: http://pypi.python.org/pypi/mock
34+
.. _unittest2: http://pypi.python.org/pypi/unittest2
35+
.. _sphinx: http://sphinx.pocoo.org/

docs/services.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,6 @@ List of services
7272
users
7373
repos
7474
gists
75+
git_data
7576

7677
.. _mimetypes: http://developer.github.com/v3/mime

pygithub3/github.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ def __init__(self, **config):
1717
from pygithub3.services.users import User
1818
from pygithub3.services.repos import Repo
1919
from pygithub3.services.gists import Gist
20+
from pygithub3.services.git_data import GitData
2021
self._users = User(**config)
2122
self._repos = Repo(**config)
2223
self._gists = Gist(**config)
24+
self._git_data = GitData(**config)
2325

2426
@property
2527
def remaining_requests(self):
@@ -47,3 +49,10 @@ def gists(self):
4749
:ref:`Gists service <Gists service>`
4850
"""
4951
return self._gists
52+
53+
@property
54+
def git_data(self):
55+
"""
56+
:ref:`Git Data service <Git Data service>`
57+
"""
58+
return self._git_data

pygithub3/requests/git_data/__init__.py

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- encoding: utf-8 -*-
2+
3+
from pygithub3.requests.base import Request
4+
from pygithub3.resources.git_data import Blob
5+
6+
7+
class Get(Request):
8+
uri = 'repos/{user}/{repo}/git/blobs/{sha}'
9+
resource = Blob
10+
11+
12+
class Create(Request):
13+
uri = 'repos/{user}/{repo}/git/blobs'
14+
resource = Blob
15+
body_schema = {
16+
'schema': ('content', 'encoding'),
17+
'required': ('content', 'encoding'), # TODO: is enc really required?
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- encoding: utf-8 -*-
2+
3+
from pygithub3.requests.base import Request
4+
from pygithub3.resources.git_data import Commit
5+
6+
7+
class Get(Request):
8+
uri = 'repos/{user}/{repo}/git/commits/{sha}'
9+
resource = Commit
10+
11+
12+
class Create(Request):
13+
uri = 'repos/{user}/{repo}/git/commits'
14+
resource = Commit
15+
body_schema = {
16+
'schema': ('message', 'tree', 'parents', 'author', 'committer'),
17+
'required': ('message', 'tree', 'parents'),
18+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from pygithub3.requests.base import Request
2+
from pygithub3.resources.git_data import Reference
3+
4+
5+
class Get(Request):
6+
uri = 'repos/{user}/{repo}/git/refs/{ref}'
7+
resource = Reference
8+
9+
10+
class List(Request):
11+
uri = 'repos/{user}/{repo}/git/refs'
12+
resource = Reference
13+
14+
15+
class Create(Request):
16+
uri = 'repos/{user}/{repo}/git/refs'
17+
resource = Reference
18+
body_schema = {
19+
'schema': ('ref', 'sha'),
20+
'required': ('ref', 'sha'),
21+
}
22+
23+
class Update(Request):
24+
uri = 'repos/{user}/{repo}/git/refs/{ref}'
25+
resource = Reference
26+
body_schema = {
27+
'schema': ('sha', 'force'),
28+
'required': ('sha',),
29+
}
30+
31+
32+
class Delete(Request):
33+
uri = 'repos/{user}/{repo}/git/refs/{ref}'

0 commit comments

Comments
 (0)