mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Merge branch 'develop'
This commit is contained in:
@@ -3,7 +3,6 @@ python:
|
||||
- "2.7"
|
||||
- "2.6"
|
||||
- "2.5"
|
||||
- "3.1"
|
||||
- "3.2"
|
||||
install:
|
||||
- if [ $TRAVIS_PYTHON_VERSION == '2.5' ]; then pip install -r python25-requirements.txt --use-mirrors; fi
|
||||
|
||||
@@ -13,14 +13,13 @@ What's new?
|
||||
|
||||
[](https://travis-ci.org/jacquev6/PyGithub)
|
||||
|
||||
[Version 1.10.0](https://github.com/jacquev6/PyGithub/issues?milestone=16&state=closed) (December 25th, 2012) (Christmas 2012 edition)
|
||||
--------------------------------------------------------------------------------------------------------------------------------------
|
||||
[Version 1.11.0](https://github.com/jacquev6/PyGithub/issues?milestone=19&state=closed) (January 31st, 2013)
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
* Major improvement: support Python 3! PyGithub is automaticaly tested on [Travis](http://travis-ci.org/jacquev6/PyGithub) with versions 2.5, 2.6, 2.7, 3.1 and 3.2 of Python
|
||||
* Add a shortcut function `Github.get_repo` to get a repo directly from its full name. thank you [lwc](https://github.com/lwc) for the contribution
|
||||
* `Github.get_gitignore_templates` and `Github.get_gitignore_template` for APIs `/gitignore/templates`
|
||||
* Add the optional `ref` parameter to `Repository.get_contents` and `get_readme`. Thank you [fixxxeruk](https://github.com/fixxxeruk) for the contribution
|
||||
* Get comments for all issues and all pull requests on a repository (`GET /repos/:user/:repo/pulls/comments`: `Repository.get_pulls_comments` or `Repository.get_pulls_review_comments`; `GET /repos/:user/:repo/issues/comments`: `Repository.get_issues_comments`)
|
||||
* Fix bug in PaginatedList without url parameters. Thank you [llimllib](https://github.com/llimllib) for the [contribution](https://github.com/jacquev6/PyGithub/pull/133)
|
||||
* [Implement](https://github.com/jacquev6/PyGithub/issues/130) `NamedUser.get_keys`
|
||||
* [Support PubSubHub](https://github.com/jacquev6/PyGithub/issues/129): `Repository.subscribe_to_hub` and `Repository.unsubscribe_from_hub`
|
||||
* [Publish the oauth scopes](https://github.com/jacquev6/PyGithub/issues/134) in Github.oauth_scopes, thank you [ bilderbuchi](https://github.com/ bilderbuchi) for asking
|
||||
|
||||
Previous versions
|
||||
-----------------
|
||||
@@ -75,6 +74,7 @@ Projects using PyGithub
|
||||
([Open an issue](https://github.com/jacquev6/PyGithub/issues) if you want to be listed here, I'll be glad to add your project)
|
||||
|
||||
* [Upverter](https://upverter.com) is a web-based schematic capture and PCB layout tool for people who design electronics. Designers can attach a Github project to an Upverter project.
|
||||
* [Notifico](http://n.tkte.ch) receives messages (such as commits and issues) from services and scripts and delivers them to IRC channels. It can import/sync from Github.
|
||||
* [Tratihubis](http://pypi.python.org/pypi/tratihubis/) converts Trac tickets to Github issues
|
||||
* https://github.com/CMB/cligh
|
||||
* https://github.com/natduca/quickopen uses PyGithub to automaticaly create issues
|
||||
|
||||
@@ -65,6 +65,10 @@ API `/hooks`
|
||||
============
|
||||
* GET: `Github.get_hooks`
|
||||
|
||||
API `/hub`
|
||||
============
|
||||
* POST: `Repository.subscribe_to_hub` or `Repository.unsubscribe_from_hub`
|
||||
|
||||
API `/issues`
|
||||
=============
|
||||
* GET: `AuthenticatedUser.get_issues`
|
||||
@@ -577,6 +581,10 @@ API `/users/:user/gists`
|
||||
* GET: `NamedUser.get_gists`
|
||||
* POST: `NamedUser.create_gist`
|
||||
|
||||
API `/users/:user/keys`
|
||||
=======================
|
||||
* GET: `NamedUser.get_keys`
|
||||
|
||||
API `/users/:user/orgs`
|
||||
=======================
|
||||
* GET: `NamedUser.get_orgs`
|
||||
|
||||
@@ -20,6 +20,7 @@ Another argument, that can be passed is `timeout` which has default value `10`.
|
||||
Attributes
|
||||
----------
|
||||
* `rate_limiting`: tuple of two integers: remaining and limit, as explained in [Rate Limiting](http://developer.github.com/v3/#rate-limiting)
|
||||
* `oauth_scopes`: None or list of string: when using oauth, after the first request, the list of scopes of the token (see http://developer.github.com/v3/oauth/#scopes)
|
||||
|
||||
Methods
|
||||
-------
|
||||
@@ -896,6 +897,10 @@ Orgs
|
||||
----
|
||||
* `get_orgs()`: `PaginatedList` of `Organization`
|
||||
|
||||
Keys
|
||||
----
|
||||
* `get_keys()`: `PaginatedList` of `UserKey`
|
||||
|
||||
Repos
|
||||
-----
|
||||
* `get_repo( name )`: `Repository`
|
||||
@@ -1416,6 +1421,16 @@ Modification
|
||||
* `has_downloads`: bool
|
||||
* `default_branch`: string
|
||||
|
||||
PubSubHubbub
|
||||
------------
|
||||
* `subscribe_to_hub( event, callback, [secret] )`
|
||||
* `event`: string
|
||||
* `callback`: string
|
||||
* `secret`: string
|
||||
* `unsubscribe_from_hub( event, callback )`
|
||||
* `event`: string
|
||||
* `callback`: string
|
||||
|
||||
Pulls
|
||||
-----
|
||||
* `create_pull( < title, body, base, head > or < issue, base, head > )`: `PullRequest`
|
||||
|
||||
+24
-24
@@ -156,7 +156,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
def add_to_emails(self, *emails):
|
||||
assert all(isinstance(element, (str, unicode)) for element in emails), emails
|
||||
post_parameters = emails
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
"/user/emails",
|
||||
None,
|
||||
@@ -165,7 +165,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def add_to_following(self, following):
|
||||
assert isinstance(following, github.NamedUser.NamedUser), following
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
"/user/following/" + following._identity,
|
||||
None,
|
||||
@@ -174,7 +174,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def add_to_starred(self, starred):
|
||||
assert isinstance(starred, github.Repository.Repository), starred
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
"/user/starred/" + starred._identity,
|
||||
None,
|
||||
@@ -183,7 +183,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def add_to_subscriptions(self, subscription):
|
||||
assert isinstance(subscription, github.Repository.Repository), subscription
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
"/user/subscriptions/" + subscription._identity,
|
||||
None,
|
||||
@@ -192,7 +192,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def add_to_watched(self, watched):
|
||||
assert isinstance(watched, github.Repository.Repository), watched
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
"/user/watched/" + watched._identity,
|
||||
None,
|
||||
@@ -216,7 +216,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
post_parameters["client_id"] = client_id
|
||||
if client_secret is not github.GithubObject.NotSet:
|
||||
post_parameters["client_secret"] = client_secret
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
"/authorizations",
|
||||
None,
|
||||
@@ -226,7 +226,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def create_fork(self, repo):
|
||||
assert isinstance(repo, github.Repository.Repository), repo
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
"/repos/" + repo.owner.login + "/" + repo.name + "/forks",
|
||||
None,
|
||||
@@ -244,7 +244,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
}
|
||||
if description is not github.GithubObject.NotSet:
|
||||
post_parameters["description"] = description
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
"/gists",
|
||||
None,
|
||||
@@ -259,7 +259,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
"title": title,
|
||||
"key": key,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
"/user/keys",
|
||||
None,
|
||||
@@ -296,7 +296,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
post_parameters["auto_init"] = auto_init
|
||||
if gitignore_template is not github.GithubObject.NotSet:
|
||||
post_parameters["gitignore_template"] = gitignore_template
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
"/user/repos",
|
||||
None,
|
||||
@@ -327,7 +327,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
post_parameters["hireable"] = hireable
|
||||
if bio is not github.GithubObject.NotSet:
|
||||
post_parameters["bio"] = bio
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
"/user",
|
||||
None,
|
||||
@@ -337,7 +337,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def get_authorization(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/authorizations/" + str(id),
|
||||
None,
|
||||
@@ -354,7 +354,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
)
|
||||
|
||||
def get_emails(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/user/emails",
|
||||
None,
|
||||
@@ -404,7 +404,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def get_key(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/user/keys/" + str(id),
|
||||
None,
|
||||
@@ -439,7 +439,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def get_repo(self, name):
|
||||
assert isinstance(name, (str, unicode)), name
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/repos/" + self.login + "/" + name,
|
||||
None,
|
||||
@@ -499,7 +499,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def has_in_following(self, following):
|
||||
assert isinstance(following, github.NamedUser.NamedUser), following
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
status, headers, data = self._requester.requestJson(
|
||||
"GET",
|
||||
"/user/following/" + following._identity,
|
||||
None,
|
||||
@@ -509,7 +509,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def has_in_starred(self, starred):
|
||||
assert isinstance(starred, github.Repository.Repository), starred
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
status, headers, data = self._requester.requestJson(
|
||||
"GET",
|
||||
"/user/starred/" + starred._identity,
|
||||
None,
|
||||
@@ -519,7 +519,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def has_in_subscriptions(self, subscription):
|
||||
assert isinstance(subscription, github.Repository.Repository), subscription
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
status, headers, data = self._requester.requestJson(
|
||||
"GET",
|
||||
"/user/subscriptions/" + subscription._identity,
|
||||
None,
|
||||
@@ -529,7 +529,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def has_in_watched(self, watched):
|
||||
assert isinstance(watched, github.Repository.Repository), watched
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
status, headers, data = self._requester.requestJson(
|
||||
"GET",
|
||||
"/user/watched/" + watched._identity,
|
||||
None,
|
||||
@@ -540,7 +540,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
def remove_from_emails(self, *emails):
|
||||
assert all(isinstance(element, (str, unicode)) for element in emails), emails
|
||||
post_parameters = emails
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
"/user/emails",
|
||||
None,
|
||||
@@ -549,7 +549,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def remove_from_following(self, following):
|
||||
assert isinstance(following, github.NamedUser.NamedUser), following
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
"/user/following/" + following._identity,
|
||||
None,
|
||||
@@ -558,7 +558,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def remove_from_starred(self, starred):
|
||||
assert isinstance(starred, github.Repository.Repository), starred
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
"/user/starred/" + starred._identity,
|
||||
None,
|
||||
@@ -567,7 +567,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def remove_from_subscriptions(self, subscription):
|
||||
assert isinstance(subscription, github.Repository.Repository), subscription
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
"/user/subscriptions/" + subscription._identity,
|
||||
None,
|
||||
@@ -576,7 +576,7 @@ class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def remove_from_watched(self, watched):
|
||||
assert isinstance(watched, github.Repository.Repository), watched
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
"/user/watched/" + watched._identity,
|
||||
None,
|
||||
|
||||
@@ -65,7 +65,7 @@ class Authorization(github.GithubObject.GithubObject):
|
||||
return self._NoneIfNotSet(self._url)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -89,7 +89,7 @@ class Authorization(github.GithubObject.GithubObject):
|
||||
post_parameters["note"] = note
|
||||
if note_url is not github.GithubObject.NotSet:
|
||||
post_parameters["note_url"] = note_url
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
|
||||
+2
-2
@@ -79,7 +79,7 @@ class Commit(github.GithubObject.GithubObject):
|
||||
post_parameters["path"] = path
|
||||
if position is not github.GithubObject.NotSet:
|
||||
post_parameters["position"] = position
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/comments",
|
||||
None,
|
||||
@@ -98,7 +98,7 @@ class Commit(github.GithubObject.GithubObject):
|
||||
post_parameters["target_url"] = target_url
|
||||
if description is not github.GithubObject.NotSet:
|
||||
post_parameters["description"] = description
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self._parentUrl(self._parentUrl(self.url)) + "/statuses/" + self.sha,
|
||||
None,
|
||||
|
||||
@@ -75,7 +75,7 @@ class CommitComment(github.GithubObject.GithubObject):
|
||||
return self._NoneIfNotSet(self._user)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -87,7 +87,7 @@ class CommitComment(github.GithubObject.GithubObject):
|
||||
post_parameters = {
|
||||
"body": body,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ class Download(github.GithubObject.GithubObject):
|
||||
return self._NoneIfNotSet(self._url)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
|
||||
+8
-8
@@ -103,7 +103,7 @@ class Gist(github.GithubObject.GithubObject):
|
||||
post_parameters = {
|
||||
"body": body,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/comments",
|
||||
None,
|
||||
@@ -112,7 +112,7 @@ class Gist(github.GithubObject.GithubObject):
|
||||
return github.GistComment.GistComment(self._requester, data, completed=True)
|
||||
|
||||
def create_fork(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/fork",
|
||||
None,
|
||||
@@ -121,7 +121,7 @@ class Gist(github.GithubObject.GithubObject):
|
||||
return Gist(self._requester, data, completed=True)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -136,7 +136,7 @@ class Gist(github.GithubObject.GithubObject):
|
||||
post_parameters["description"] = description
|
||||
if files is not github.GithubObject.NotSet:
|
||||
post_parameters["files"] = dict((key, value._identity) for key, value in files.iteritems())
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
@@ -146,7 +146,7 @@ class Gist(github.GithubObject.GithubObject):
|
||||
|
||||
def get_comment(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/comments/" + str(id),
|
||||
None,
|
||||
@@ -163,7 +163,7 @@ class Gist(github.GithubObject.GithubObject):
|
||||
)
|
||||
|
||||
def is_starred(self):
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
status, headers, data = self._requester.requestJson(
|
||||
"GET",
|
||||
self.url + "/star",
|
||||
None,
|
||||
@@ -172,7 +172,7 @@ class Gist(github.GithubObject.GithubObject):
|
||||
return status == 204
|
||||
|
||||
def reset_starred(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url + "/star",
|
||||
None,
|
||||
@@ -180,7 +180,7 @@ class Gist(github.GithubObject.GithubObject):
|
||||
)
|
||||
|
||||
def set_starred(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/star",
|
||||
None,
|
||||
|
||||
@@ -50,7 +50,7 @@ class GistComment(github.GithubObject.GithubObject):
|
||||
return self._NoneIfNotSet(self._user)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -62,7 +62,7 @@ class GistComment(github.GithubObject.GithubObject):
|
||||
post_parameters = {
|
||||
"body": body,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ class GitRef(github.GithubObject.GithubObject):
|
||||
return self._NoneIfNotSet(self._url)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -50,7 +50,7 @@ class GitRef(github.GithubObject.GithubObject):
|
||||
}
|
||||
if force is not github.GithubObject.NotSet:
|
||||
post_parameters["force"] = force
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
|
||||
+13
-9
@@ -48,12 +48,16 @@ class Github(object):
|
||||
def rate_limiting(self):
|
||||
return self.__requester.rate_limiting
|
||||
|
||||
@property
|
||||
def oauth_scopes(self):
|
||||
return self.__requester.oauth_scopes
|
||||
|
||||
def get_user(self, login=github.GithubObject.NotSet):
|
||||
assert login is github.GithubObject.NotSet or isinstance(login, (str, unicode)), login
|
||||
if login is github.GithubObject.NotSet:
|
||||
return AuthenticatedUser.AuthenticatedUser(self.__requester, {"url": "/user"}, completed=False)
|
||||
else:
|
||||
headers, data = self.__requester.requestAndCheck(
|
||||
headers, data = self.__requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/users/" + login,
|
||||
None,
|
||||
@@ -63,7 +67,7 @@ class Github(object):
|
||||
|
||||
def get_organization(self, login):
|
||||
assert isinstance(login, (str, unicode)), login
|
||||
headers, data = self.__requester.requestAndCheck(
|
||||
headers, data = self.__requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/orgs/" + login,
|
||||
None,
|
||||
@@ -73,7 +77,7 @@ class Github(object):
|
||||
|
||||
def get_repo(self, full_name):
|
||||
assert isinstance(full_name, (str, unicode)), full_name
|
||||
headers, data = self.__requester.requestAndCheck(
|
||||
headers, data = self.__requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/repos/" + full_name,
|
||||
None,
|
||||
@@ -83,7 +87,7 @@ class Github(object):
|
||||
|
||||
def get_gist(self, id):
|
||||
assert isinstance(id, (str, unicode)), id
|
||||
headers, data = self.__requester.requestAndCheck(
|
||||
headers, data = self.__requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/gists/" + id,
|
||||
None,
|
||||
@@ -125,7 +129,7 @@ class Github(object):
|
||||
|
||||
def legacy_search_user_by_email(self, email):
|
||||
assert isinstance(email, (str, unicode)), email
|
||||
headers, data = self.__requester.requestAndCheck(
|
||||
headers, data = self.__requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/legacy/user/email/" + email,
|
||||
None,
|
||||
@@ -142,7 +146,7 @@ class Github(object):
|
||||
if context is not github.GithubObject.NotSet:
|
||||
post_parameters["mode"] = "gfm"
|
||||
post_parameters["context"] = context._identity
|
||||
status, headers, data = self.__requester.requestRaw(
|
||||
status, headers, data = self.__requester.requestJson(
|
||||
"POST",
|
||||
"/markdown",
|
||||
None,
|
||||
@@ -151,7 +155,7 @@ class Github(object):
|
||||
return data
|
||||
|
||||
def get_hooks(self):
|
||||
headers, data = self.__requester.requestAndCheck(
|
||||
headers, data = self.__requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/hooks",
|
||||
None,
|
||||
@@ -160,7 +164,7 @@ class Github(object):
|
||||
return [HookDescription.HookDescription(self.__requester, attributes, completed=True) for attributes in data]
|
||||
|
||||
def get_gitignore_templates(self):
|
||||
headers, data = self.__requester.requestAndCheck(
|
||||
headers, data = self.__requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/gitignore/templates",
|
||||
None,
|
||||
@@ -170,7 +174,7 @@ class Github(object):
|
||||
|
||||
def get_gitignore_template(self, name):
|
||||
assert isinstance(name, (str, unicode)), name
|
||||
headers, attributes = self.__requester.requestAndCheck(
|
||||
headers, attributes = self.__requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/gitignore/templates/" + name,
|
||||
None,
|
||||
|
||||
@@ -62,7 +62,7 @@ class GithubObject(BasicGithubObject):
|
||||
self.__complete()
|
||||
|
||||
def __complete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self._url,
|
||||
None,
|
||||
|
||||
+3
-3
@@ -65,7 +65,7 @@ class Hook(github.GithubObject.GithubObject):
|
||||
return self._NoneIfNotSet(self._url)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -91,7 +91,7 @@ class Hook(github.GithubObject.GithubObject):
|
||||
post_parameters["remove_events"] = remove_events
|
||||
if active is not github.GithubObject.NotSet:
|
||||
post_parameters["active"] = active
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
@@ -100,7 +100,7 @@ class Hook(github.GithubObject.GithubObject):
|
||||
self._useAttributes(data)
|
||||
|
||||
def test(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/test",
|
||||
None,
|
||||
|
||||
+7
-7
@@ -119,7 +119,7 @@ class Issue(github.GithubObject.GithubObject):
|
||||
def add_to_labels(self, *labels):
|
||||
assert all(isinstance(element, github.Label.Label) for element in labels), labels
|
||||
post_parameters = [label.name for label in labels]
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/labels",
|
||||
None,
|
||||
@@ -131,7 +131,7 @@ class Issue(github.GithubObject.GithubObject):
|
||||
post_parameters = {
|
||||
"body": body,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/comments",
|
||||
None,
|
||||
@@ -140,7 +140,7 @@ class Issue(github.GithubObject.GithubObject):
|
||||
return github.IssueComment.IssueComment(self._requester, data, completed=True)
|
||||
|
||||
def delete_labels(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url + "/labels",
|
||||
None,
|
||||
@@ -167,7 +167,7 @@ class Issue(github.GithubObject.GithubObject):
|
||||
post_parameters["milestone"] = milestone._identity if milestone else ''
|
||||
if labels is not github.GithubObject.NotSet:
|
||||
post_parameters["labels"] = labels
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
@@ -177,7 +177,7 @@ class Issue(github.GithubObject.GithubObject):
|
||||
|
||||
def get_comment(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self._parentUrl(self.url) + "/comments/" + str(id),
|
||||
None,
|
||||
@@ -211,7 +211,7 @@ class Issue(github.GithubObject.GithubObject):
|
||||
|
||||
def remove_from_labels(self, label):
|
||||
assert isinstance(label, github.Label.Label), label
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url + "/labels/" + label._identity,
|
||||
None,
|
||||
@@ -221,7 +221,7 @@ class Issue(github.GithubObject.GithubObject):
|
||||
def set_labels(self, *labels):
|
||||
assert all(isinstance(element, github.Label.Label) for element in labels), labels
|
||||
post_parameters = [label.name for label in labels]
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/labels",
|
||||
None,
|
||||
|
||||
@@ -50,7 +50,7 @@ class IssueComment(github.GithubObject.GithubObject):
|
||||
return self._NoneIfNotSet(self._user)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -62,7 +62,7 @@ class IssueComment(github.GithubObject.GithubObject):
|
||||
post_parameters = {
|
||||
"body": body,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ class Label(github.GithubObject.GithubObject):
|
||||
return self._NoneIfNotSet(self._url)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -49,7 +49,7 @@ class Label(github.GithubObject.GithubObject):
|
||||
"name": name,
|
||||
"color": color,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ class PaginatedList(github.PaginatedList.PaginatedListBase):
|
||||
args = dict(self.__args)
|
||||
if page != 0:
|
||||
args["start_page"] = page + 1
|
||||
headers, data = self.__requester.requestAndCheck(
|
||||
headers, data = self.__requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.__url,
|
||||
args,
|
||||
|
||||
+2
-2
@@ -79,7 +79,7 @@ class Milestone(github.GithubObject.GithubObject):
|
||||
return self._NoneIfNotSet(self._url)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -100,7 +100,7 @@ class Milestone(github.GithubObject.GithubObject):
|
||||
post_parameters["description"] = description
|
||||
if due_on is not github.GithubObject.NotSet:
|
||||
post_parameters["due_on"] = due_on.strftime("%Y-%m-%d")
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
|
||||
+10
-2
@@ -165,7 +165,7 @@ class NamedUser(github.GithubObject.GithubObject):
|
||||
}
|
||||
if description is not github.GithubObject.NotSet:
|
||||
post_parameters["description"] = description
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/gists",
|
||||
None,
|
||||
@@ -205,6 +205,14 @@ class NamedUser(github.GithubObject.GithubObject):
|
||||
None
|
||||
)
|
||||
|
||||
def get_keys(self):
|
||||
return github.PaginatedList.PaginatedList(
|
||||
github.UserKey.UserKey,
|
||||
self._requester,
|
||||
self.url + "/keys",
|
||||
None
|
||||
)
|
||||
|
||||
def get_orgs(self):
|
||||
return github.PaginatedList.PaginatedList(
|
||||
github.Organization.Organization,
|
||||
@@ -239,7 +247,7 @@ class NamedUser(github.GithubObject.GithubObject):
|
||||
|
||||
def get_repo(self, name):
|
||||
assert isinstance(name, (str, unicode)), name
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/repos/" + self.login + "/" + name,
|
||||
None,
|
||||
|
||||
+11
-11
@@ -146,7 +146,7 @@ class Organization(github.GithubObject.GithubObject):
|
||||
|
||||
def add_to_public_members(self, public_member):
|
||||
assert isinstance(public_member, github.NamedUser.NamedUser), public_member
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/public_members/" + public_member._identity,
|
||||
None,
|
||||
@@ -158,7 +158,7 @@ class Organization(github.GithubObject.GithubObject):
|
||||
url_parameters = {
|
||||
"org": self.login,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
"/repos/" + repo.owner.login + "/" + repo.name + "/forks",
|
||||
url_parameters,
|
||||
@@ -198,7 +198,7 @@ class Organization(github.GithubObject.GithubObject):
|
||||
post_parameters["auto_init"] = auto_init
|
||||
if gitignore_template is not github.GithubObject.NotSet:
|
||||
post_parameters["gitignore_template"] = gitignore_template
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/repos",
|
||||
None,
|
||||
@@ -217,7 +217,7 @@ class Organization(github.GithubObject.GithubObject):
|
||||
post_parameters["repo_names"] = [element._identity for element in repo_names]
|
||||
if permission is not github.GithubObject.NotSet:
|
||||
post_parameters["permission"] = permission
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/teams",
|
||||
None,
|
||||
@@ -245,7 +245,7 @@ class Organization(github.GithubObject.GithubObject):
|
||||
post_parameters["location"] = location
|
||||
if name is not github.GithubObject.NotSet:
|
||||
post_parameters["name"] = name
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
@@ -279,7 +279,7 @@ class Organization(github.GithubObject.GithubObject):
|
||||
|
||||
def get_repo(self, name):
|
||||
assert isinstance(name, (str, unicode)), name
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/repos/" + self.login + "/" + name,
|
||||
None,
|
||||
@@ -301,7 +301,7 @@ class Organization(github.GithubObject.GithubObject):
|
||||
|
||||
def get_team(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/teams/" + str(id),
|
||||
None,
|
||||
@@ -319,7 +319,7 @@ class Organization(github.GithubObject.GithubObject):
|
||||
|
||||
def has_in_members(self, member):
|
||||
assert isinstance(member, github.NamedUser.NamedUser), member
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
status, headers, data = self._requester.requestJson(
|
||||
"GET",
|
||||
self.url + "/members/" + member._identity,
|
||||
None,
|
||||
@@ -329,7 +329,7 @@ class Organization(github.GithubObject.GithubObject):
|
||||
|
||||
def has_in_public_members(self, public_member):
|
||||
assert isinstance(public_member, github.NamedUser.NamedUser), public_member
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
status, headers, data = self._requester.requestJson(
|
||||
"GET",
|
||||
self.url + "/public_members/" + public_member._identity,
|
||||
None,
|
||||
@@ -339,7 +339,7 @@ class Organization(github.GithubObject.GithubObject):
|
||||
|
||||
def remove_from_members(self, member):
|
||||
assert isinstance(member, github.NamedUser.NamedUser), member
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url + "/members/" + member._identity,
|
||||
None,
|
||||
@@ -348,7 +348,7 @@ class Organization(github.GithubObject.GithubObject):
|
||||
|
||||
def remove_from_public_members(self, public_member):
|
||||
assert isinstance(public_member, github.NamedUser.NamedUser), public_member
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url + "/public_members/" + public_member._identity,
|
||||
None,
|
||||
|
||||
@@ -74,7 +74,7 @@ class PaginatedList(PaginatedListBase):
|
||||
self.__requester = requester
|
||||
self.__contentClass = contentClass
|
||||
self.__firstUrl = firstUrl
|
||||
self.__firstParams = firstParams
|
||||
self.__firstParams = firstParams or ()
|
||||
self.__nextUrl = firstUrl
|
||||
self.__nextParams = firstParams
|
||||
|
||||
@@ -82,7 +82,7 @@ class PaginatedList(PaginatedListBase):
|
||||
return self.__nextUrl is not None
|
||||
|
||||
def _fetchNextPage(self):
|
||||
headers, data = self.__requester.requestAndCheck("GET", self.__nextUrl, self.__nextParams, None)
|
||||
headers, data = self.__requester.requestJsonAndCheck("GET", self.__nextUrl, self.__nextParams, None)
|
||||
|
||||
links = self.__parseLinkHeader(headers)
|
||||
if len(data) > 0 and "next" in links:
|
||||
@@ -111,7 +111,7 @@ class PaginatedList(PaginatedListBase):
|
||||
params = dict(self.__firstParams)
|
||||
if page != 0:
|
||||
params["page"] = page + 1
|
||||
headers, data = self.__requester.requestAndCheck("GET", self.__firstUrl, params, None)
|
||||
headers, data = self.__requester.requestJsonAndCheck("GET", self.__firstUrl, params, None)
|
||||
|
||||
return [
|
||||
self.__contentClass(self.__requester, element, completed=False)
|
||||
|
||||
@@ -175,7 +175,7 @@ class PullRequest(github.GithubObject.GithubObject):
|
||||
"path": path,
|
||||
"position": position,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/comments",
|
||||
None,
|
||||
@@ -188,7 +188,7 @@ class PullRequest(github.GithubObject.GithubObject):
|
||||
post_parameters = {
|
||||
"body": body,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self._parentUrl(self._parentUrl(self.url)) + "/issues/" + str(self.number) + "/comments",
|
||||
None,
|
||||
@@ -207,7 +207,7 @@ class PullRequest(github.GithubObject.GithubObject):
|
||||
post_parameters["body"] = body
|
||||
if state is not github.GithubObject.NotSet:
|
||||
post_parameters["state"] = state
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
@@ -220,7 +220,7 @@ class PullRequest(github.GithubObject.GithubObject):
|
||||
|
||||
def get_review_comment(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self._parentUrl(self.url) + "/comments/" + str(id),
|
||||
None,
|
||||
@@ -257,7 +257,7 @@ class PullRequest(github.GithubObject.GithubObject):
|
||||
|
||||
def get_issue_comment(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self._parentUrl(self._parentUrl(self.url)) + "/issues/comments/" + str(id),
|
||||
None,
|
||||
@@ -274,7 +274,7 @@ class PullRequest(github.GithubObject.GithubObject):
|
||||
)
|
||||
|
||||
def is_merged(self):
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
status, headers, data = self._requester.requestJson(
|
||||
"GET",
|
||||
self.url + "/merge",
|
||||
None,
|
||||
@@ -287,7 +287,7 @@ class PullRequest(github.GithubObject.GithubObject):
|
||||
post_parameters = dict()
|
||||
if commit_message is not github.GithubObject.NotSet:
|
||||
post_parameters["commit_message"] = commit_message
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/merge",
|
||||
None,
|
||||
|
||||
@@ -75,7 +75,7 @@ class PullRequestComment(github.GithubObject.GithubObject):
|
||||
return self._NoneIfNotSet(self._user)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -87,7 +87,7 @@ class PullRequestComment(github.GithubObject.GithubObject):
|
||||
post_parameters = {
|
||||
"body": body,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
|
||||
+68
-41
@@ -200,7 +200,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def add_to_collaborators(self, collaborator):
|
||||
assert isinstance(collaborator, github.NamedUser.NamedUser), collaborator
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/collaborators/" + collaborator._identity,
|
||||
None,
|
||||
@@ -210,7 +210,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
def compare(self, base, head):
|
||||
assert isinstance(base, (str, unicode)), base
|
||||
assert isinstance(head, (str, unicode)), head
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/compare/" + base + "..." + head,
|
||||
None,
|
||||
@@ -231,7 +231,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
post_parameters["description"] = description
|
||||
if content_type is not github.GithubObject.NotSet:
|
||||
post_parameters["content_type"] = content_type
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/downloads",
|
||||
None,
|
||||
@@ -246,7 +246,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
"content": content,
|
||||
"encoding": encoding,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/git/blobs",
|
||||
None,
|
||||
@@ -269,7 +269,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
post_parameters["author"] = author._identity
|
||||
if committer is not github.GithubObject.NotSet:
|
||||
post_parameters["committer"] = committer._identity
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/git/commits",
|
||||
None,
|
||||
@@ -284,7 +284,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
"ref": ref,
|
||||
"sha": sha,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/git/refs",
|
||||
None,
|
||||
@@ -306,7 +306,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
}
|
||||
if tagger is not github.GithubObject.NotSet:
|
||||
post_parameters["tagger"] = tagger._identity
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/git/tags",
|
||||
None,
|
||||
@@ -322,7 +322,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
}
|
||||
if base_tree is not github.GithubObject.NotSet:
|
||||
post_parameters["base_tree"] = base_tree._identity
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/git/trees",
|
||||
None,
|
||||
@@ -343,7 +343,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
post_parameters["events"] = events
|
||||
if active is not github.GithubObject.NotSet:
|
||||
post_parameters["active"] = active
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/hooks",
|
||||
None,
|
||||
@@ -368,7 +368,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
post_parameters["milestone"] = milestone._identity
|
||||
if labels is not github.GithubObject.NotSet:
|
||||
post_parameters["labels"] = [element.name for element in labels]
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/issues",
|
||||
None,
|
||||
@@ -383,7 +383,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
"title": title,
|
||||
"key": key,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/keys",
|
||||
None,
|
||||
@@ -398,7 +398,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
"name": name,
|
||||
"color": color,
|
||||
}
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/labels",
|
||||
None,
|
||||
@@ -420,7 +420,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
post_parameters["description"] = description
|
||||
if due_on is not github.GithubObject.NotSet:
|
||||
post_parameters["due_on"] = due_on.strftime("%Y-%m-%d")
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/milestones",
|
||||
None,
|
||||
@@ -449,7 +449,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def __create_pull(self, **kwds):
|
||||
post_parameters = kwds
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/pulls",
|
||||
None,
|
||||
@@ -458,7 +458,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
return github.PullRequest.PullRequest(self._requester, data, completed=True)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -491,7 +491,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
post_parameters["has_downloads"] = has_downloads
|
||||
if default_branch is not github.GithubObject.NotSet:
|
||||
post_parameters["default_branch"] = default_branch
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
@@ -505,7 +505,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
url = self.url + "/" + archive_format
|
||||
if ref is not github.GithubObject.NotSet:
|
||||
url += "/" + ref
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
url,
|
||||
None,
|
||||
@@ -523,7 +523,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_branch(self, branch):
|
||||
assert isinstance(branch, (str, unicode)), branch
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/branches/" + branch,
|
||||
None,
|
||||
@@ -549,7 +549,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_comment(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/comments/" + str(id),
|
||||
None,
|
||||
@@ -567,7 +567,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_commit(self, sha):
|
||||
assert isinstance(sha, (str, unicode)), sha
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/commits/" + sha,
|
||||
None,
|
||||
@@ -596,7 +596,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
url_parameters = dict()
|
||||
if ref is not github.GithubObject.NotSet:
|
||||
url_parameters["ref"] = ref
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/contents" + path,
|
||||
url_parameters,
|
||||
@@ -614,7 +614,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_download(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/downloads/" + str(id),
|
||||
None,
|
||||
@@ -648,7 +648,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_git_blob(self, sha):
|
||||
assert isinstance(sha, (str, unicode)), sha
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/git/blobs/" + sha,
|
||||
None,
|
||||
@@ -658,7 +658,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_git_commit(self, sha):
|
||||
assert isinstance(sha, (str, unicode)), sha
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/git/commits/" + sha,
|
||||
None,
|
||||
@@ -671,7 +671,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
if not self._requester.FIX_REPO_GET_GIT_REF:
|
||||
prefix = "/git/"
|
||||
assert isinstance(ref, (str, unicode)), ref
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + prefix + ref,
|
||||
None,
|
||||
@@ -689,7 +689,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_git_tag(self, sha):
|
||||
assert isinstance(sha, (str, unicode)), sha
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/git/tags/" + sha,
|
||||
None,
|
||||
@@ -703,7 +703,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
url_parameters = dict()
|
||||
if recursive is not github.GithubObject.NotSet:
|
||||
url_parameters["recursive"] = recursive
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/git/trees/" + sha,
|
||||
url_parameters,
|
||||
@@ -713,7 +713,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_hook(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/hooks/" + str(id),
|
||||
None,
|
||||
@@ -731,7 +731,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_issue(self, number):
|
||||
assert isinstance(number, (int, long)), number
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/issues/" + str(number),
|
||||
None,
|
||||
@@ -798,7 +798,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_issues_event(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/issues/events/" + str(id),
|
||||
None,
|
||||
@@ -816,7 +816,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_key(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/keys/" + str(id),
|
||||
None,
|
||||
@@ -834,7 +834,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_label(self, name):
|
||||
assert isinstance(name, (str, unicode)), name
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/labels/" + urllib.quote(name),
|
||||
None,
|
||||
@@ -851,7 +851,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
)
|
||||
|
||||
def get_languages(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/languages",
|
||||
None,
|
||||
@@ -861,7 +861,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_milestone(self, number):
|
||||
assert isinstance(number, (int, long)), number
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/milestones/" + str(number),
|
||||
None,
|
||||
@@ -897,7 +897,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def get_pull(self, number):
|
||||
assert isinstance(number, (int, long)), number
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/pulls/" + str(number),
|
||||
None,
|
||||
@@ -943,7 +943,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
url_parameters = dict()
|
||||
if ref is not github.GithubObject.NotSet:
|
||||
url_parameters["ref"] = ref
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/readme",
|
||||
url_parameters,
|
||||
@@ -993,7 +993,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def has_in_assignees(self, assignee):
|
||||
assert isinstance(assignee, github.NamedUser.NamedUser), assignee
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
status, headers, data = self._requester.requestJson(
|
||||
"GET",
|
||||
self.url + "/assignees/" + assignee._identity,
|
||||
None,
|
||||
@@ -1003,7 +1003,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def has_in_collaborators(self, collaborator):
|
||||
assert isinstance(collaborator, github.NamedUser.NamedUser), collaborator
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
status, headers, data = self._requester.requestJson(
|
||||
"GET",
|
||||
self.url + "/collaborators/" + collaborator._identity,
|
||||
None,
|
||||
@@ -1014,7 +1014,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
def legacy_search_issues(self, state, keyword):
|
||||
assert state in ["open", "closed"], state
|
||||
assert isinstance(keyword, (str, unicode)), keyword
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/legacy/issues/search/" + self.owner.login + "/" + self.name + "/" + state + "/" + urllib.quote(keyword),
|
||||
None,
|
||||
@@ -1035,7 +1035,7 @@ class Repository(github.GithubObject.GithubObject):
|
||||
}
|
||||
if commit_message is not github.GithubObject.NotSet:
|
||||
post_parameters["commit_message"] = commit_message
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/merges",
|
||||
None,
|
||||
@@ -1048,13 +1048,40 @@ class Repository(github.GithubObject.GithubObject):
|
||||
|
||||
def remove_from_collaborators(self, collaborator):
|
||||
assert isinstance(collaborator, github.NamedUser.NamedUser), collaborator
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url + "/collaborators/" + collaborator._identity,
|
||||
None,
|
||||
None
|
||||
)
|
||||
|
||||
def subscribe_to_hub(self, event, callback, secret=github.GithubObject.NotSet):
|
||||
return self._hub("subscribe", event, callback, secret)
|
||||
|
||||
def unsubscribe_from_hub(self, event, callback):
|
||||
return self._hub("unsubscribe", event, callback, github.GithubObject.NotSet)
|
||||
|
||||
def _hub(self, mode, event, callback, secret):
|
||||
assert isinstance(mode, (str, unicode)), mode
|
||||
assert isinstance(event, (str, unicode)), event
|
||||
assert isinstance(callback, (str, unicode)), callback
|
||||
assert secret is github.GithubObject.NotSet or isinstance(secret, (str, unicode)), secret
|
||||
|
||||
post_parameters = {
|
||||
"hub.mode": mode,
|
||||
"hub.topic": "https://github.com/" + self._full_name + "/events/" + event,
|
||||
"hub.callback": callback,
|
||||
}
|
||||
if secret is not github.GithubObject.NotSet:
|
||||
post_parameters["hub.secret"] = secret
|
||||
|
||||
responseHeaders, output = self._requester.requestMultipartAndCheck(
|
||||
"POST",
|
||||
"/hub",
|
||||
None,
|
||||
post_parameters,
|
||||
)
|
||||
|
||||
@property
|
||||
def _identity(self):
|
||||
return self.owner.login + "/" + self.name
|
||||
|
||||
@@ -51,7 +51,7 @@ class RepositoryKey(github.GithubObject.GithubObject):
|
||||
return self._NoneIfNotSet(self._verified)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.__customUrl,
|
||||
None,
|
||||
@@ -66,7 +66,7 @@ class RepositoryKey(github.GithubObject.GithubObject):
|
||||
post_parameters["title"] = title
|
||||
if key is not github.GithubObject.NotSet:
|
||||
post_parameters["key"] = key
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.__customUrl,
|
||||
None,
|
||||
|
||||
+47
-9
@@ -69,16 +69,23 @@ class Requester:
|
||||
self.rate_limiting = (5000, 5000)
|
||||
self.FIX_REPO_GET_GIT_REF = True
|
||||
|
||||
self.oauth_scopes = None
|
||||
|
||||
self.__clientId = client_id
|
||||
self.__clientSecret = client_secret
|
||||
self.__userAgent = user_agent
|
||||
|
||||
def requestAndCheck(self, verb, url, parameters, input):
|
||||
status, headers, output = self.requestRaw(verb, url, parameters, input)
|
||||
def requestJsonAndCheck(self, verb, url, parameters, input):
|
||||
return self.__check(*self.requestJson(verb, url, parameters, input))
|
||||
|
||||
def requestMultipartAndCheck(self, verb, url, parameters, input):
|
||||
return self.__check(*self.requestMultipart(verb, url, parameters, input))
|
||||
|
||||
def __check(self, status, responseHeaders, output):
|
||||
output = self.__structuredFromJson(output)
|
||||
if status >= 400:
|
||||
raise GithubException.GithubException(status, output)
|
||||
return headers, output
|
||||
return responseHeaders, output
|
||||
|
||||
def __structuredFromJson(self, data):
|
||||
if len(data) == 0:
|
||||
@@ -86,7 +93,29 @@ class Requester:
|
||||
else:
|
||||
return json.loads(data)
|
||||
|
||||
def requestRaw(self, verb, url, parameters, input):
|
||||
def requestJson(self, verb, url, parameters, input):
|
||||
def encode(input):
|
||||
return "application/json", json.dumps(input)
|
||||
|
||||
return self.__requestEncode(verb, url, parameters, input, encode)
|
||||
|
||||
def requestMultipart(self, verb, url, parameters, input):
|
||||
def encode(input):
|
||||
boundary = "----------------------------3c3ba8b523b2"
|
||||
eol = "\r\n"
|
||||
|
||||
encoded_input = ""
|
||||
for name, value in input.iteritems():
|
||||
encoded_input += "--" + boundary + eol
|
||||
encoded_input += "Content-Disposition: form-data; name=\"" + name + "\"" + eol
|
||||
encoded_input += eol
|
||||
encoded_input += value + eol
|
||||
encoded_input += "--" + boundary + "--" + eol
|
||||
return "multipart/form-data; boundary=" + boundary, encoded_input
|
||||
|
||||
return self.__requestEncode(verb, url, parameters, input, encode)
|
||||
|
||||
def __requestEncode(self, verb, url, parameters, input, encode):
|
||||
assert verb in ["HEAD", "GET", "POST", "PATCH", "PUT", "DELETE"]
|
||||
if parameters is None:
|
||||
parameters = dict()
|
||||
@@ -99,14 +128,26 @@ class Requester:
|
||||
url = self.__makeAbsoluteUrl(url)
|
||||
url = self.__addParametersToUrl(url, parameters)
|
||||
|
||||
encoded_input = "null"
|
||||
if input is not None:
|
||||
requestHeaders["Content-Type"] = "application/json"
|
||||
requestHeaders["Content-Type"], encoded_input = encode(input)
|
||||
|
||||
status, responseHeaders, output = self.__requestRaw(verb, url, requestHeaders, encoded_input)
|
||||
|
||||
if "x-ratelimit-remaining" in responseHeaders and "x-ratelimit-limit" in responseHeaders:
|
||||
self.rate_limiting = (int(responseHeaders["x-ratelimit-remaining"]), int(responseHeaders["x-ratelimit-limit"]))
|
||||
|
||||
if "x-oauth-scopes" in responseHeaders:
|
||||
self.oauth_scopes = responseHeaders["x-oauth-scopes"].split(", ")
|
||||
|
||||
return status, responseHeaders, output
|
||||
|
||||
def __requestRaw(self, verb, url, requestHeaders, input):
|
||||
cnx = self.__createConnection()
|
||||
cnx.request(
|
||||
verb,
|
||||
url,
|
||||
json.dumps(input),
|
||||
input,
|
||||
requestHeaders
|
||||
)
|
||||
response = cnx.getresponse()
|
||||
@@ -117,9 +158,6 @@ class Requester:
|
||||
|
||||
cnx.close()
|
||||
|
||||
if "x-ratelimit-remaining" in responseHeaders and "x-ratelimit-limit" in responseHeaders:
|
||||
self.rate_limiting = (int(responseHeaders["x-ratelimit-remaining"]), int(responseHeaders["x-ratelimit-limit"]))
|
||||
|
||||
self.__log(verb, url, requestHeaders, input, status, responseHeaders, output)
|
||||
|
||||
return status, responseHeaders, output
|
||||
|
||||
+8
-8
@@ -53,7 +53,7 @@ class Team(github.GithubObject.GithubObject):
|
||||
|
||||
def add_to_members(self, member):
|
||||
assert isinstance(member, github.NamedUser.NamedUser), member
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/members/" + member._identity,
|
||||
None,
|
||||
@@ -62,7 +62,7 @@ class Team(github.GithubObject.GithubObject):
|
||||
|
||||
def add_to_repos(self, repo):
|
||||
assert isinstance(repo, github.Repository.Repository), repo
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/repos/" + repo._identity,
|
||||
None,
|
||||
@@ -70,7 +70,7 @@ class Team(github.GithubObject.GithubObject):
|
||||
)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -85,7 +85,7 @@ class Team(github.GithubObject.GithubObject):
|
||||
}
|
||||
if permission is not github.GithubObject.NotSet:
|
||||
post_parameters["permission"] = permission
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
@@ -111,7 +111,7 @@ class Team(github.GithubObject.GithubObject):
|
||||
|
||||
def has_in_members(self, member):
|
||||
assert isinstance(member, github.NamedUser.NamedUser), member
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
status, headers, data = self._requester.requestJson(
|
||||
"GET",
|
||||
self.url + "/members/" + member._identity,
|
||||
None,
|
||||
@@ -121,7 +121,7 @@ class Team(github.GithubObject.GithubObject):
|
||||
|
||||
def has_in_repos(self, repo):
|
||||
assert isinstance(repo, github.Repository.Repository), repo
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
status, headers, data = self._requester.requestJson(
|
||||
"GET",
|
||||
self.url + "/repos/" + repo._identity,
|
||||
None,
|
||||
@@ -131,7 +131,7 @@ class Team(github.GithubObject.GithubObject):
|
||||
|
||||
def remove_from_members(self, member):
|
||||
assert isinstance(member, github.NamedUser.NamedUser), member
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url + "/members/" + member._identity,
|
||||
None,
|
||||
@@ -140,7 +140,7 @@ class Team(github.GithubObject.GithubObject):
|
||||
|
||||
def remove_from_repos(self, repo):
|
||||
assert isinstance(repo, github.Repository.Repository), repo
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url + "/repos/" + repo._identity,
|
||||
None,
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ class UserKey(github.GithubObject.GithubObject):
|
||||
return self._NoneIfNotSet(self._verified)
|
||||
|
||||
def delete(self):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
@@ -58,7 +58,7 @@ class UserKey(github.GithubObject.GithubObject):
|
||||
post_parameters["title"] = title
|
||||
if key is not github.GithubObject.NotSet:
|
||||
post_parameters["key"] = key
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
None,
|
||||
|
||||
@@ -60,3 +60,6 @@ from Issue50 import *
|
||||
from Issue54 import *
|
||||
from Issue80 import *
|
||||
from Issue87 import *
|
||||
from Issue131 import *
|
||||
from Issue133 import *
|
||||
from Issue134 import *
|
||||
|
||||
@@ -57,7 +57,7 @@ class RecordingConnection: # pragma no cover
|
||||
print verb, url, input, headers,
|
||||
self.__cnx.request(verb, url, input, headers)
|
||||
fixAuthorizationHeader(headers)
|
||||
self.__file.write(self.__protocol + " " + verb + " " + self.__host + " " + self.__port + " " + url + " " + str(headers) + " " + input + "\n")
|
||||
self.__file.write(self.__protocol + " " + verb + " " + self.__host + " " + self.__port + " " + url + " " + str(headers) + " " + input.replace('\n', '').replace('\r', '') + "\n")
|
||||
|
||||
def getresponse(self):
|
||||
res = self.__cnx.getresponse()
|
||||
@@ -103,7 +103,7 @@ class ReplayingConnection:
|
||||
def request(self, verb, url, input, headers):
|
||||
fixAuthorizationHeader(headers)
|
||||
expectation = self.__file.readline().strip()
|
||||
self.__testCase.assertEqual(self.__protocol + " " + verb + " " + self.__host + " " + self.__port + " " + url + " " + str(headers) + " " + input, expectation)
|
||||
self.__testCase.assertEqual(self.__protocol + " " + verb + " " + self.__host + " " + self.__port + " " + url + " " + str(headers) + " " + input.replace('\n', '').replace('\r', ''), expectation)
|
||||
|
||||
def getresponse(self):
|
||||
status = int(self.__file.readline().strip())
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2012 Vincent Jacques
|
||||
# vincent@vincent-jacques.net
|
||||
|
||||
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
|
||||
|
||||
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import Framework
|
||||
|
||||
|
||||
class Issue131(Framework.TestCase): # https://github.com/jacquev6/PyGithub/pull/133
|
||||
def setUp(self):
|
||||
Framework.TestCase.setUp(self)
|
||||
self.user = self.g.get_user()
|
||||
self.repo = self.g.get_user("openmicroscopy").get_repo("ome-documentation")
|
||||
|
||||
def testGetPullWithOrgHeadUser(self):
|
||||
user = self.repo.get_pull(204).head.user
|
||||
self.assertEqual(user.login, 'imcf')
|
||||
self.assertEqual(user.type, 'Organization')
|
||||
self.assertEqual(user.__class__.__name__, 'NamedUser') # Should be Organization
|
||||
|
||||
def testGetPullsWithOrgHeadUser(self):
|
||||
for pull in self.repo.get_pulls('closed'):
|
||||
if pull.number == 204:
|
||||
user = pull.head.user
|
||||
self.assertEqual(user, None)
|
||||
# Should be:
|
||||
# self.assertEqual(user.login, 'imcf')
|
||||
# self.assertEqual(user.type, 'Organization')
|
||||
# self.assertEqual(user.__class__.__name__, 'NamedUser') # Should be Organization
|
||||
break
|
||||
else:
|
||||
self.assertTrue(False)
|
||||
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2012 Vincent Jacques
|
||||
# vincent@vincent-jacques.net
|
||||
|
||||
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
|
||||
|
||||
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import Framework
|
||||
|
||||
|
||||
class Issue133(Framework.TestCase): # https://github.com/jacquev6/PyGithub/pull/133
|
||||
def setUp(self):
|
||||
Framework.TestCase.setUp(self)
|
||||
self.user = self.g.get_user()
|
||||
|
||||
def testGetPageWithoutInitialArguments(self):
|
||||
self.assertEqual(len(self.user.get_followers().get_page(0)), 22)
|
||||
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2012 Vincent Jacques
|
||||
# vincent@vincent-jacques.net
|
||||
|
||||
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
|
||||
|
||||
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import Framework
|
||||
import github
|
||||
|
||||
|
||||
class Issue134(Framework.BasicTestCase): # https://github.com/jacquev6/PyGithub/pull/134
|
||||
def testGetAuthorizationsFailsWhenAutenticatedThroughOAuth(self):
|
||||
g = github.Github(self.oauth_token)
|
||||
raised = False
|
||||
try:
|
||||
list(g.get_user().get_authorizations())
|
||||
except github.GithubException, exception:
|
||||
raised = True
|
||||
self.assertEqual(exception.status, 404)
|
||||
self.assertTrue(raised)
|
||||
|
||||
def testGetAuthorizationsSucceedsWhenAutenticatedThroughLoginPassword(self):
|
||||
g = github.Github(self.login, self.password)
|
||||
self.assertListKeyEqual(g.get_user().get_authorizations(), lambda a: a.note, [None, None, 'cligh', None, None, 'GitHub Android App'])
|
||||
|
||||
def testGetOAuthScopesFromHeader(self):
|
||||
g = github.Github(self.oauth_token)
|
||||
self.assertEqual(g.oauth_scopes, None)
|
||||
g.get_user().name
|
||||
self.assertEqual(g.oauth_scopes, ['repo', 'user', 'gist'])
|
||||
@@ -38,17 +38,17 @@ class Logging(Framework.BasicTestCase):
|
||||
|
||||
def testLoggingWithBasicAuthentication(self):
|
||||
self.assertEqual(github.Github(self.login, self.password).get_user().name, "Vincent Jacques")
|
||||
self.assertEqual(self.__handler.handled, u'GET https://api.github.com/user {\'Authorization\': \'Basic (login and password removed)\'} None ==> 200 {\'status\': \'200 OK\', \'content-length\': \'806\', \'x-github-media-type\': \'github.beta; format=json\', \'x-content-type-options\': \'nosniff\', \'vary\': \'Accept, Authorization, Cookie\', \'x-ratelimit-remaining\': \'4993\', \'server\': \'nginx\', \'last-modified\': \'Fri, 14 Sep 2012 18:47:46 GMT\', \'connection\': \'keep-alive\', \'x-ratelimit-limit\': \'5000\', \'etag\': \'"434dfe5d3f50558fe3cea087cb95c401"\', \'cache-control\': \'private, s-maxage=60, max-age=60\', \'date\': \'Mon, 17 Sep 2012 17:12:32 GMT\', \'content-type\': \'application/json; charset=utf-8\'} {"owned_private_repos":3,"disk_usage":18612,"following":28,"type":"User","public_repos":13,"location":"Paris, France","company":"Criteo","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","plan":{"space":614400,"private_repos":5,"name":"micro","collaborators":1},"blog":"http://vincent-jacques.net","login":"jacquev6","public_gists":3,"html_url":"https://github.com/jacquev6","hireable":false,"created_at":"2010-07-09T06:10:06Z","private_gists":5,"followers":13,"name":"Vincent Jacques","email":"vincent@vincent-jacques.net","bio":"","total_private_repos":3,"collaborators":0,"gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146,"url":"https://api.github.com/users/jacquev6"}')
|
||||
self.assertEqual(self.__handler.handled, u'GET https://api.github.com/user {\'Authorization\': \'Basic (login and password removed)\'} null ==> 200 {\'status\': \'200 OK\', \'content-length\': \'806\', \'x-github-media-type\': \'github.beta; format=json\', \'x-content-type-options\': \'nosniff\', \'vary\': \'Accept, Authorization, Cookie\', \'x-ratelimit-remaining\': \'4993\', \'server\': \'nginx\', \'last-modified\': \'Fri, 14 Sep 2012 18:47:46 GMT\', \'connection\': \'keep-alive\', \'x-ratelimit-limit\': \'5000\', \'etag\': \'"434dfe5d3f50558fe3cea087cb95c401"\', \'cache-control\': \'private, s-maxage=60, max-age=60\', \'date\': \'Mon, 17 Sep 2012 17:12:32 GMT\', \'content-type\': \'application/json; charset=utf-8\'} {"owned_private_repos":3,"disk_usage":18612,"following":28,"type":"User","public_repos":13,"location":"Paris, France","company":"Criteo","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","plan":{"space":614400,"private_repos":5,"name":"micro","collaborators":1},"blog":"http://vincent-jacques.net","login":"jacquev6","public_gists":3,"html_url":"https://github.com/jacquev6","hireable":false,"created_at":"2010-07-09T06:10:06Z","private_gists":5,"followers":13,"name":"Vincent Jacques","email":"vincent@vincent-jacques.net","bio":"","total_private_repos":3,"collaborators":0,"gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146,"url":"https://api.github.com/users/jacquev6"}')
|
||||
|
||||
def testLoggingWithOAuthAuthentication(self):
|
||||
self.assertEqual(github.Github(self.oauth_token).get_user().name, "Vincent Jacques")
|
||||
self.assertEqual(self.__handler.handled, u'GET https://api.github.com/user {\'Authorization\': \'token (oauth token removed)\'} None ==> 200 {\'status\': \'200 OK\', \'x-ratelimit-remaining\': \'4993\', \'x-github-media-type\': \'github.beta; format=json\', \'x-content-type-options\': \'nosniff\', \'vary\': \'Accept, Authorization, Cookie\', \'content-length\': \'628\', \'server\': \'nginx\', \'last-modified\': \'Tue, 25 Sep 2012 07:42:42 GMT\', \'connection\': \'keep-alive\', \'x-ratelimit-limit\': \'5000\', \'etag\': \'"c23ad6b5815fc3d6ec6341c4a47afe85"\', \'cache-control\': \'private, max-age=60, s-maxage=60\', \'date\': \'Tue, 25 Sep 2012 20:36:54 GMT\', \'x-oauth-scopes\': \'\', \'content-type\': \'application/json; charset=utf-8\', \'x-accepted-oauth-scopes\': \'user\'} {"type":"User","bio":"","html_url":"https://github.com/jacquev6","login":"jacquev6","followers":14,"company":"Criteo","blog":"http://vincent-jacques.net","public_repos":13,"created_at":"2010-07-09T06:10:06Z","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","email":"vincent@vincent-jacques.net","following":29,"name":"Vincent Jacques","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","hireable":false,"id":327146,"public_gists":3,"location":"Paris, France","url":"https://api.github.com/users/jacquev6"}')
|
||||
self.assertEqual(self.__handler.handled, u'GET https://api.github.com/user {\'Authorization\': \'token (oauth token removed)\'} null ==> 200 {\'status\': \'200 OK\', \'x-ratelimit-remaining\': \'4993\', \'x-github-media-type\': \'github.beta; format=json\', \'x-content-type-options\': \'nosniff\', \'vary\': \'Accept, Authorization, Cookie\', \'content-length\': \'628\', \'server\': \'nginx\', \'last-modified\': \'Tue, 25 Sep 2012 07:42:42 GMT\', \'connection\': \'keep-alive\', \'x-ratelimit-limit\': \'5000\', \'etag\': \'"c23ad6b5815fc3d6ec6341c4a47afe85"\', \'cache-control\': \'private, max-age=60, s-maxage=60\', \'date\': \'Tue, 25 Sep 2012 20:36:54 GMT\', \'x-oauth-scopes\': \'\', \'content-type\': \'application/json; charset=utf-8\', \'x-accepted-oauth-scopes\': \'user\'} {"type":"User","bio":"","html_url":"https://github.com/jacquev6","login":"jacquev6","followers":14,"company":"Criteo","blog":"http://vincent-jacques.net","public_repos":13,"created_at":"2010-07-09T06:10:06Z","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","email":"vincent@vincent-jacques.net","following":29,"name":"Vincent Jacques","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","hireable":false,"id":327146,"public_gists":3,"location":"Paris, France","url":"https://api.github.com/users/jacquev6"}')
|
||||
|
||||
def testLoggingWithoutAuthentication(self):
|
||||
self.assertEqual(github.Github().get_user("jacquev6").name, "Vincent Jacques")
|
||||
self.assertEqual(self.__handler.handled, u'GET https://api.github.com/users/jacquev6 {} None ==> 200 {\'status\': \'200 OK\', \'content-length\': \'628\', \'x-github-media-type\': \'github.beta; format=json\', \'x-content-type-options\': \'nosniff\', \'vary\': \'Accept\', \'x-ratelimit-remaining\': \'4989\', \'server\': \'nginx\', \'last-modified\': \'Tue, 25 Sep 2012 07:42:42 GMT\', \'connection\': \'keep-alive\', \'x-ratelimit-limit\': \'5000\', \'etag\': \'"9bd085221a16b6d2ea95e72634c3c1ac"\', \'cache-control\': \'public, max-age=60, s-maxage=60\', \'date\': \'Tue, 25 Sep 2012 20:38:56 GMT\', \'content-type\': \'application/json; charset=utf-8\'} {"type":"User","html_url":"https://github.com/jacquev6","login":"jacquev6","followers":14,"company":"Criteo","created_at":"2010-07-09T06:10:06Z","email":"vincent@vincent-jacques.net","hireable":false,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","public_gists":3,"bio":"","following":29,"name":"Vincent Jacques","blog":"http://vincent-jacques.net","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146,"public_repos":13,"location":"Paris, France","url":"https://api.github.com/users/jacquev6"}')
|
||||
self.assertEqual(self.__handler.handled, u'GET https://api.github.com/users/jacquev6 {} null ==> 200 {\'status\': \'200 OK\', \'content-length\': \'628\', \'x-github-media-type\': \'github.beta; format=json\', \'x-content-type-options\': \'nosniff\', \'vary\': \'Accept\', \'x-ratelimit-remaining\': \'4989\', \'server\': \'nginx\', \'last-modified\': \'Tue, 25 Sep 2012 07:42:42 GMT\', \'connection\': \'keep-alive\', \'x-ratelimit-limit\': \'5000\', \'etag\': \'"9bd085221a16b6d2ea95e72634c3c1ac"\', \'cache-control\': \'public, max-age=60, s-maxage=60\', \'date\': \'Tue, 25 Sep 2012 20:38:56 GMT\', \'content-type\': \'application/json; charset=utf-8\'} {"type":"User","html_url":"https://github.com/jacquev6","login":"jacquev6","followers":14,"company":"Criteo","created_at":"2010-07-09T06:10:06Z","email":"vincent@vincent-jacques.net","hireable":false,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","public_gists":3,"bio":"","following":29,"name":"Vincent Jacques","blog":"http://vincent-jacques.net","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146,"public_repos":13,"location":"Paris, France","url":"https://api.github.com/users/jacquev6"}')
|
||||
|
||||
def testLoggingWithBaseUrl(self):
|
||||
# ReplayData forged, not recorded
|
||||
self.assertEqual(github.Github(base_url="http://my.enterprise.com/my/prefix").get_user("jacquev6").name, "Vincent Jacques")
|
||||
self.assertEqual(self.__handler.handled, u'GET http://my.enterprise.com/my/prefix/users/jacquev6 {} None ==> 200 {\'status\': \'200 OK\', \'content-length\': \'628\', \'x-github-media-type\': \'github.beta; format=json\', \'x-content-type-options\': \'nosniff\', \'vary\': \'Accept\', \'x-ratelimit-remaining\': \'4989\', \'server\': \'nginx\', \'last-modified\': \'Tue, 25 Sep 2012 07:42:42 GMT\', \'connection\': \'keep-alive\', \'x-ratelimit-limit\': \'5000\', \'etag\': \'"9bd085221a16b6d2ea95e72634c3c1ac"\', \'cache-control\': \'public, max-age=60, s-maxage=60\', \'date\': \'Tue, 25 Sep 2012 20:38:56 GMT\', \'content-type\': \'application/json; charset=utf-8\'} {"type":"User","html_url":"https://github.com/jacquev6","login":"jacquev6","followers":14,"company":"Criteo","created_at":"2010-07-09T06:10:06Z","email":"vincent@vincent-jacques.net","hireable":false,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","public_gists":3,"bio":"","following":29,"name":"Vincent Jacques","blog":"http://vincent-jacques.net","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146,"public_repos":13,"location":"Paris, France","url":"https://api.github.com/users/jacquev6"}')
|
||||
self.assertEqual(self.__handler.handled, u'GET http://my.enterprise.com/my/prefix/users/jacquev6 {} null ==> 200 {\'status\': \'200 OK\', \'content-length\': \'628\', \'x-github-media-type\': \'github.beta; format=json\', \'x-content-type-options\': \'nosniff\', \'vary\': \'Accept\', \'x-ratelimit-remaining\': \'4989\', \'server\': \'nginx\', \'last-modified\': \'Tue, 25 Sep 2012 07:42:42 GMT\', \'connection\': \'keep-alive\', \'x-ratelimit-limit\': \'5000\', \'etag\': \'"9bd085221a16b6d2ea95e72634c3c1ac"\', \'cache-control\': \'public, max-age=60, s-maxage=60\', \'date\': \'Tue, 25 Sep 2012 20:38:56 GMT\', \'content-type\': \'application/json; charset=utf-8\'} {"type":"User","html_url":"https://github.com/jacquev6","login":"jacquev6","followers":14,"company":"Criteo","created_at":"2010-07-09T06:10:06Z","email":"vincent@vincent-jacques.net","hireable":false,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","public_gists":3,"bio":"","following":29,"name":"Vincent Jacques","blog":"http://vincent-jacques.net","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146,"public_repos":13,"location":"Paris, France","url":"https://api.github.com/users/jacquev6"}')
|
||||
|
||||
@@ -131,3 +131,6 @@ class NamedUser(Framework.TestCase):
|
||||
|
||||
def testGetReceivedEvents(self):
|
||||
self.assertListKeyBegin(self.user.get_received_events(), lambda e: e.type, ["IssueCommentEvent", "IssueCommentEvent", "IssueCommentEvent", "IssueCommentEvent"])
|
||||
|
||||
def testGetKeys(self):
|
||||
self.assertListKeyEqual(self.user.get_keys(), lambda k: k.id, [3557894, 3791954, 3937333, 4051357, 4051492])
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+5
@@ -0,0 +1,5 @@
|
||||
https GET api.github.com None /authorizations {'Authorization': 'token private_token_removed'} null
|
||||
404
|
||||
[('status', '404 Not Found'), ('content-length', '23'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-remaining', '55'), ('server', 'GitHub.com'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '60'), ('cache-control', ''), ('date', 'Tue, 29 Jan 2013 18:19:32 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"message":"Not Found"}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
https GET api.github.com None /authorizations {'Authorization': 'Basic login_and_password_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('content-length', '1930'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('x-ratelimit-remaining', '4928'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 29 Jan 2013 17:36:52 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1ee9c020e28a8e60c0ed7eee863a79fc"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Tue, 29 Jan 2013 18:19:33 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"token":"private_token_removed","url":"https://api.github.com/authorizations/619306","updated_at":"2012-09-03T08:35:36Z","scopes":[],"created_at":"2012-09-02T15:30:23Z","app":{"url":"http://upverter.com","name":"Upverter"},"note":null,"id":619306,"note_url":null},{"token":"private_token_removed","url":"https://api.github.com/authorizations/648494","updated_at":"2013-01-29T17:36:52Z","scopes":["public_repo","user:email"],"created_at":"2012-09-16T07:13:01Z","app":{"url":"https://travis-ci.org","name":"Travis"},"note":null,"id":648494,"note_url":null},{"token":"private_token_removed","url":"https://api.github.com/authorizations/651653","updated_at":"2012-09-17T21:05:19Z","scopes":["user","repo","gists","delete_repo"],"created_at":"2012-09-17T21:05:19Z","app":{"url":"https://github.com/CMB/cligh","name":"cligh (API)"},"note":"cligh","id":651653,"note_url":"https://github.com/CMB/cligh"},{"token":"private_token_removed","url":"https://api.github.com/authorizations/816763","updated_at":"2012-12-19T09:22:09Z","scopes":[],"created_at":"2012-11-15T17:47:48Z","app":{"url":"https://coderwall.com","name":"coderwall.com"},"note":null,"id":816763,"note_url":null},{"token":"private_token_removed","url":"https://api.github.com/authorizations/974947","updated_at":"2012-12-19T09:17:20Z","scopes":["public_repo"],"created_at":"2012-12-19T09:15:32Z","app":{"url":"http://geekli.st/","name":"Geeklist, Inc."},"note":null,"id":974947,"note_url":null},{"token":"private_token_removed","url":"https://api.github.com/authorizations/1348532","updated_at":"2013-01-27T11:51:21Z","scopes":["repo","user","gist"],"created_at":"2013-01-27T11:51:21Z","app":{"url":"https://github.com/github/android","name":"GitHub Android App (API)"},"note":"GitHub Android App","id":1348532,"note_url":"https://github.com/github/android"}]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
https GET api.github.com None /user {'Authorization': 'token private_token_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4992'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1464'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 05 Feb 2013 18:44:48 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"9257360a3470aac247f722352581abb1"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Tue, 05 Feb 2013 22:57:03 GMT'), ('x-oauth-scopes', 'repo, user, gist'), ('content-type', 'application/json; charset=utf-8'), ('x-accepted-oauth-scopes', 'user:follow, user:email, user')]
|
||||
{"public_repos":21,"type":"User","repos_url":"https://api.github.com/users/jacquev6/repos","followers_url":"https://api.github.com/users/jacquev6/followers","url":"https://api.github.com/users/jacquev6","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","following_url":"https://api.github.com/users/jacquev6/following","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","total_private_repos":4,"following":37,"html_url":"https://github.com/jacquev6","created_at":"2010-07-09T06:10:06Z","collaborators":1,"location":"Paris, France","received_events_url":"https://api.github.com/users/jacquev6/received_events","owned_private_repos":4,"followers":22,"organizations_url":"https://api.github.com/users/jacquev6/orgs","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","email":"vincent@vincent-jacques.net","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","disk_usage":13360,"public_gists":2,"name":"Vincent Jacques","blog":"http://vincent-jacques.net","hireable":false,"plan":{"collaborators":1,"space":614400,"name":"micro","private_repos":5},"starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","id":327146,"login":"jacquev6","private_gists":5,"updated_at":"2013-02-05T18:44:48Z","company":"Criteo","bio":""}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
https GET api.github.com None /users/jacquev6/keys {'Authorization': 'Basic login_and_password_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4998'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-limit', '5000'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '2021'), ('server', 'GitHub.com'), ('last-modified', 'Sun, 03 Feb 2013 11:54:54 GMT'), ('connection', 'keep-alive'), ('etag', '"d80dfcef46052de82fcfd18ddc6d0b9f"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Sun, 03 Feb 2013 16:17:13 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBIP5wjRLjI21lmSNsdGCbB/6Oc6PwyGTr7xn0z0QgUukL8YdsbVtDlgwAXcJbjEO0fIZtXumtHtN6dXxMwzvuyLxwp+YX6itjOex8X+ARsMa3g84+d252E1eVs480s5fZZwfoKGhWD+55bpFVlNokc4OUbqSXEnK45nrEWpxNEfeYF48aW4RpJ42HF8sF1ihxLHCrPXxpx1jKXN8ZpHqzfEHCF2hjJHaIS9sUADxaINEeakWy5brbNn5qSQurs3ADNs827Pahh6tPYcbUWpk7+Lu2V3wvqOdjfQz9GIEhSD1jUDa/R7/FIt92yUShMULdQZ49GuHup7VcTaBW3bBj","id":3557894},{"key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDNPDWrRtvubw0UEsoF3GMsfaRnt2Q2uj1vADkSt2Ii9QmoA4oy4Z/QJwVCYnosGhr/Y21pBYk1J0BuyYnw1NZ0CpC1dxdZLsm5YFVKy0n7DKjyiKShTXEi0rj9GAZfVY4Whv8Du4Jjy0cb4tN9OXqYJ7AI+hN0H/AAX9+vmX0C1Oph7KKyy31De4ov68mpKXQr3EPORgOJQ78yV0LxlaGMeXjYjiMKW9fT0nCKfy/WMQCNE8IJNKDoBsX10ctPQ57K8zE+O9XS8WPS2AL7B1TCJl2GebJjeRN9GHyc8o70ZLgfW4W5JzFMCGv2sYcDJjvVrymYt4/YfAl9AnzZDAN5","id":3791954},{"key":"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAruD8eAQGD1PcfwiycEiwij6StRlNzXKVWlu8IkgfGZq/fk7k5kNf0PwdmG7kZo4gZAi/ljcHrnyINqxtO6zxbUihxJp7T0Zyz27fT0nOrs1p+KAFg7x/qs28Dm7aSYquKztcLqlZdRSDjD/178i7ft90+sjIq9mg2zgYDiV9tGzMfwoD9Cf/OpbFNOdDHNDvuVzGKefDfrC9zY9bpxteJP/teCQXzC6eqYTL7Qz0L6NANRq0Bv9WKA1xE04E6xlSEbtIX9+VWGHH5WnD/q/PABwZqwhxwDm7/b2vd8E9TuoXiVw0rSgWh3WFfYzSLnN/kTw5zadML6egC91Gx594jw==","id":3937333},{"key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC262QAZ3rvJ7KySFEHUQYGfntylusL03x/ULKdVaSltc3Z2xvWm4zQSLHrWrdUbRN9z9kMpHWZZ2G+pvUPcY/qijbqtwg9FwBHNZoviq65LujKyQeegFXQKhGGaesDeKKC+jTXbg2NJY6+u5HLe4Je8q45VVHyAfltcuSE2QoCim50toyGUGWhcIDz/2mQYpy1wtkehQA6TeC55UE00TSU06E9glnqVi8hjDlsA7DABqyctG/sjP79OwUMBppiXYX2B0RJMtRHZ+5chsHx8oqavux1oG/tdTw9ZSAfKUHfDrN97x9PB38F3j8s60S2udRwLEYuErlF1JizTF4XOZhD","id":4051357},{"key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK+jbASXi+PhE7GpBuKEH0qC+02J8L20A9CscleT5GUXKpZSbvxmsU0XLz95kYIBVUfrmTdn3PBn6FMK2OTWpxF9gt9DKclidkv2xfA1RkqnNVpMvZbzBMDmJcWo/lae+arQVJ26O1pbZjPH56c0cYvhblsoZnI1kCFatiJ3MOUeD2zCDylsfQ8zgLKA5yj0HRC3n5cPe9nIVWXnJQ1two4GHmxE7zue+hikYB7PQvaldGKTmHX04ODyZpyFOd86cvjiftN3G39POr2vh52jBwj4oLAiF89SC3QxQes8+zF00jOmnFUlONup0nLvJg4t/ij0M2kr5cqca7pMP+QfZp","id":4051492}]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
https POST api.github.com None /hub {'Content-Type': 'multipart/form-data; boundary=----------------------------3c3ba8b523b2', 'Authorization': 'Basic login_and_password_removed'} ------------------------------3c3ba8b523b2Content-Disposition: form-data; name="hub.callback"http://requestb.in/1bc1sc61------------------------------3c3ba8b523b2Content-Disposition: form-data; name="hub.topic"https://github.com/jacquev6/PyGithub/events/non-existing-event------------------------------3c3ba8b523b2Content-Disposition: form-data; name="hub.mode"subscribe------------------------------3c3ba8b523b2--
|
||||
422
|
||||
[('status', '422 Unprocessable Entity'), ('content-length', '51'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-remaining', '4994'), ('server', 'GitHub.com'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('cache-control', ''), ('date', 'Tue, 05 Feb 2013 18:58:01 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"message":"Invalid event: \"non-existing-event\""}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
https POST api.github.com None /hub {'Content-Type': 'multipart/form-data; boundary=----------------------------3c3ba8b523b2', 'Authorization': 'Basic login_and_password_removed'} ------------------------------3c3ba8b523b2Content-Disposition: form-data; name="hub.callback"http://requestb.in/1bc1sc61------------------------------3c3ba8b523b2Content-Disposition: form-data; name="hub.topic"https://github.com/jacquev6/PyGithub/events/push------------------------------3c3ba8b523b2Content-Disposition: form-data; name="hub.mode"subscribe------------------------------3c3ba8b523b2Content-Disposition: form-data; name="hub.secret"my_secret------------------------------3c3ba8b523b2--
|
||||
204
|
||||
[('status', '204 No Content'), ('x-ratelimit-remaining', '4997'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('server', 'GitHub.com'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('cache-control', ''), ('date', 'Tue, 05 Feb 2013 18:57:27 GMT')]
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
https POST api.github.com None /hub {'Content-Type': 'multipart/form-data; boundary=----------------------------3c3ba8b523b2', 'Authorization': 'Basic login_and_password_removed'} ------------------------------3c3ba8b523b2Content-Disposition: form-data; name="hub.callback"http://requestb.in/1bc1sc61------------------------------3c3ba8b523b2Content-Disposition: form-data; name="hub.topic"https://github.com/jacquev6/PyGithub/events/push------------------------------3c3ba8b523b2Content-Disposition: form-data; name="hub.mode"unsubscribe------------------------------3c3ba8b523b2--
|
||||
204
|
||||
[('status', '204 No Content'), ('x-ratelimit-remaining', '4991'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('server', 'GitHub.com'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('cache-control', ''), ('date', 'Tue, 05 Feb 2013 18:58:12 GMT')]
|
||||
|
||||
|
||||
@@ -438,3 +438,19 @@ class Repository(Framework.TestCase):
|
||||
self.assertListKeyEqual(self.repo.get_pulls_comments(), lambda c: c.id, [1580134])
|
||||
self.assertListKeyEqual(self.repo.get_pulls_comments(sort="created", direction="asc"), lambda c: c.id, [1580134])
|
||||
self.assertListKeyEqual(self.repo.get_pulls_comments(since=datetime.datetime(2012, 5, 28, 23, 0, 0)), lambda c: c.id, [1580134])
|
||||
|
||||
def testSubscribePubSubHubbub(self):
|
||||
self.repo.subscribe_to_hub("push", "http://requestb.in/1bc1sc61", "my_secret")
|
||||
|
||||
def testBadSubscribePubSubHubbub(self):
|
||||
raised = False
|
||||
try:
|
||||
self.repo.subscribe_to_hub("non-existing-event", "http://requestb.in/1bc1sc61")
|
||||
except github.GithubException, exception:
|
||||
raised = True
|
||||
self.assertEqual(exception.status, 422)
|
||||
self.assertEqual(exception.data, {"message": "Invalid event: \"non-existing-event\""})
|
||||
self.assertTrue(raised)
|
||||
|
||||
def testUnsubscribePubSubHubbub(self):
|
||||
self.repo.unsubscribe_from_hub("push", "http://requestb.in/1bc1sc61")
|
||||
|
||||
Reference in New Issue
Block a user