Skip to content
Snippets Groups Projects
Commit a2b499a4 authored by Ian Cordasco's avatar Ian Cordasco
Browse files

Merge branch 'origin/develop'

Release v0.8
parents fc6aef67 f787fc0b
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -14,3 +14,4 @@ venv/
venv*/
build/
*.egg
.env
language: python
python:
- 2.6
- 2.7
- 3.2
- 3.3
- pypy
# # command to run tests, e.g. python setup.py test
- 2.6
- 2.7
- 3.2
- 3.3
- pypy
# command to run tests, e.g. python setup.py test
before_script:
- pip install -r dev-requirements.txt
- pip install -U requests"$REQUESTS_VERSION"
# test script
script: make travis
notifications:
on_success: change
on_failure: always
 
branches:
except:
- uricore
env:
global:
- TRAVIS_GH3="True"
matrix:
- REQUESTS_VERSION="==2.0.1"
- REQUESTS_VERSION="" # Latest
Loading
Loading
@@ -3,6 +3,11 @@ Development Lead
 
- Ian Cordasco <graffatcolmingov@gmail.com>
 
Maintainer(s)
`````````````
- Barry Morrison (@esacteksab)
Requests
````````
 
Loading
Loading
@@ -48,4 +53,8 @@ Contributors
 
- Matias Bordese (@matiasb)
 
- Aleksey Ostapenko (@kbakba)
\ No newline at end of file
- Aleksey Ostapenko (@kbakba)
- Vincent Driessen (@nvie)
- Philip Chimento (@ptomato)
Loading
Loading
@@ -41,7 +41,7 @@ Guidelines for Contributing to github3.py
 
#. In case you haven't caught on, for anything you add, write tests.
 
#. Be cordial_. Seriously, if anyone who isn't cordial will be sent packing,
#. Be cordial_. Seriously, anyone who isn't cordial will be sent packing,
regardless of the value of their contributions. I will not tolerate some
contributors creating a hostile environment for others.
 
Loading
Loading
History/Changelog
=================
-----------------
0.8.0: 2014-01-03
~~~~~~~~~~~~~~~~~
- **Breaking Change** Remove legacy search API
I realize this should have been scheduled for 1.0 but I was a bit eager to
remove this.
- Use Betamax to start recording integration tests
- Add support for Releases API
- Add support for Feeds API
- Add support for Two-Factor Authentication via the API
- Add support for New Search API
- Add ``github3.search_code``, ``github3.search_issues``,
``github3.search_repositories``, ``github3.search_users``
- Add ``GitHub#search_code``, ``GitHub#search_issues``,
``GitHub#search_repositories``, ``GitHub#search_users``
- Switch to requests >= 2.0
- Totally remove all references to the Downloads API
- Fix bug in ``Repository#update_file`` where ``branch`` was not being sent to
the API. Thanks @tpetr!
- Add ``GitHub#rate_limit`` to return all of the information from the
``/rate_limit`` endpoint.
- Catch missing attributes -- ``diff_hunk``, ``original_commit_id`` -- on
``ReviewComment``.
- Add support for the Emojis endpoint
- Note deprecation of a few object attributes
- Add support for the ``ReleaseEvent``
- Add ``GitHub#iter_user_teams`` to return all of the teams the authenticated
user belongs to
 
0.7.1: 2013-09-30
-----------------
~~~~~~~~~~~~~~~~~
 
- Add dependency on uritemplate.py_ to add URITemplates to different classes.
See the documentation for attributes which are templates.
Loading
Loading
@@ -17,7 +63,7 @@ History/Changelog
.. _uritemplate.py: https://github.com/sigmavirus24/uritemplate
 
0.7.0: 2013-05-19
-----------------
~~~~~~~~~~~~~~~~~
 
- Fix ``Issue.close``, ``Issue.reopen``, and ``Issue.assign``. (Issue #106)
 
Loading
Loading
@@ -46,12 +92,12 @@ History/Changelog
u = gh.user('sigmavirus24')
 
0.6.1: 2013-04-06
-----------------
~~~~~~~~~~~~~~~~~
 
- Add equality for labels courtesy of Alejandro Gomez (@alejandrogomez)
 
0.6.0: 2013-04-05
-----------------
~~~~~~~~~~~~~~~~~
 
- Add ``sort`` and ``order`` parameters to ``github3.GitHub.search_users`` and
``github3.GitHub.search_repos``.
Loading
Loading
@@ -91,22 +137,22 @@ History/Changelog
about how equivalence is determined.
 
0.5.3: 2013-03-19
-----------------
~~~~~~~~~~~~~~~~~
 
- Add missing optional parameter to Repository.contents. Thanks @tpetr
 
0.5.2: 2013-03-02
-----------------
~~~~~~~~~~~~~~~~~
 
- Stop trying to decode the byte strings returned by ``b64decode``. Fixes #72
 
0.5.1: 2013-02-21
-----------------
~~~~~~~~~~~~~~~~~
 
- Hot fix an issue when a user doesn't have a real name set
 
0.5: 2013-02-16
---------------
~~~~~~~~~~~~~~~
 
- 100% (mock) test coverage
 
Loading
Loading
@@ -203,7 +249,7 @@ History/Changelog
.. _pengwynn/octokit: https://github.com/pengwynn/octokit
 
0.4: 2013-01-16
---------------
~~~~~~~~~~~~~~~
 
- In github3.legacy.LegacyRepo
 
Loading
Loading
@@ -235,7 +281,7 @@ History/Changelog
- 70% test coverage
 
0.3: 2013-01-01
---------------
~~~~~~~~~~~~~~~
 
- In github3.repos.Repository
 
Loading
Loading
@@ -305,7 +351,7 @@ History/Changelog
.. _types: http://developer.github.com/v3/repos/#list-organization-repositories
 
0.2: 2012-11-21
---------------
~~~~~~~~~~~~~~~
 
- MAJOR API CHANGES:
 
Loading
Loading
@@ -323,12 +369,12 @@ History/Changelog
- 50% test coverage via mock tests
 
0.1: 2012-11-13
---------------
~~~~~~~~~~~~~~~
 
- Add API for GitHub Enterprise customers.
 
0.1b2: 2012-11-10
-----------------
~~~~~~~~~~~~~~~~~
 
- Handle 500 errors better, courtesy of Kristian Glass (@doismellburning)
- Handle sending json with `%` symbols better, courtesy of Kristian Glass
Loading
Loading
@@ -337,14 +383,14 @@ History/Changelog
- Correctly display method signatures in documentation courtesy of (@seveas)
 
0.1b1: 2012-10-31
-----------------
~~~~~~~~~~~~~~~~~
 
- unit tests implemented using mock instead of hitting the GitHub API (#37)
- removed ``list_*`` functions from GitHub object
- Notifications API coverage
 
0.1b0: 2012-10-06
-----------------
~~~~~~~~~~~~~~~~~
 
- Support for the complete GitHub API (accomplished)
 
Loading
Loading
Loading
Loading
@@ -32,15 +32,15 @@ Please read the `CONTRIBUTING`_ document.
Testing
~~~~~~~
 
You can run either ``pip install -r requirements.txt`` to install the
You can run either ``pip install -r dev-requirements.txt`` to install the
following before testing or simply ``make test-deps``. It is suggested you do
this in a virtual enviroment. These need to be installed for the tests to run.
 
- expecter_ by Gary Bernhardt
- mock_ by Michael Foord
- betamax_
- coverage_ by Ned Batchelder
- mock_ by Michael Foord
 
.. _expecter: https://github.com/garybernhardt/expecter
.. _betamax: https://github.com/sigmavirus24/betamax
.. _coverage: http://nedbatchelder.com/code/coverage/
.. _mock: http://mock.readthedocs.org/en/latest/
 
Loading
Loading
@@ -63,11 +63,6 @@ Testing
 
Install the dependencies from requirements.txt e.g.:
 
::
pip install -r requirements.txt
# or make test-deps
::
 
make tests
Loading
Loading
requests==1.2.3
requests>=2.0.0,<=3.0.0
uritemplate.py==0.2.0
betamax==0.1.0
coverage==3.5.2
#coverage==3.5.2
mock==1.0.1
pytest==2.3.5
wheel==0.21.0
git+git://github.com/sigmavirus24/betamax
Loading
Loading
@@ -129,19 +129,20 @@ Or you can simply use the following functions
 
------
 
.. autofunction:: github3.search_issues
.. autofunction:: github3.search_code
 
------
 
.. autofunction:: github3.search_repos
.. autofunction:: github3.search_issues
 
------
 
.. autofunction:: github3.search_users
.. autofunction:: github3.search_repositories
 
------
 
.. autofunction:: github3.search_email
.. autofunction:: github3.search_users
 
------
 
Loading
Loading
Loading
Loading
@@ -53,3 +53,9 @@ Creating an anonymous gist
# Which of course it didn't, because you're not logged in
# comment == None
print(gist.html_url)
In the above examples ``'spam.txt'`` is the file name. GitHub will auto-detect
file type based on extension provided. ``'What... is the air-speed velocity of
an unladen swallow?'`` is the file's content or body. ``'Answer this to cross
the bridge'`` is the gists's description. While required by github3.py, it is
allowed to be empty, e.g., ``''`` is accepted by GitHub.
Loading
Loading
@@ -72,11 +72,11 @@ Modules
git
github
issues
legacy
models
orgs
pulls
repos
search_structs
structs
users
 
Loading
Loading
@@ -109,8 +109,11 @@ Dependencies
~~~~~~~~~~~~
 
- requests_ by Kenneth Reitz
- uritemplate.py_ by Ian Cordasco
 
.. _requests: https://github.com/kennethreitz/requests
.. _uritemplate.py: https://github.com/sigmavirus24/uritemplate
 
Contributing
------------
Loading
Loading
@@ -148,11 +151,12 @@ Running the Unittests
mkdir -p /path/to/virtualenv/github3.py
cd /path/to/virtualenv/github3.py
virtualenv .
cd /path/to/github3.py_repo/requirements.txt
pip install -r requirements.txt
cd /path/to/github3.py_repo/
pip install -r dev-requirements.txt
# Or you could run make test-deps
make tests
 
.. toctree::
 
testing
Loading
Loading
.. module:: github3
.. module:: github3.legacy
Legacy
======
This part of the documentation covers the legacy objects used in the Search_
section of the API.
Legacy Objects
--------------
.. autoclass:: LegacyIssue
:inherited-members:
------
.. autoclass:: LegacyRepo
:inherited-members:
------
.. autoclass:: LegacyUser
:inherited-members:
.. _Search: http://developer.github.com/v3/search/
Loading
Loading
@@ -8,13 +8,13 @@ This part of the documentation covers:
- :class:`Repository <github3.repos.repo.Repository>`
- :class:`Branch <github3.repos.branch.Branch>`
- :class:`Contents <github3.repos.contents.Contents>`
- :class:`Download <github3.repos.download.Download>`
- :class:`Hook <github3.repos.hook.Hook>`
- :class:`RepoTag <github3.repos.tag.RepoTag>`
- :class:`RepoComment <github3.repos.comment.RepoComment>`
- :class:`RepoCommit <github3.repos.commit.RepoCommit>`
- :class:`Comparison <github3.repos.comparison.Comparison>`
- :class:`Status <github3.repos.status.Status>`
- :class:`ContributorStats <github3.repos.stats.ContributorStats>`
 
None of these objects should be instantiated directly by the user (developer).
These are here for reference only.
Loading
Loading
@@ -46,9 +46,10 @@ Repository Objects
 
---------
 
.. autoclass:: github3.repos.download.Download
.. autoclass:: github3.repos.release.Release
:members:
 
---------
 
.. autoclass:: github3.repos.hook.Hook
Loading
Loading
@@ -81,3 +82,8 @@ about `comments <http://developer.github.com/v3/repos/comments/>`_.
 
.. autoclass:: github3.repos.status.Status
:members:
---------
.. autoclass:: github3.repos.stats.ContributorStats
:members:
.. module:: github3
.. module:: github3.search
Search Structures
=================
These classes are meant to expose the entirety of an item returned as a search
result by GitHub's Search API.
Objects
-------
.. autoclass:: CodeSearchResult
:members:
.. autoclass:: IssueSearchResult
:members:
.. autoclass:: RepositorySearchResult
:members:
.. autoclass:: UserSearchResult
:members:
Loading
Loading
@@ -23,3 +23,7 @@ Objects
 
.. autoclass:: GitHubIterator
:inherited-members:
.. autoclass:: SearchIterator
:inherited-members:
This diff is collapsed.
# -*- coding: utf-8 -*-
"""
github3
=======
Loading
Loading
@@ -13,7 +14,7 @@ __title__ = 'github3'
__author__ = 'Ian Cordasco'
__license__ = 'Modified BSD'
__copyright__ = 'Copyright 2012-2013 Ian Cordasco'
__version__ = '0.7.1'
__version__ = '0.8.0'
__version_info__ = tuple(int(i) for i in __version__.split('.'))
 
from github3.api import *
Loading
Loading
# -*- coding: utf-8 -*-
"""
github3.api
===========
Loading
Loading
@@ -54,6 +55,11 @@ def login(username=None, password=None, token=None, url=None):
return g
 
 
def emojis():
return gh.emojis()
emojis.__doc__ = gh.emojis.__doc__
def gist(id_num):
"""Retrieve the gist identified by ``id_num``.
 
Loading
Loading
@@ -343,56 +349,231 @@ def pull_request(owner, repository, number):
return gh.pull_request(owner, repository, number)
 
 
def rate_limit():
return gh.rate_limit()
rate_limit.__doc__ = gh.rate_limit.__doc__
def repository(owner, repository):
return gh.repository(owner, repository)
repository.__doc__ = gh.repository.__doc__
 
 
def search_issues(owner, repo, state, keyword):
"""Find issues by state and keyword.
def ratelimit_remaining():
"""Get the remaining number of requests allowed.
 
:param str owner: (required)
:param str repo: (required)
:param str state: (required), accepted values: ('open', 'closed')
:param str keyword: (required), what to search for
:param int start_page: (optional), page to get (results come 100/page)
:returns: list of :class:`LegacyIssue <github3.legacy.LegacyIssue>`
:returns: int
 
"""
return gh.search_issues(owner, repo, state, keyword)
def search_repos(keyword, **params):
"""Search all repositories by keyword.
return gh.ratelimit_remaining
 
:param str keyword: (required)
:param str language: (optional), language to filter by
:param int start_page: (optional), page to get (results come 100/page)
:returns: list of :class:`LegacyRepo <github3.legacy.LegacyRepo>`
 
def search_code(query, sort=None, order=None, per_page=None,
text_match=False, number=-1, etag=None):
"""Find code via the code search API.
.. warning::
You will only be able to make 5 calls with this or other search
functions. To raise the rate-limit on this set of endpoints, create an
authenticated :class:`GitHub <github3.github.GitHub>` Session with
``login``.
The query can contain any combination of the following supported
qualifiers:
- ``in`` Qualifies which fields are searched. With this qualifier you
can restrict the search to just the file contents, the file path, or
both.
- ``language`` Searches code based on the language its written in.
- ``fork`` Specifies that code from forked repositories should be
searched. Repository forks will not be searchable unless the fork
has more stars than the parent repository.
- ``size`` Finds files that match a certain size (in bytes).
- ``path`` Specifies the path that the resulting file must be at.
- ``extension`` Matches files with a certain extension.
- ``user`` or ``repo`` Limits searches to a specific user or
repository.
For more information about these qualifiers, see: http://git.io/-DvAuA
:param str query: (required), a valid query as described above, e.g.,
``addClass in:file language:js repo:jquery/jquery``
:param str sort: (optional), how the results should be sorted;
option(s): ``indexed``; default: best match
:param str order: (optional), the direction of the sorted results,
options: ``asc``, ``desc``; default: ``desc``
:param int per_page: (optional)
:param bool text_match: (optional), if True, return matching search
terms. See http://git.io/4ct1eQ for more information
:param int number: (optional), number of repositories to return.
Default: -1, returns all available repositories
:param str etag: (optional), previous ETag header value
:return: generator of :class:`CodeSearchResult
<github3.search.CodeSearchResult>`
"""
return gh.search_repos(keyword, **params)
def search_users(keyword):
"""Search all users by keyword.
:param str keyword: (required)
:param int start_page: (optional), page to get (results come 100/page)
:returns: list of :class:`LegacyUser <github3.legacy.LegacyUser>`
return gh.search_code(query, sort, order, per_page, text_match, number,
etag)
def search_issues(query, sort=None, order=None, per_page=None,
text_match=False, number=-1, etag=None):
"""Find issues by state and keyword
.. warning::
You will only be able to make 5 calls with this or other search
functions. To raise the rate-limit on this set of endpoints, create an
authenticated :class:`GitHub <github3.github.GitHub>` Session with
``login``.
The query can contain any combination of the following supported
qualifers:
- ``type`` With this qualifier you can restrict the search to issues or
pull request only.
- ``in`` Qualifies which fields are searched. With this qualifier you can
restrict the search to just the title, body, comments, or any
combination of these.
- ``author`` Finds issues created by a certain user.
- ``assignee`` Finds issues that are assigned to a certain user.
- ``mentions`` Finds issues that mention a certain user.
- ``commenter`` Finds issues that a certain user commented on.
- ``involves`` Finds issues that were either created by a certain user,
assigned to that user, mention that user, or were commented on by that
user.
- ``state`` Filter issues based on whether theyre open or closed.
- ``labels`` Filters issues based on their labels.
- ``language`` Searches for issues within repositories that match a
certain language.
- ``created`` or ``updated`` Filters issues based on times of creation, or
when they were last updated.
- ``comments`` Filters issues based on the quantity of comments.
- ``user`` or ``repo`` Limits searches to a specific user or repository.
For more information about these qualifiers, see: http://git.io/d1oELA
:param str query: (required), a valid query as described above, e.g.,
``windows label:bug``
:param str sort: (optional), how the results should be sorted;
options: ``created``, ``comments``, ``updated``; default: best match
:param str order: (optional), the direction of the sorted results,
options: ``asc``, ``desc``; default: ``desc``
:param int per_page: (optional)
:param bool text_match: (optional), if True, return matching search
terms. See http://git.io/QLQuSQ for more information
:param int number: (optional), number of issues to return.
Default: -1, returns all available issues
:param str etag: (optional), previous ETag header value
:return: generator of :class:`IssueSearchResult
<github3.search.IssueSearchResult>`
"""
return gh.search_users(keyword)
def search_email(email):
"""Search users by email.
:param str email: (required)
:returns: :class:`LegacyUser <github3.legacy.LegacyUser>`
return gh.search_issues(query, sort, order, per_page, text_match,
number, etag)
def search_repositories(query, sort=None, order=None, per_page=None,
text_match=False, number=-1, etag=None):
"""Find repositories via various criteria.
.. warning::
You will only be able to make 5 calls with this or other search
functions. To raise the rate-limit on this set of endpoints, create an
authenticated :class:`GitHub <github3.github.GitHub>` Session with
``login``.
The query can contain any combination of the following supported
qualifers:
- ``in`` Qualifies which fields are searched. With this qualifier you
can restrict the search to just the repository name, description,
readme, or any combination of these.
- ``size`` Finds repositories that match a certain size (in
kilobytes).
- ``forks`` Filters repositories based on the number of forks, and/or
whether forked repositories should be included in the results at
all.
- ``created`` or ``pushed`` Filters repositories based on times of
creation, or when they were last updated. Format: ``YYYY-MM-DD``.
Examples: ``created:<2011``, ``pushed:<2013-02``,
``pushed:>=2013-03-06``
- ``user`` or ``repo`` Limits searches to a specific user or
repository.
- ``language`` Searches repositories based on the language they're
written in.
- ``stars`` Searches repositories based on the number of stars.
For more information about these qualifiers, see: http://git.io/4Z8AkA
:param str query: (required), a valid query as described above, e.g.,
``tetris language:assembly``
:param str sort: (optional), how the results should be sorted;
options: ``stars``, ``forks``, ``updated``; default: best match
:param str order: (optional), the direction of the sorted results,
options: ``asc``, ``desc``; default: ``desc``
:param int per_page: (optional)
:param bool text_match: (optional), if True, return matching search
terms. See http://git.io/4ct1eQ for more information
:param int number: (optional), number of repositories to return.
Default: -1, returns all available repositories
:param str etag: (optional), previous ETag header value
:return: generator of :class:`Repository <github3.repos.Repository>`
"""
return gh.search_repositories(query, sort, order, per_page, text_match,
number, etag)
def search_users(query, sort=None, order=None, per_page=None,
text_match=False, number=-1, etag=None):
"""Find users via the Search API.
.. warning::
You will only be able to make 5 calls with this or other search
functions. To raise the rate-limit on this set of endpoints, create an
authenticated :class:`GitHub <github3.github.GitHub>` Session with
``login``.
The query can contain any combination of the following supported
qualifers:
- ``type`` With this qualifier you can restrict the search to just
personal accounts or just organization accounts.
- ``in`` Qualifies which fields are searched. With this qualifier you
can restrict the search to just the username, public email, full
name, or any combination of these.
- ``repos`` Filters users based on the number of repositories they
have.
- ``location`` Filter users by the location indicated in their
profile.
- ``language`` Search for users that have repositories that match a
certain language.
- ``created`` Filter users based on when they joined.
- ``followers`` Filter users based on the number of followers they
have.
For more information about these qualifiers see: http://git.io/wjVYJw
:param str query: (required), a valid query as described above, e.g.,
``tom repos:>42 followers:>1000``
:param str sort: (optional), how the results should be sorted;
options: ``followers``, ``repositories``, or ``joined``; default:
best match
:param str order: (optional), the direction of the sorted results,
options: ``asc``, ``desc``; default: ``desc``
:param int per_page: (optional)
:param bool text_match: (optional), if True, return matching search
terms. See http://git.io/_V1zRwa for more information
:param int number: (optional), number of search results to return;
Default: -1 returns all available
:param str etag: (optional), ETag header value of the last request.
:return: generator of :class:`UserSearchResult
<github3.search.UserSearchResult>`
"""
return gh.search_email(email)
return gh.search_users(query, sort, order, per_page, text_match, number,
etag)
 
 
def user(login):
Loading
Loading
@@ -400,15 +581,6 @@ def user(login):
user.__doc__ = gh.user.__doc__
 
 
def ratelimit_remaining():
"""Get the remaining number of requests allowed.
:returns: int
"""
return gh.ratelimit_remaining
def zen():
"""Return a quote from the Zen of GitHub. Yet another API Easter Egg.
 
Loading
Loading
# -*- coding: utf-8 -*-
"""
github3.auths
=============
Loading
Loading
@@ -57,12 +58,6 @@ class Authorization(GitHubCore):
def __repr__(self):
return '<Authorization [{0}]>'.format(self.name)
 
def __eq__(self, other):
return self.id == other.id
def __ne__(self, other):
return self.id != other.id
def _update_(self, auth):
self.__init__(auth, self._session)
 
Loading
Loading
# -*- coding: utf-8 -*-
"""
github3.decorators
==================
Loading
Loading
# -*- coding: utf-8 -*-
"""
github3.events
==============
Loading
Loading
@@ -57,12 +58,6 @@ class Event(GitHubObject):
def __repr__(self):
return '<Event [{0}]>'.format(self.type[:-5])
 
def __eq__(self, other):
return self.id == other.id
def __ne__(self, other):
return self.id != other.id
@staticmethod
def list_types():
"""List available payload types"""
Loading
Loading
@@ -85,13 +80,6 @@ def _commitcomment(payload):
return payload
 
 
def _download(payload):
from github3.repos.download import Download
if payload.get('download'):
payload['download'] = Download(payload['download'], None)
return payload
def _follow(payload):
from github3.users import User
if payload.get('target'):
Loading
Loading
@@ -151,6 +139,14 @@ def _pullreqcomm(payload):
return payload
 
 
def _release(payload):
from github3.repos.release import Release
release = payload.get('release')
if release:
payload['release'] = Release(release)
return payload
def _team(payload):
from github3.orgs import Team
from github3.repos import Repository
Loading
Loading
@@ -172,7 +168,6 @@ _payload_handlers = {
'CommitCommentEvent': _commitcomment,
'CreateEvent': identity,
'DeleteEvent': identity,
'DownloadEvent': _download,
'FollowEvent': _follow,
'ForkEvent': _forkev,
'ForkApplyEvent': identity,
Loading
Loading
@@ -185,6 +180,8 @@ _payload_handlers = {
'PullRequestEvent': _pullreqev,
'PullRequestReviewCommentEvent': _pullreqcomm,
'PushEvent': identity,
'ReleaseEvent': _release,
'StatusEvent': identity,
'TeamAddEvent': _team,
'WatchEvent': identity,
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment