Merge branch 'develop'

This commit is contained in:
Vincent Jacques
2013-09-08 17:42:25 +02:00
94 changed files with 3641 additions and 624 deletions
+5
View File
@@ -1,6 +1,7 @@
############################ Copyrights and license ############################
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -28,3 +29,7 @@ GithubCredentials.py
/PyGithub.egg-info/
/.coverage
/developer.github.com/
*.cfg
*.bat
*.py~
+17 -26
View File
@@ -7,18 +7,28 @@ Should you have any question, any remark, or if you find a bug, or if there is s
PyGithub is stable. I will maintain it up to date with the API, and fix bugs if any, but I don't plan new heavy developments.
What's new?
===========
Thank you, dear stargazers!
---------------------------
`Version 1.18.0 <https://github.com/jacquev6/PyGithub/issues?milestone=30&state=closed>`_ (August 21st, 2013) (Bénodet edition)
-------------------------------------------------------------------------------------------------------------------------------
Starting today (September 05th, 2013), we now need more than 8 bits to store the number of `stargazers <https://github.com/jacquev6/PyGithub/stargazers>`_! Thank you so much!
* `Issues <https://github.com/jacquev6/PyGithub/pull/181>`_' ``repository`` attribute will never be ``None``. Thank you `stuglaser <https://github.com/stuglaser>`_ for the pull request
* No more false assumption on `rate_limiting <https://github.com/jacquev6/PyGithub/pull/186>`_, and creation of ``rate_limiting_resettime``. Thank you `edjackson <https://github.com/edjackson>`_ for the pull request
* `New <https://github.com/jacquev6/PyGithub/pull/187>`_ parameters ``since`` and ``until`` to ``Repository.get_commits``. Thank you `apetresc <https://github.com/apetresc>`_ for the pull request
* `Catch <https://github.com/jacquev6/PyGithub/pull/182>`_ Json parsing exception for some internal server errors, and throw a better exception. Thank you `MarkRoddy <https://github.com/MarkRoddy>`_ for the pull request
* `Allow <https://github.com/jacquev6/PyGithub/pull/184>`_ reversed iteration of ``PaginatedList``s. Thank you `davidbrai <https://github.com/davidbrai>`_ for the pull request
`Version 1.19.0 <https://github.com/jacquev6/PyGithub/issues?milestone=31&state=closed>`_ (September ??th, 2013) (AKFish's edition)
-----------------------------------------------------------------------------------------------------------------------------------
* Implement `conditional requests <http://developer.github.com/guides/getting-started/#conditional-requests>`_ by the method ``GithubObject.update``. Thank you very much `akfish <https://github.com/akfish>`_ for the pull request and your collaboration!
* Implement persistence of PyGithub objects: ``Github.save`` and ``Github.load``. Don't forget to ``update`` your objects after loading them, it won't decrease your rate limiting quota if nothing has changed. Again, thank you `akfish <https://github.com/akfish>`_
* Implement ``Github.get_repos`` to get all public repositories
* Implement ``NamedUser.has_in_following``
* `Implement <https://github.com/jacquev6/PyGithub/issues/188>`_ ``Github.get_api_status``, ``Github.get_last_api_status_message`` and ``Github.get_api_status_messages``. Thank you `ruxandraburtica <https://github.com/ruxandraburtica>`_ for asking
* Implement ``Github.get_rate_limit``
* Add many missing attributes
* Technical change: HTTP headers are now stored in retrieved objects. This is a base for new functionalities. Thank you `akfish <https://github.com/akfish>`_ for the pull request
* Use the new URL to fork gists (minor change)
* Use the new URL to test hooks (minor change)
What's missing?
===============
@@ -30,10 +40,6 @@ Github API v3 URLs not (yet) covered by PyGithub
* ``/applications/:client_id/tokens/:access_token`` (GET)
* ``/feeds`` (GET)
* ``/gists/:id/forks`` (POST)
* instead, ``Gist.create_fork`` calls the old URL ``/gists/:id/fork``
* ``/meta`` (GET)
* ``/notifications`` (PUT)
* ``/notifications/emails`` (GET)
@@ -48,16 +54,8 @@ Github API v3 URLs not (yet) covered by PyGithub
* ``/notifications/threads/:id/subscription`` (DELETE)
* ``/notifications/threads/:id/subscription`` (GET)
* ``/notifications/threads/:id/subscription`` (PUT)
* ``/rate_limit`` (GET)
* should be called in method ``Github.get_rate_limit``. See also ``Github.rate_limiting``
* ``/repos/:owner/:repo/contents/:path`` (DELETE)
* ``/repos/:owner/:repo/contents/:path`` (PUT)
* ``/repos/:owner/:repo/hooks/:id/tests`` (POST)
* instead, ``Hook.test`` calls the old URL ``/repos/:owner/:repo/hooks/:id/test``
* ``/repos/:owner/:repo/notifications`` (GET)
* ``/repos/:owner/:repo/notifications`` (PUT)
* ``/repos/:owner/:repo/stats/code_frequency`` (GET)
@@ -68,17 +66,10 @@ Github API v3 URLs not (yet) covered by PyGithub
* ``/repos/:owner/:repo/subscription`` (DELETE)
* ``/repos/:owner/:repo/subscription`` (GET)
* ``/repos/:owner/:repo/subscription`` (PUT)
* ``/repositories`` (GET)
* should be called in method ``Github.get_repos``
* ``/search/code`` (GET)
* ``/search/issues`` (GET)
* ``/search/repositories`` (GET)
* ``/search/users`` (GET)
* ``/users/:user/following/:target_user`` (GET)
* should be called in method ``NamedUser.has_in_following``
Documentation
=============
+2 -1
View File
@@ -281,6 +281,7 @@ githubClasses = [
"../github/MainClass.py",
"../github/PaginatedList.py",
"../github/Requester.py",
"../github/Consts.py",
"../github/__init__.py"]
]
@@ -318,7 +319,7 @@ for githubClass in githubClasses + ["MainClass"]:
if not isProperty:
assert method is None, method + " has no :calls: section"
method = line.split("(")[0][8:]
if method in ["_initAttributes", "_useAttributes", "__init__", "__create_pull_1", "__create_pull_2", "__create_pull", "_hub", "__get_FIX_REPO_GET_GIT_REF", "__set_FIX_REPO_GET_GIT_REF", "__get_per_page", "__set_per_page"]:
if method in ["_initAttributes", "_useAttributes", "__init__", "__create_pull_1", "__create_pull_2", "__create_pull", "_hub", "__get_FIX_REPO_GET_GIT_REF", "__set_FIX_REPO_GET_GIT_REF", "__get_per_page", "__set_per_page", "create_from_raw_data", "dump", "load"]:
method = None
isProperty = False
if line.startswith(" :calls: `"):
+171 -78
View File
@@ -5,6 +5,7 @@
# Copyright 2012 Steve English <steve.english@navetas.com> #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -38,6 +39,7 @@ import github.UserKey
import github.Issue
import github.Event
import github.Authorization
import github.Notification
class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
@@ -109,6 +111,14 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._email)
return self._NoneIfNotSet(self._email)
@property
def events_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._events_url)
return self._NoneIfNotSet(self._events_url)
@property
def followers(self):
"""
@@ -117,6 +127,14 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._followers)
return self._NoneIfNotSet(self._followers)
@property
def followers_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._followers_url)
return self._NoneIfNotSet(self._followers_url)
@property
def following(self):
"""
@@ -125,6 +143,22 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._following)
return self._NoneIfNotSet(self._following)
@property
def following_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._following_url)
return self._NoneIfNotSet(self._following_url)
@property
def gists_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._gists_url)
return self._NoneIfNotSet(self._gists_url)
@property
def gravatar_id(self):
"""
@@ -181,6 +215,14 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._name)
return self._NoneIfNotSet(self._name)
@property
def organizations_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._organizations_url)
return self._NoneIfNotSet(self._organizations_url)
@property
def owned_private_repos(self):
"""
@@ -221,6 +263,46 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._public_repos)
return self._NoneIfNotSet(self._public_repos)
@property
def received_events_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._received_events_url)
return self._NoneIfNotSet(self._received_events_url)
@property
def repos_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._repos_url)
return self._NoneIfNotSet(self._repos_url)
@property
def site_admin(self):
"""
:type: bool
"""
self._completeIfNotSet(self._site_admin)
return self._NoneIfNotSet(self._site_admin)
@property
def starred_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._starred_url)
return self._NoneIfNotSet(self._starred_url)
@property
def subscriptions_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._subscriptions_url)
return self._NoneIfNotSet(self._subscriptions_url)
@property
def total_private_repos(self):
"""
@@ -237,6 +319,14 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._type)
return self._NoneIfNotSet(self._type)
@property
def updated_at(self):
"""
:type: datetime.datetime
"""
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url(self):
"""
@@ -256,8 +346,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
"/user/emails",
None,
post_parameters
input=post_parameters
)
def add_to_following(self, following):
@@ -269,9 +358,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(following, github.NamedUser.NamedUser), following
headers, data = self._requester.requestJsonAndCheck(
"PUT",
"/user/following/" + following._identity,
None,
None
"/user/following/" + following._identity
)
def add_to_starred(self, starred):
@@ -283,9 +370,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(starred, github.Repository.Repository), starred
headers, data = self._requester.requestJsonAndCheck(
"PUT",
"/user/starred/" + starred._identity,
None,
None
"/user/starred/" + starred._identity
)
def add_to_subscriptions(self, subscription):
@@ -297,9 +382,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(subscription, github.Repository.Repository), subscription
headers, data = self._requester.requestJsonAndCheck(
"PUT",
"/user/subscriptions/" + subscription._identity,
None,
None
"/user/subscriptions/" + subscription._identity
)
def add_to_watched(self, watched):
@@ -311,9 +394,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(watched, github.Repository.Repository), watched
headers, data = self._requester.requestJsonAndCheck(
"PUT",
"/user/watched/" + watched._identity,
None,
None
"/user/watched/" + watched._identity
)
def create_authorization(self, scopes=github.GithubObject.NotSet, note=github.GithubObject.NotSet, note_url=github.GithubObject.NotSet, client_id=github.GithubObject.NotSet, client_secret=github.GithubObject.NotSet):
@@ -345,10 +426,9 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
"/authorizations",
None,
post_parameters
input=post_parameters
)
return github.Authorization.Authorization(self._requester, data, completed=True)
return github.Authorization.Authorization(self._requester, headers, data, completed=True)
def create_fork(self, repo):
"""
@@ -359,11 +439,9 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(repo, github.Repository.Repository), repo
headers, data = self._requester.requestJsonAndCheck(
"POST",
"/repos/" + repo.owner.login + "/" + repo.name + "/forks",
None,
None
"/repos/" + repo.owner.login + "/" + repo.name + "/forks"
)
return github.Repository.Repository(self._requester, data, completed=True)
return github.Repository.Repository(self._requester, headers, data, completed=True)
def create_gist(self, public, files, description=github.GithubObject.NotSet):
"""
@@ -385,10 +463,9 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
"/gists",
None,
post_parameters
input=post_parameters
)
return github.Gist.Gist(self._requester, data, completed=True)
return github.Gist.Gist(self._requester, headers, data, completed=True)
def create_key(self, title, key):
"""
@@ -406,10 +483,9 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
"/user/keys",
None,
post_parameters
input=post_parameters
)
return github.UserKey.UserKey(self._requester, data, completed=True)
return github.UserKey.UserKey(self._requester, headers, data, completed=True)
def create_repo(self, name, description=github.GithubObject.NotSet, homepage=github.GithubObject.NotSet, private=github.GithubObject.NotSet, has_issues=github.GithubObject.NotSet, has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet, auto_init=github.GithubObject.NotSet, gitignore_template=github.GithubObject.NotSet):
"""
@@ -456,10 +532,9 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
"/user/repos",
None,
post_parameters
input=post_parameters
)
return github.Repository.Repository(self._requester, data, completed=True)
return github.Repository.Repository(self._requester, headers, data, completed=True)
def edit(self, name=github.GithubObject.NotSet, email=github.GithubObject.NotSet, blog=github.GithubObject.NotSet, company=github.GithubObject.NotSet, location=github.GithubObject.NotSet, hireable=github.GithubObject.NotSet, bio=github.GithubObject.NotSet):
"""
@@ -498,8 +573,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
"/user",
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -512,11 +586,9 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(id, (int, long)), id
headers, data = self._requester.requestJsonAndCheck(
"GET",
"/authorizations/" + str(id),
None,
None
"/authorizations/" + str(id)
)
return github.Authorization.Authorization(self._requester, data, completed=True)
return github.Authorization.Authorization(self._requester, headers, data, completed=True)
def get_authorizations(self):
"""
@@ -537,9 +609,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"GET",
"/user/emails",
None,
None
"/user/emails"
)
return data
@@ -676,11 +746,9 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(id, (int, long)), id
headers, data = self._requester.requestJsonAndCheck(
"GET",
"/user/keys/" + str(id),
None,
None
"/user/keys/" + str(id)
)
return github.UserKey.UserKey(self._requester, data, completed=True)
return github.UserKey.UserKey(self._requester, headers, data, completed=True)
def get_keys(self):
"""
@@ -703,15 +771,15 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(id, (str, unicode)), id
headers, data = self._requester.requestJsonAndCheck(
"GET",
"/notifications/threads/" + id,
None,
None
"/notifications/threads/" + id
)
return github.Notification.Notification(self._requester, data, completed=True)
return github.Notification.Notification(self._requester, headers, data, completed=True)
def get_notifications(self, all=github.GithubObject.NotSet, participating=github.GithubObject.NotSet):
"""
:calls: `GET /notifications <http://developer.github.com/v3/activity/notifications>`_
:param all: bool
:param participating: bool
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Notification.Notification`
"""
@@ -767,11 +835,9 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(name, (str, unicode)), name
headers, data = self._requester.requestJsonAndCheck(
"GET",
"/repos/" + self.login + "/" + name,
None,
None
"/repos/" + self.login + "/" + name
)
return github.Repository.Repository(self._requester, data, completed=True)
return github.Repository.Repository(self._requester, headers, data, completed=True)
def get_repos(self, type=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet):
"""
@@ -855,9 +921,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(following, github.NamedUser.NamedUser), following
status, headers, data = self._requester.requestJson(
"GET",
"/user/following/" + following._identity,
None,
None
"/user/following/" + following._identity
)
return status == 204
@@ -870,9 +934,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(starred, github.Repository.Repository), starred
status, headers, data = self._requester.requestJson(
"GET",
"/user/starred/" + starred._identity,
None,
None
"/user/starred/" + starred._identity
)
return status == 204
@@ -885,9 +947,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(subscription, github.Repository.Repository), subscription
status, headers, data = self._requester.requestJson(
"GET",
"/user/subscriptions/" + subscription._identity,
None,
None
"/user/subscriptions/" + subscription._identity
)
return status == 204
@@ -900,9 +960,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(watched, github.Repository.Repository), watched
status, headers, data = self._requester.requestJson(
"GET",
"/user/watched/" + watched._identity,
None,
None
"/user/watched/" + watched._identity
)
return status == 204
@@ -917,8 +975,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
"/user/emails",
None,
post_parameters
input=post_parameters
)
def remove_from_following(self, following):
@@ -930,9 +987,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(following, github.NamedUser.NamedUser), following
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
"/user/following/" + following._identity,
None,
None
"/user/following/" + following._identity
)
def remove_from_starred(self, starred):
@@ -944,9 +999,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(starred, github.Repository.Repository), starred
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
"/user/starred/" + starred._identity,
None,
None
"/user/starred/" + starred._identity
)
def remove_from_subscriptions(self, subscription):
@@ -958,9 +1011,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(subscription, github.Repository.Repository), subscription
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
"/user/subscriptions/" + subscription._identity,
None,
None
"/user/subscriptions/" + subscription._identity
)
def remove_from_watched(self, watched):
@@ -972,9 +1023,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(watched, github.Repository.Repository), watched
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
"/user/watched/" + watched._identity,
None,
None
"/user/watched/" + watched._identity
)
def _initAttributes(self):
@@ -986,8 +1035,12 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
self._created_at = github.GithubObject.NotSet
self._disk_usage = github.GithubObject.NotSet
self._email = github.GithubObject.NotSet
self._events_url = github.GithubObject.NotSet
self._followers = github.GithubObject.NotSet
self._followers_url = github.GithubObject.NotSet
self._following = github.GithubObject.NotSet
self._following_url = github.GithubObject.NotSet
self._gists_url = github.GithubObject.NotSet
self._gravatar_id = github.GithubObject.NotSet
self._hireable = github.GithubObject.NotSet
self._html_url = github.GithubObject.NotSet
@@ -995,13 +1048,20 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
self._location = github.GithubObject.NotSet
self._login = github.GithubObject.NotSet
self._name = github.GithubObject.NotSet
self._organizations_url = github.GithubObject.NotSet
self._owned_private_repos = github.GithubObject.NotSet
self._plan = github.GithubObject.NotSet
self._private_gists = github.GithubObject.NotSet
self._public_gists = github.GithubObject.NotSet
self._public_repos = github.GithubObject.NotSet
self._received_events_url = github.GithubObject.NotSet
self._repos_url = github.GithubObject.NotSet
self._site_admin = github.GithubObject.NotSet
self._starred_url = github.GithubObject.NotSet
self._subscriptions_url = github.GithubObject.NotSet
self._total_private_repos = github.GithubObject.NotSet
self._type = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
def _useAttributes(self, attributes):
@@ -1029,12 +1089,24 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
if "email" in attributes: # pragma no branch
assert attributes["email"] is None or isinstance(attributes["email"], (str, unicode)), attributes["email"]
self._email = attributes["email"]
if "events_url" in attributes: # pragma no branch
assert attributes["events_url"] is None or isinstance(attributes["events_url"], (str, unicode)), attributes["events_url"]
self._events_url = attributes["events_url"]
if "followers" in attributes: # pragma no branch
assert attributes["followers"] is None or isinstance(attributes["followers"], (int, long)), attributes["followers"]
self._followers = attributes["followers"]
if "followers_url" in attributes: # pragma no branch
assert attributes["followers_url"] is None or isinstance(attributes["followers_url"], (str, unicode)), attributes["followers_url"]
self._followers_url = attributes["followers_url"]
if "following" in attributes: # pragma no branch
assert attributes["following"] is None or isinstance(attributes["following"], (int, long)), attributes["following"]
self._following = attributes["following"]
if "following_url" in attributes: # pragma no branch
assert attributes["following_url"] is None or isinstance(attributes["following_url"], (str, unicode)), attributes["following_url"]
self._following_url = attributes["following_url"]
if "gists_url" in attributes: # pragma no branch
assert attributes["gists_url"] is None or isinstance(attributes["gists_url"], (str, unicode)), attributes["gists_url"]
self._gists_url = attributes["gists_url"]
if "gravatar_id" in attributes: # pragma no branch
assert attributes["gravatar_id"] is None or isinstance(attributes["gravatar_id"], (str, unicode)), attributes["gravatar_id"]
self._gravatar_id = attributes["gravatar_id"]
@@ -1056,12 +1128,15 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
if "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
if "organizations_url" in attributes: # pragma no branch
assert attributes["organizations_url"] is None or isinstance(attributes["organizations_url"], (str, unicode)), attributes["organizations_url"]
self._organizations_url = attributes["organizations_url"]
if "owned_private_repos" in attributes: # pragma no branch
assert attributes["owned_private_repos"] is None or isinstance(attributes["owned_private_repos"], (int, long)), attributes["owned_private_repos"]
self._owned_private_repos = attributes["owned_private_repos"]
if "plan" in attributes: # pragma no branch
assert attributes["plan"] is None or isinstance(attributes["plan"], dict), attributes["plan"]
self._plan = None if attributes["plan"] is None else github.Plan.Plan(self._requester, attributes["plan"], completed=False)
self._plan = None if attributes["plan"] is None else github.Plan.Plan(self._requester, self._headers, attributes["plan"], completed=False)
if "private_gists" in attributes: # pragma no branch
assert attributes["private_gists"] is None or isinstance(attributes["private_gists"], (int, long)), attributes["private_gists"]
self._private_gists = attributes["private_gists"]
@@ -1071,12 +1146,30 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
if "public_repos" in attributes: # pragma no branch
assert attributes["public_repos"] is None or isinstance(attributes["public_repos"], (int, long)), attributes["public_repos"]
self._public_repos = attributes["public_repos"]
if "received_events_url" in attributes: # pragma no branch
assert attributes["received_events_url"] is None or isinstance(attributes["received_events_url"], (str, unicode)), attributes["received_events_url"]
self._received_events_url = attributes["received_events_url"]
if "repos_url" in attributes: # pragma no branch
assert attributes["repos_url"] is None or isinstance(attributes["repos_url"], (str, unicode)), attributes["repos_url"]
self._repos_url = attributes["repos_url"]
if "site_admin" in attributes: # pragma no branch
assert attributes["site_admin"] is None or isinstance(attributes["site_admin"], bool), attributes["site_admin"]
self._site_admin = attributes["site_admin"]
if "starred_url" in attributes: # pragma no branch
assert attributes["starred_url"] is None or isinstance(attributes["starred_url"], (str, unicode)), attributes["starred_url"]
self._starred_url = attributes["starred_url"]
if "subscriptions_url" in attributes: # pragma no branch
assert attributes["subscriptions_url"] is None or isinstance(attributes["subscriptions_url"], (str, unicode)), attributes["subscriptions_url"]
self._subscriptions_url = attributes["subscriptions_url"]
if "total_private_repos" in attributes: # pragma no branch
assert attributes["total_private_repos"] is None or isinstance(attributes["total_private_repos"], (int, long)), attributes["total_private_repos"]
self._total_private_repos = attributes["total_private_repos"]
if "type" in attributes: # pragma no branch
assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"]
self._type = attributes["type"]
if "updated_at" in attributes: # pragma no branch
assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"]
self._updated_at = self._parseDatetime(attributes["updated_at"])
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+4 -6
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -112,9 +113,7 @@ class Authorization(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def edit(self, scopes=github.GithubObject.NotSet, add_scopes=github.GithubObject.NotSet, remove_scopes=github.GithubObject.NotSet, note=github.GithubObject.NotSet, note_url=github.GithubObject.NotSet):
@@ -146,8 +145,7 @@ class Authorization(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -165,7 +163,7 @@ class Authorization(github.GithubObject.CompletableGithubObject):
def _useAttributes(self, attributes):
if "app" in attributes: # pragma no branch
assert attributes["app"] is None or isinstance(attributes["app"], dict), attributes["app"]
self._app = None if attributes["app"] is None else github.AuthorizationApplication.AuthorizationApplication(self._requester, attributes["app"], completed=False)
self._app = None if attributes["app"] is None else github.AuthorizationApplication.AuthorizationApplication(self._requester, self._headers, attributes["app"], completed=False)
if "created_at" in attributes: # pragma no branch
assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"]
self._created_at = self._parseDatetime(attributes["created_at"])
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+2 -1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
# #
@@ -55,7 +56,7 @@ class Branch(github.GithubObject.NonCompletableGithubObject):
def _useAttributes(self, attributes):
if "commit" in attributes: # pragma no branch
assert attributes["commit"] is None or isinstance(attributes["commit"], dict), attributes["commit"]
self._commit = None if attributes["commit"] is None else github.Commit.Commit(self._requester, attributes["commit"], completed=False)
self._commit = None if attributes["commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["commit"], completed=False)
if "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
+35 -12
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
# #
@@ -48,6 +49,14 @@ class Commit(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._author)
return self._NoneIfNotSet(self._author)
@property
def comments_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._comments_url)
return self._NoneIfNotSet(self._comments_url)
@property
def commit(self):
"""
@@ -72,6 +81,14 @@ class Commit(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._files)
return self._NoneIfNotSet(self._files)
@property
def html_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def parents(self):
"""
@@ -129,10 +146,9 @@ class Commit(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.url + "/comments",
None,
post_parameters
input=post_parameters
)
return github.CommitComment.CommitComment(self._requester, data, completed=True)
return github.CommitComment.CommitComment(self._requester, headers, data, completed=True)
def create_status(self, state, target_url=github.GithubObject.NotSet, description=github.GithubObject.NotSet):
"""
@@ -155,10 +171,9 @@ class Commit(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
self._parentUrl(self._parentUrl(self.url)) + "/statuses/" + self.sha,
None,
post_parameters
input=post_parameters
)
return github.CommitStatus.CommitStatus(self._requester, data, completed=True)
return github.CommitStatus.CommitStatus(self._requester, headers, data, completed=True)
def get_comments(self):
"""
@@ -190,9 +205,11 @@ class Commit(github.GithubObject.CompletableGithubObject):
def _initAttributes(self):
self._author = github.GithubObject.NotSet
self._comments_url = github.GithubObject.NotSet
self._commit = github.GithubObject.NotSet
self._committer = github.GithubObject.NotSet
self._files = github.GithubObject.NotSet
self._html_url = github.GithubObject.NotSet
self._parents = github.GithubObject.NotSet
self._sha = github.GithubObject.NotSet
self._stats = github.GithubObject.NotSet
@@ -201,23 +218,29 @@ class Commit(github.GithubObject.CompletableGithubObject):
def _useAttributes(self, attributes):
if "author" in attributes: # pragma no branch
assert attributes["author"] is None or isinstance(attributes["author"], dict), attributes["author"]
self._author = None if attributes["author"] is None else github.NamedUser.NamedUser(self._requester, attributes["author"], completed=False)
self._author = None if attributes["author"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["author"], completed=False)
if "comments_url" in attributes: # pragma no branch
assert attributes["comments_url"] is None or isinstance(attributes["comments_url"], (str, unicode)), attributes["comments_url"]
self._comments_url = attributes["comments_url"]
if "commit" in attributes: # pragma no branch
assert attributes["commit"] is None or isinstance(attributes["commit"], dict), attributes["commit"]
self._commit = None if attributes["commit"] is None else github.GitCommit.GitCommit(self._requester, attributes["commit"], completed=False)
self._commit = None if attributes["commit"] is None else github.GitCommit.GitCommit(self._requester, self._headers, attributes["commit"], completed=False)
if "committer" in attributes: # pragma no branch
assert attributes["committer"] is None or isinstance(attributes["committer"], dict), attributes["committer"]
self._committer = None if attributes["committer"] is None else github.NamedUser.NamedUser(self._requester, attributes["committer"], completed=False)
self._committer = None if attributes["committer"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["committer"], completed=False)
if "files" in attributes: # pragma no branch
assert attributes["files"] is None or all(isinstance(element, dict) for element in attributes["files"]), attributes["files"]
self._files = None if attributes["files"] is None else [
github.File.File(self._requester, element, completed=False)
github.File.File(self._requester, self._headers, element, completed=False)
for element in attributes["files"]
]
if "html_url" in attributes: # pragma no branch
assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"]
self._html_url = attributes["html_url"]
if "parents" in attributes: # pragma no branch
assert attributes["parents"] is None or all(isinstance(element, dict) for element in attributes["parents"]), attributes["parents"]
self._parents = None if attributes["parents"] is None else [
Commit(self._requester, element, completed=False)
Commit(self._requester, self._headers, element, completed=False)
for element in attributes["parents"]
]
if "sha" in attributes: # pragma no branch
@@ -225,7 +248,7 @@ class Commit(github.GithubObject.CompletableGithubObject):
self._sha = attributes["sha"]
if "stats" in attributes: # pragma no branch
assert attributes["stats"] is None or isinstance(attributes["stats"], dict), attributes["stats"]
self._stats = None if attributes["stats"] is None else github.CommitStats.CommitStats(self._requester, attributes["stats"], completed=False)
self._stats = None if attributes["stats"] is None else github.CommitStats.CommitStats(self._requester, self._headers, attributes["stats"], completed=False)
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+4 -6
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -128,9 +129,7 @@ class CommitComment(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def edit(self, body):
@@ -146,8 +145,7 @@ class CommitComment(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -197,4 +195,4 @@ class CommitComment(github.GithubObject.CompletableGithubObject):
self._url = attributes["url"]
if "user" in attributes: # pragma no branch
assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"]
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+13 -1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -82,6 +83,13 @@ class CommitStatus(github.GithubObject.NonCompletableGithubObject):
"""
return self._NoneIfNotSet(self._updated_at)
@property
def url(self):
"""
:type: string
"""
return self._NoneIfNotSet(self._url)
def _initAttributes(self):
self._created_at = github.GithubObject.NotSet
self._creator = github.GithubObject.NotSet
@@ -90,6 +98,7 @@ class CommitStatus(github.GithubObject.NonCompletableGithubObject):
self._state = github.GithubObject.NotSet
self._target_url = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
def _useAttributes(self, attributes):
if "created_at" in attributes: # pragma no branch
@@ -97,7 +106,7 @@ class CommitStatus(github.GithubObject.NonCompletableGithubObject):
self._created_at = self._parseDatetime(attributes["created_at"])
if "creator" in attributes: # pragma no branch
assert attributes["creator"] is None or isinstance(attributes["creator"], dict), attributes["creator"]
self._creator = None if attributes["creator"] is None else github.NamedUser.NamedUser(self._requester, attributes["creator"], completed=False)
self._creator = None if attributes["creator"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["creator"], completed=False)
if "description" in attributes: # pragma no branch
assert attributes["description"] is None or isinstance(attributes["description"], (str, unicode)), attributes["description"]
self._description = attributes["description"]
@@ -113,3 +122,6 @@ class CommitStatus(github.GithubObject.NonCompletableGithubObject):
if "updated_at" in attributes: # pragma no branch
assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"]
self._updated_at = self._parseDatetime(attributes["updated_at"])
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+16 -3
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -90,6 +91,14 @@ class Comparison(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def merge_base_commit(self):
"""
:type: :class:`github.Commit.Commit`
"""
self._completeIfNotSet(self._merge_base_commit)
return self._NoneIfNotSet(self._merge_base_commit)
@property
def patch_url(self):
"""
@@ -138,6 +147,7 @@ class Comparison(github.GithubObject.CompletableGithubObject):
self._diff_url = github.GithubObject.NotSet
self._files = github.GithubObject.NotSet
self._html_url = github.GithubObject.NotSet
self._merge_base_commit = github.GithubObject.NotSet
self._patch_url = github.GithubObject.NotSet
self._permalink_url = github.GithubObject.NotSet
self._status = github.GithubObject.NotSet
@@ -150,14 +160,14 @@ class Comparison(github.GithubObject.CompletableGithubObject):
self._ahead_by = attributes["ahead_by"]
if "base_commit" in attributes: # pragma no branch
assert attributes["base_commit"] is None or isinstance(attributes["base_commit"], dict), attributes["base_commit"]
self._base_commit = None if attributes["base_commit"] is None else github.Commit.Commit(self._requester, attributes["base_commit"], completed=False)
self._base_commit = None if attributes["base_commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["base_commit"], completed=False)
if "behind_by" in attributes: # pragma no branch
assert attributes["behind_by"] is None or isinstance(attributes["behind_by"], (int, long)), attributes["behind_by"]
self._behind_by = attributes["behind_by"]
if "commits" in attributes: # pragma no branch
assert attributes["commits"] is None or all(isinstance(element, dict) for element in attributes["commits"]), attributes["commits"]
self._commits = None if attributes["commits"] is None else [
github.Commit.Commit(self._requester, element, completed=False)
github.Commit.Commit(self._requester, self._headers, element, completed=False)
for element in attributes["commits"]
]
if "diff_url" in attributes: # pragma no branch
@@ -166,12 +176,15 @@ class Comparison(github.GithubObject.CompletableGithubObject):
if "files" in attributes: # pragma no branch
assert attributes["files"] is None or all(isinstance(element, dict) for element in attributes["files"]), attributes["files"]
self._files = None if attributes["files"] is None else [
github.File.File(self._requester, element, completed=False)
github.File.File(self._requester, self._headers, element, completed=False)
for element in attributes["files"]
]
if "html_url" in attributes: # pragma no branch
assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"]
self._html_url = attributes["html_url"]
if "merge_base_commit" in attributes: # pragma no branch
assert attributes["merge_base_commit"] is None or isinstance(attributes["merge_base_commit"], dict), attributes["merge_base_commit"]
self._merge_base_commit = None if attributes["merge_base_commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["merge_base_commit"], completed=False)
if "patch_url" in attributes: # pragma no branch
assert attributes["patch_url"] is None or isinstance(attributes["patch_url"], (str, unicode)), attributes["patch_url"]
self._patch_url = attributes["patch_url"]
+44
View File
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
############################ Copyrights and license ############################
# #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/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/>. #
# #
################################################################################
# #193: Line endings should be linux style
# TODO: As of Thu Aug 21 22:40:13 (BJT) Chinese Standard Time 2013
# lots of consts in this project are explict
# should realy round them up and reference them by consts
# EDIT: well, maybe :-)
################################################################################
# Request Header #
# (Case sensitive) #
################################################################################
REQ_IF_NONE_MATCH = "If-None-Match"
REQ_IF_MODIFIED_SINCE = "If-Modified-Since"
################################################################################
# Response Header #
# (Lower Case) #
################################################################################
RES_ETAG = "etag"
RES_LAST_MODIFED = "last-modified"
+25
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -47,6 +48,22 @@ class ContentFile(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._encoding)
return self._NoneIfNotSet(self._encoding)
@property
def git_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._git_url)
return self._NoneIfNotSet(self._git_url)
@property
def html_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def name(self):
"""
@@ -98,6 +115,8 @@ class ContentFile(github.GithubObject.CompletableGithubObject):
def _initAttributes(self):
self._content = github.GithubObject.NotSet
self._encoding = github.GithubObject.NotSet
self._git_url = github.GithubObject.NotSet
self._html_url = github.GithubObject.NotSet
self._name = github.GithubObject.NotSet
self._path = github.GithubObject.NotSet
self._sha = github.GithubObject.NotSet
@@ -111,6 +130,12 @@ class ContentFile(github.GithubObject.CompletableGithubObject):
if "encoding" in attributes: # pragma no branch
assert attributes["encoding"] is None or isinstance(attributes["encoding"], (str, unicode)), attributes["encoding"]
self._encoding = attributes["encoding"]
if "git_url" in attributes: # pragma no branch
assert attributes["git_url"] is None or isinstance(attributes["git_url"], (str, unicode)), attributes["git_url"]
self._git_url = attributes["git_url"]
if "html_url" in attributes: # pragma no branch
assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"]
self._html_url = attributes["html_url"]
if "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
+2 -3
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -198,9 +199,7 @@ class Download(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def _initAttributes(self):
+4 -3
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
# #
@@ -105,7 +106,7 @@ class Event(github.GithubObject.NonCompletableGithubObject):
def _useAttributes(self, attributes):
if "actor" in attributes: # pragma no branch
assert attributes["actor"] is None or isinstance(attributes["actor"], dict), attributes["actor"]
self._actor = None if attributes["actor"] is None else github.NamedUser.NamedUser(self._requester, attributes["actor"], completed=False)
self._actor = None if attributes["actor"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["actor"], completed=False)
if "created_at" in attributes: # pragma no branch
assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"]
self._created_at = self._parseDatetime(attributes["created_at"])
@@ -114,7 +115,7 @@ class Event(github.GithubObject.NonCompletableGithubObject):
self._id = attributes["id"]
if "org" in attributes: # pragma no branch
assert attributes["org"] is None or isinstance(attributes["org"], dict), attributes["org"]
self._org = None if attributes["org"] is None else github.Organization.Organization(self._requester, attributes["org"], completed=False)
self._org = None if attributes["org"] is None else github.Organization.Organization(self._requester, self._headers, attributes["org"], completed=False)
if "payload" in attributes: # pragma no branch
assert attributes["payload"] is None or isinstance(attributes["payload"], dict), attributes["payload"]
self._payload = attributes["payload"]
@@ -123,7 +124,7 @@ class Event(github.GithubObject.NonCompletableGithubObject):
self._public = attributes["public"]
if "repo" in attributes: # pragma no branch
assert attributes["repo"] is None or isinstance(attributes["repo"], dict), attributes["repo"]
self._repo = None if attributes["repo"] is None else github.Repository.Repository(self._requester, attributes["repo"], completed=False)
self._repo = None if attributes["repo"] is None else github.Repository.Repository(self._requester, self._headers, attributes["repo"], completed=False)
if "type" in attributes: # pragma no branch
assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"]
self._type = attributes["type"]
+12
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -52,6 +53,13 @@ class File(github.GithubObject.NonCompletableGithubObject):
"""
return self._NoneIfNotSet(self._changes)
@property
def contents_url(self):
"""
:type: string
"""
return self._NoneIfNotSet(self._contents_url)
@property
def deletions(self):
"""
@@ -98,6 +106,7 @@ class File(github.GithubObject.NonCompletableGithubObject):
self._additions = github.GithubObject.NotSet
self._blob_url = github.GithubObject.NotSet
self._changes = github.GithubObject.NotSet
self._contents_url = github.GithubObject.NotSet
self._deletions = github.GithubObject.NotSet
self._filename = github.GithubObject.NotSet
self._patch = github.GithubObject.NotSet
@@ -115,6 +124,9 @@ class File(github.GithubObject.NonCompletableGithubObject):
if "changes" in attributes: # pragma no branch
assert attributes["changes"] is None or isinstance(attributes["changes"], (int, long)), attributes["changes"]
self._changes = attributes["changes"]
if "contents_url" in attributes: # pragma no branch
assert attributes["contents_url"] is None or isinstance(attributes["contents_url"], (str, unicode)), attributes["contents_url"]
self._contents_url = attributes["contents_url"]
if "deletions" in attributes: # pragma no branch
assert attributes["deletions"] is None or isinstance(attributes["deletions"], (int, long)), attributes["deletions"]
self._deletions = attributes["deletions"]
+54 -31
View File
@@ -5,6 +5,7 @@
# Copyright 2012 Steve English <steve.english@navetas.com> #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -46,6 +47,22 @@ class Gist(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._comments)
return self._NoneIfNotSet(self._comments)
@property
def comments_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._comments_url)
return self._NoneIfNotSet(self._comments_url)
@property
def commits_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._commits_url)
return self._NoneIfNotSet(self._commits_url)
@property
def created_at(self):
"""
@@ -86,6 +103,14 @@ class Gist(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._forks)
return self._NoneIfNotSet(self._forks)
@property
def forks_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._forks_url)
return self._NoneIfNotSet(self._forks_url)
@property
def git_pull_url(self):
"""
@@ -171,23 +196,20 @@ class Gist(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.url + "/comments",
None,
post_parameters
input=post_parameters
)
return github.GistComment.GistComment(self._requester, data, completed=True)
return github.GistComment.GistComment(self._requester, headers, data, completed=True)
def create_fork(self):
"""
:calls: `POST /gists/:id/fork <http://developer.github.com/v3/todo>`_
:calls: `POST /gists/:id/forks <http://developer.github.com/v3/gists>`_
:rtype: :class:`github.Gist.Gist`
"""
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.url + "/fork",
None,
None
self.url + "/forks"
)
return Gist(self._requester, data, completed=True)
return Gist(self._requester, headers, data, completed=True)
def delete(self):
"""
@@ -196,9 +218,7 @@ class Gist(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def edit(self, description=github.GithubObject.NotSet, files=github.GithubObject.NotSet):
@@ -218,8 +238,7 @@ class Gist(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -232,11 +251,9 @@ class Gist(github.GithubObject.CompletableGithubObject):
assert isinstance(id, (int, long)), id
headers, data = self._requester.requestJsonAndCheck(
"GET",
self.url + "/comments/" + str(id),
None,
None
self.url + "/comments/" + str(id)
)
return github.GistComment.GistComment(self._requester, data, completed=True)
return github.GistComment.GistComment(self._requester, headers, data, completed=True)
def get_comments(self):
"""
@@ -257,9 +274,7 @@ class Gist(github.GithubObject.CompletableGithubObject):
"""
status, headers, data = self._requester.requestJson(
"GET",
self.url + "/star",
None,
None
self.url + "/star"
)
return status == 204
@@ -270,9 +285,7 @@ class Gist(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url + "/star",
None,
None
self.url + "/star"
)
def set_starred(self):
@@ -282,18 +295,19 @@ class Gist(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"PUT",
self.url + "/star",
None,
None
self.url + "/star"
)
def _initAttributes(self):
self._comments = github.GithubObject.NotSet
self._comments_url = github.GithubObject.NotSet
self._commits_url = github.GithubObject.NotSet
self._created_at = github.GithubObject.NotSet
self._description = github.GithubObject.NotSet
self._files = github.GithubObject.NotSet
self._fork_of = github.GithubObject.NotSet
self._forks = github.GithubObject.NotSet
self._forks_url = github.GithubObject.NotSet
self._git_pull_url = github.GithubObject.NotSet
self._git_push_url = github.GithubObject.NotSet
self._history = github.GithubObject.NotSet
@@ -308,6 +322,12 @@ class Gist(github.GithubObject.CompletableGithubObject):
if "comments" in attributes: # pragma no branch
assert attributes["comments"] is None or isinstance(attributes["comments"], (int, long)), attributes["comments"]
self._comments = attributes["comments"]
if "comments_url" in attributes: # pragma no branch
assert attributes["comments_url"] is None or isinstance(attributes["comments_url"], (str, unicode)), attributes["comments_url"]
self._comments_url = attributes["comments_url"]
if "commits_url" in attributes: # pragma no branch
assert attributes["commits_url"] is None or isinstance(attributes["commits_url"], (str, unicode)), attributes["commits_url"]
self._commits_url = attributes["commits_url"]
if "created_at" in attributes: # pragma no branch
assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"]
self._created_at = self._parseDatetime(attributes["created_at"])
@@ -317,18 +337,21 @@ class Gist(github.GithubObject.CompletableGithubObject):
if "files" in attributes: # pragma no branch
assert attributes["files"] is None or all(isinstance(element, dict) for element in attributes["files"].itervalues()), attributes["files"]
self._files = None if attributes["files"] is None else dict(
(key, github.GistFile.GistFile(self._requester, element, completed=False))
(key, github.GistFile.GistFile(self._requester, self._headers, element, completed=False))
for key, element in attributes["files"].iteritems()
)
if "fork_of" in attributes: # pragma no branch
assert attributes["fork_of"] is None or isinstance(attributes["fork_of"], dict), attributes["fork_of"]
self._fork_of = None if attributes["fork_of"] is None else Gist(self._requester, attributes["fork_of"], completed=False)
self._fork_of = None if attributes["fork_of"] is None else Gist(self._requester, self._headers, attributes["fork_of"], completed=False)
if "forks" in attributes: # pragma no branch
assert attributes["forks"] is None or all(isinstance(element, dict) for element in attributes["forks"]), attributes["forks"]
self._forks = None if attributes["forks"] is None else [
Gist(self._requester, element, completed=False)
Gist(self._requester, self._headers, element, completed=False)
for element in attributes["forks"]
]
if "forks_url" in attributes: # pragma no branch
assert attributes["forks_url"] is None or isinstance(attributes["forks_url"], (str, unicode)), attributes["forks_url"]
self._forks_url = attributes["forks_url"]
if "git_pull_url" in attributes: # pragma no branch
assert attributes["git_pull_url"] is None or isinstance(attributes["git_pull_url"], (str, unicode)), attributes["git_pull_url"]
self._git_pull_url = attributes["git_pull_url"]
@@ -338,7 +361,7 @@ class Gist(github.GithubObject.CompletableGithubObject):
if "history" in attributes: # pragma no branch
assert attributes["history"] is None or all(isinstance(element, dict) for element in attributes["history"]), attributes["history"]
self._history = None if attributes["history"] is None else [
github.GistHistoryState.GistHistoryState(self._requester, element, completed=False)
github.GistHistoryState.GistHistoryState(self._requester, self._headers, element, completed=False)
for element in attributes["history"]
]
if "html_url" in attributes: # pragma no branch
@@ -358,4 +381,4 @@ class Gist(github.GithubObject.CompletableGithubObject):
self._url = attributes["url"]
if "user" in attributes: # pragma no branch
assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"]
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)
+4 -6
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -88,9 +89,7 @@ class GistComment(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def edit(self, body):
@@ -106,8 +105,7 @@ class GistComment(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -137,4 +135,4 @@ class GistComment(github.GithubObject.CompletableGithubObject):
self._url = attributes["url"]
if "user" in attributes: # pragma no branch
assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"]
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)
+12
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -66,12 +67,20 @@ class GistFile(github.GithubObject.NonCompletableGithubObject):
"""
return self._NoneIfNotSet(self._size)
@property
def type(self):
"""
:type: string
"""
return self._NoneIfNotSet(self._type)
def _initAttributes(self):
self._content = github.GithubObject.NotSet
self._filename = github.GithubObject.NotSet
self._language = github.GithubObject.NotSet
self._raw_url = github.GithubObject.NotSet
self._size = github.GithubObject.NotSet
self._type = github.GithubObject.NotSet
def _useAttributes(self, attributes):
if "content" in attributes: # pragma no branch
@@ -89,3 +98,6 @@ class GistFile(github.GithubObject.NonCompletableGithubObject):
if "size" in attributes: # pragma no branch
assert attributes["size"] is None or isinstance(attributes["size"], (int, long)), attributes["size"]
self._size = attributes["size"]
if "type" in attributes: # pragma no branch
assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"]
self._type = attributes["type"]
+193 -2
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -27,6 +28,7 @@ import github.GithubObject
import github.NamedUser
import github.CommitStats
import github.Gist
class GistHistoryState(github.GithubObject.CompletableGithubObject):
@@ -42,6 +44,30 @@ class GistHistoryState(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._change_status)
return self._NoneIfNotSet(self._change_status)
@property
def comments(self):
"""
:type: integer
"""
self._completeIfNotSet(self._comments)
return self._NoneIfNotSet(self._comments)
@property
def comments_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._comments_url)
return self._NoneIfNotSet(self._comments_url)
@property
def commits_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._commits_url)
return self._NoneIfNotSet(self._commits_url)
@property
def committed_at(self):
"""
@@ -50,6 +76,102 @@ class GistHistoryState(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._committed_at)
return self._NoneIfNotSet(self._committed_at)
@property
def created_at(self):
"""
:type: datetime.datetime
"""
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def description(self):
"""
:type: string
"""
self._completeIfNotSet(self._description)
return self._NoneIfNotSet(self._description)
@property
def files(self):
"""
:type: dict of string to :class:`github.GistFile.GistFile`
"""
self._completeIfNotSet(self._files)
return self._NoneIfNotSet(self._files)
@property
def forks(self):
"""
:type: list of :class:`github.Gist.Gist`
"""
self._completeIfNotSet(self._forks)
return self._NoneIfNotSet(self._forks)
@property
def forks_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._forks_url)
return self._NoneIfNotSet(self._forks_url)
@property
def git_pull_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._git_pull_url)
return self._NoneIfNotSet(self._git_pull_url)
@property
def git_push_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._git_push_url)
return self._NoneIfNotSet(self._git_push_url)
@property
def history(self):
"""
:type: list of :class:`GistHistoryState`
"""
self._completeIfNotSet(self._history)
return self._NoneIfNotSet(self._history)
@property
def html_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def id(self):
"""
:type: string
"""
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def public(self):
"""
:type: bool
"""
self._completeIfNotSet(self._public)
return self._NoneIfNotSet(self._public)
@property
def updated_at(self):
"""
:type: datetime.datetime
"""
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url(self):
"""
@@ -76,7 +198,22 @@ class GistHistoryState(github.GithubObject.CompletableGithubObject):
def _initAttributes(self):
self._change_status = github.GithubObject.NotSet
self._comments = github.GithubObject.NotSet
self._comments_url = github.GithubObject.NotSet
self._commits_url = github.GithubObject.NotSet
self._committed_at = github.GithubObject.NotSet
self._created_at = github.GithubObject.NotSet
self._description = github.GithubObject.NotSet
self._files = github.GithubObject.NotSet
self._forks = github.GithubObject.NotSet
self._forks_url = github.GithubObject.NotSet
self._git_pull_url = github.GithubObject.NotSet
self._git_push_url = github.GithubObject.NotSet
self._history = github.GithubObject.NotSet
self._html_url = github.GithubObject.NotSet
self._id = github.GithubObject.NotSet
self._public = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
self._user = github.GithubObject.NotSet
self._version = github.GithubObject.NotSet
@@ -84,16 +221,70 @@ class GistHistoryState(github.GithubObject.CompletableGithubObject):
def _useAttributes(self, attributes):
if "change_status" in attributes: # pragma no branch
assert attributes["change_status"] is None or isinstance(attributes["change_status"], dict), attributes["change_status"]
self._change_status = None if attributes["change_status"] is None else github.CommitStats.CommitStats(self._requester, attributes["change_status"], completed=False)
self._change_status = None if attributes["change_status"] is None else github.CommitStats.CommitStats(self._requester, self._headers, attributes["change_status"], completed=False)
if "comments" in attributes: # pragma no branch
assert attributes["comments"] is None or isinstance(attributes["comments"], (int, long)), attributes["comments"]
self._comments = attributes["comments"]
if "comments_url" in attributes: # pragma no branch
assert attributes["comments_url"] is None or isinstance(attributes["comments_url"], (str, unicode)), attributes["comments_url"]
self._comments_url = attributes["comments_url"]
if "commits_url" in attributes: # pragma no branch
assert attributes["commits_url"] is None or isinstance(attributes["commits_url"], (str, unicode)), attributes["commits_url"]
self._commits_url = attributes["commits_url"]
if "committed_at" in attributes: # pragma no branch
assert attributes["committed_at"] is None or isinstance(attributes["committed_at"], (str, unicode)), attributes["committed_at"]
self._committed_at = self._parseDatetime(attributes["committed_at"])
if "created_at" in attributes: # pragma no branch
assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"]
self._created_at = self._parseDatetime(attributes["created_at"])
if "description" in attributes: # pragma no branch
assert attributes["description"] is None or isinstance(attributes["description"], (str, unicode)), attributes["description"]
self._description = attributes["description"]
if "files" in attributes: # pragma no branch
assert attributes["files"] is None or all(isinstance(element, dict) for element in attributes["files"].itervalues()), attributes["files"]
self._files = None if attributes["files"] is None else dict(
(key, github.GistFile.GistFile(self._requester, self._headers, element, completed=False))
for key, element in attributes["files"].iteritems()
)
if "forks" in attributes: # pragma no branch
assert attributes["forks"] is None or all(isinstance(element, dict) for element in attributes["forks"]), attributes["forks"]
self._forks = None if attributes["forks"] is None else [
github.Gist.Gist(self._requester, self._headers, element, completed=False)
for element in attributes["forks"]
]
if "forks_url" in attributes: # pragma no branch
assert attributes["forks_url"] is None or isinstance(attributes["forks_url"], (str, unicode)), attributes["forks_url"]
self._forks_url = attributes["forks_url"]
if "git_pull_url" in attributes: # pragma no branch
assert attributes["git_pull_url"] is None or isinstance(attributes["git_pull_url"], (str, unicode)), attributes["git_pull_url"]
self._git_pull_url = attributes["git_pull_url"]
if "git_push_url" in attributes: # pragma no branch
assert attributes["git_push_url"] is None or isinstance(attributes["git_push_url"], (str, unicode)), attributes["git_push_url"]
self._git_push_url = attributes["git_push_url"]
if "history" in attributes: # pragma no branch
assert attributes["history"] is None or all(isinstance(element, dict) for element in attributes["history"]), attributes["history"]
self._history = None if attributes["history"] is None else [
GistHistoryState(self._requester, self._headers, element, completed=False)
for element in attributes["history"]
]
if "html_url" in attributes: # pragma no branch
assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"]
self._html_url = attributes["html_url"]
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], (str, unicode)), attributes["id"]
self._id = attributes["id"]
if "public" in attributes: # pragma no branch
assert attributes["public"] is None or isinstance(attributes["public"], bool), attributes["public"]
self._public = attributes["public"]
if "updated_at" in attributes: # pragma no branch
assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"]
self._updated_at = self._parseDatetime(attributes["updated_at"])
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
if "user" in attributes: # pragma no branch
assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"]
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)
if "version" in attributes: # pragma no branch
assert attributes["version"] is None or isinstance(attributes["version"], (str, unicode)), attributes["version"]
self._version = attributes["version"]
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+17 -4
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -50,6 +51,14 @@ class GitCommit(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._committer)
return self._NoneIfNotSet(self._committer)
@property
def html_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def message(self):
"""
@@ -97,6 +106,7 @@ class GitCommit(github.GithubObject.CompletableGithubObject):
def _initAttributes(self):
self._author = github.GithubObject.NotSet
self._committer = github.GithubObject.NotSet
self._html_url = github.GithubObject.NotSet
self._message = github.GithubObject.NotSet
self._parents = github.GithubObject.NotSet
self._sha = github.GithubObject.NotSet
@@ -106,17 +116,20 @@ class GitCommit(github.GithubObject.CompletableGithubObject):
def _useAttributes(self, attributes):
if "author" in attributes: # pragma no branch
assert attributes["author"] is None or isinstance(attributes["author"], dict), attributes["author"]
self._author = None if attributes["author"] is None else github.GitAuthor.GitAuthor(self._requester, attributes["author"], completed=False)
self._author = None if attributes["author"] is None else github.GitAuthor.GitAuthor(self._requester, self._headers, attributes["author"], completed=False)
if "committer" in attributes: # pragma no branch
assert attributes["committer"] is None or isinstance(attributes["committer"], dict), attributes["committer"]
self._committer = None if attributes["committer"] is None else github.GitAuthor.GitAuthor(self._requester, attributes["committer"], completed=False)
self._committer = None if attributes["committer"] is None else github.GitAuthor.GitAuthor(self._requester, self._headers, attributes["committer"], completed=False)
if "html_url" in attributes: # pragma no branch
assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"]
self._html_url = attributes["html_url"]
if "message" in attributes: # pragma no branch
assert attributes["message"] is None or isinstance(attributes["message"], (str, unicode)), attributes["message"]
self._message = attributes["message"]
if "parents" in attributes: # pragma no branch
assert attributes["parents"] is None or all(isinstance(element, dict) for element in attributes["parents"]), attributes["parents"]
self._parents = None if attributes["parents"] is None else [
GitCommit(self._requester, element, completed=False)
GitCommit(self._requester, self._headers, element, completed=False)
for element in attributes["parents"]
]
if "sha" in attributes: # pragma no branch
@@ -124,7 +137,7 @@ class GitCommit(github.GithubObject.CompletableGithubObject):
self._sha = attributes["sha"]
if "tree" in attributes: # pragma no branch
assert attributes["tree"] is None or isinstance(attributes["tree"], dict), attributes["tree"]
self._tree = None if attributes["tree"] is None else github.GitTree.GitTree(self._requester, attributes["tree"], completed=False)
self._tree = None if attributes["tree"] is None else github.GitTree.GitTree(self._requester, self._headers, attributes["tree"], completed=False)
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+4 -6
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -64,9 +65,7 @@ class GitRef(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def edit(self, sha, force=github.GithubObject.NotSet):
@@ -86,8 +85,7 @@ class GitRef(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -99,7 +97,7 @@ class GitRef(github.GithubObject.CompletableGithubObject):
def _useAttributes(self, attributes):
if "object" in attributes: # pragma no branch
assert attributes["object"] is None or isinstance(attributes["object"], dict), attributes["object"]
self._object = None if attributes["object"] is None else github.GitObject.GitObject(self._requester, attributes["object"], completed=False)
self._object = None if attributes["object"] is None else github.GitObject.GitObject(self._requester, self._headers, attributes["object"], completed=False)
if "ref" in attributes: # pragma no branch
assert attributes["ref"] is None or isinstance(attributes["ref"], (str, unicode)), attributes["ref"]
self._ref = attributes["ref"]
+3 -2
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -96,7 +97,7 @@ class GitTag(github.GithubObject.CompletableGithubObject):
self._message = attributes["message"]
if "object" in attributes: # pragma no branch
assert attributes["object"] is None or isinstance(attributes["object"], dict), attributes["object"]
self._object = None if attributes["object"] is None else github.GitObject.GitObject(self._requester, attributes["object"], completed=False)
self._object = None if attributes["object"] is None else github.GitObject.GitObject(self._requester, self._headers, attributes["object"], completed=False)
if "sha" in attributes: # pragma no branch
assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"]
self._sha = attributes["sha"]
@@ -105,7 +106,7 @@ class GitTag(github.GithubObject.CompletableGithubObject):
self._tag = attributes["tag"]
if "tagger" in attributes: # pragma no branch
assert attributes["tagger"] is None or isinstance(attributes["tagger"], dict), attributes["tagger"]
self._tagger = None if attributes["tagger"] is None else github.GitAuthor.GitAuthor(self._requester, attributes["tagger"], completed=False)
self._tagger = None if attributes["tagger"] is None else github.GitAuthor.GitAuthor(self._requester, self._headers, attributes["tagger"], completed=False)
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+2 -1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -73,7 +74,7 @@ class GitTree(github.GithubObject.CompletableGithubObject):
if "tree" in attributes: # pragma no branch
assert attributes["tree"] is None or all(isinstance(element, dict) for element in attributes["tree"]), attributes["tree"]
self._tree = None if attributes["tree"] is None else [
github.GitTreeElement.GitTreeElement(self._requester, element, completed=False)
github.GitTreeElement.GitTreeElement(self._requester, self._headers, element, completed=False)
for element in attributes["tree"]
]
if "url" in attributes: # pragma no branch
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+74 -10
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -26,6 +27,7 @@
import datetime
import GithubException
import Consts
class _NotSetType:
@@ -38,14 +40,32 @@ class GithubObject(object):
"""
Base class for all classes representing objects returned by the API.
"""
def __init__(self, requester, attributes, completed):
'''
A global debug flag to enable header validation by requester for all objects
'''
CHECK_AFTER_INIT_FLAG = False
@classmethod
def setCheckAfterInitFlag(cls, flag):
cls.CHECK_AFTER_INIT_FLAG = flag
def __init__(self, requester, headers, attributes, completed):
self._requester = requester
self._initAttributes()
self._storeAndUseAttributes(attributes)
self._storeAndUseAttributes(headers, attributes)
def _storeAndUseAttributes(self, attributes):
self._useAttributes(attributes)
# Ask requester to do some checking, for debug and test purpose
# Since it's most handy to access and kinda all-knowing
if self.CHECK_AFTER_INIT_FLAG: # pragma no branch (Flag always set in tests)
requester.check_me(self)
def _storeAndUseAttributes(self, headers, attributes):
# Make sure headers are assigned before calling _useAttributes
# (Some derived classes will use headers in _useAttributes)
self._headers = headers
self._rawData = attributes
self._useAttributes(attributes)
@property
def raw_data(self):
@@ -55,6 +75,14 @@ class GithubObject(object):
self._completeIfNeeded()
return self._rawData
@property
def raw_headers(self):
"""
:type: dict
"""
self._completeIfNeeded()
return self._headers
@staticmethod
def _parentUrl(url):
return "/".join(url.split("/")[: -1])
@@ -77,6 +105,20 @@ class GithubObject(object):
else:
return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%SZ")
@property
def etag(self):
'''
:type str
'''
return self._headers.get(Consts.RES_ETAG)
@property
def last_modified(self):
'''
:type str
'''
return self._headers.get(Consts.RES_LAST_MODIFED)
class NonCompletableGithubObject(GithubObject):
def _completeIfNeeded(self):
@@ -84,8 +126,8 @@ class NonCompletableGithubObject(GithubObject):
class CompletableGithubObject(GithubObject):
def __init__(self, requester, attributes, completed):
GithubObject.__init__(self, requester, attributes, completed)
def __init__(self, requester, headers, attributes, completed):
GithubObject.__init__(self, requester, headers, attributes, completed)
self.__completed = completed
def _completeIfNotSet(self, value):
@@ -99,9 +141,31 @@ class CompletableGithubObject(GithubObject):
def __complete(self):
headers, data = self._requester.requestJsonAndCheck(
"GET",
self._url,
None,
None
self._url
)
self._storeAndUseAttributes(data)
self._storeAndUseAttributes(headers, data)
self.__completed = True
def update(self):
'''
Check and update the object with conditional request
:rtype: Boolean value indicating whether the object is changed
'''
conditionalRequestHeader = dict()
if self.etag is not None:
conditionalRequestHeader[Consts.REQ_IF_NONE_MATCH] = self.etag
if self.last_modified is not None:
conditionalRequestHeader[Consts.REQ_IF_MODIFIED_SINCE] = self.last_modified
status, responseHeaders, output = self._requester.requestJson(
"GET",
self._url,
headers=conditionalRequestHeader
)
if status == 304:
return False
else:
headers, data = self._requester._Requester__check(status, responseHeaders, output)
self._storeAndUseAttributes(headers, data)
self.__completed = True
return True
+1
View File
@@ -3,6 +3,7 @@
############################ Copyrights and license ############################
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+19 -11
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -30,7 +31,7 @@ import github.HookResponse
class Hook(github.GithubObject.CompletableGithubObject):
"""
This class represents Hooks as returned for example by http://developer.github.com/v3/todo
This class represents Hooks as returned for example by http://developer.github.com/v3/repos/hooks
"""
@property
@@ -89,6 +90,14 @@ class Hook(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._name)
return self._NoneIfNotSet(self._name)
@property
def test_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._test_url)
return self._NoneIfNotSet(self._test_url)
@property
def updated_at(self):
"""
@@ -112,9 +121,7 @@ class Hook(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def edit(self, name, config, events=github.GithubObject.NotSet, add_events=github.GithubObject.NotSet, remove_events=github.GithubObject.NotSet, active=github.GithubObject.NotSet):
@@ -149,21 +156,18 @@ class Hook(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
def test(self):
"""
:calls: `POST /repos/:owner/:repo/hooks/:id/test <http://developer.github.com/v3/todo>`_
:calls: `POST /repos/:owner/:repo/hooks/:id/tests <http://developer.github.com/v3/repos/hooks>`_
:rtype: None
"""
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.url + "/test",
None,
None
self.url + "/tests"
)
def _initAttributes(self):
@@ -174,6 +178,7 @@ class Hook(github.GithubObject.CompletableGithubObject):
self._id = github.GithubObject.NotSet
self._last_response = github.GithubObject.NotSet
self._name = github.GithubObject.NotSet
self._test_url = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
@@ -195,10 +200,13 @@ class Hook(github.GithubObject.CompletableGithubObject):
self._id = attributes["id"]
if "last_response" in attributes: # pragma no branch
assert attributes["last_response"] is None or isinstance(attributes["last_response"], dict), attributes["last_response"]
self._last_response = None if attributes["last_response"] is None else github.HookResponse.HookResponse(self._requester, attributes["last_response"], completed=False)
self._last_response = None if attributes["last_response"] is None else github.HookResponse.HookResponse(self._requester, self._headers, attributes["last_response"], completed=False)
if "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
if "test_url" in attributes: # pragma no branch
assert attributes["test_url"] is None or isinstance(attributes["test_url"], (str, unicode)), attributes["test_url"]
self._test_url = attributes["test_url"]
if "updated_at" in attributes: # pragma no branch
assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"]
self._updated_at = self._parseDatetime(attributes["updated_at"])
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+54 -27
View File
@@ -6,6 +6,7 @@
# Copyright 2012 Philip Kimmey <philip@rover.com> #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Stuart Glaser <stuglaser@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
@@ -83,6 +84,14 @@ class Issue(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._comments)
return self._NoneIfNotSet(self._comments)
@property
def comments_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._comments_url)
return self._NoneIfNotSet(self._comments_url)
@property
def created_at(self):
"""
@@ -91,6 +100,14 @@ class Issue(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def events_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._events_url)
return self._NoneIfNotSet(self._events_url)
@property
def html_url(self):
"""
@@ -115,6 +132,14 @@ class Issue(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._labels)
return self._NoneIfNotSet(self._labels)
@property
def labels_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._labels_url)
return self._NoneIfNotSet(self._labels_url)
@property
def milestone(self):
"""
@@ -148,7 +173,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
if self._repository is github.GithubObject.NotSet:
# The repository was not set automatically, so it must be looked up by url.
repo_url = "/".join(self.url.split("/")[:-2])
self._repository = github.Repository.Repository(self._requester, {'url': repo_url}, False)
self._repository = github.Repository.Repository(self._requester, self._headers, {'url': repo_url}, completed=False)
return self._repository
@property
@@ -202,8 +227,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.url + "/labels",
None,
post_parameters
input=post_parameters
)
def create_comment(self, body):
@@ -219,10 +243,9 @@ class Issue(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.url + "/comments",
None,
post_parameters
input=post_parameters
)
return github.IssueComment.IssueComment(self._requester, data, completed=True)
return github.IssueComment.IssueComment(self._requester, headers, data, completed=True)
def delete_labels(self):
"""
@@ -231,9 +254,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url + "/labels",
None,
None
self.url + "/labels"
)
def edit(self, title=github.GithubObject.NotSet, body=github.GithubObject.NotSet, assignee=github.GithubObject.NotSet, state=github.GithubObject.NotSet, milestone=github.GithubObject.NotSet, labels=github.GithubObject.NotSet):
@@ -269,8 +290,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -283,11 +303,9 @@ class Issue(github.GithubObject.CompletableGithubObject):
assert isinstance(id, (int, long)), id
headers, data = self._requester.requestJsonAndCheck(
"GET",
self._parentUrl(self.url) + "/comments/" + str(id),
None,
None
self._parentUrl(self.url) + "/comments/" + str(id)
)
return github.IssueComment.IssueComment(self._requester, data, completed=True)
return github.IssueComment.IssueComment(self._requester, headers, data, completed=True)
def get_comments(self):
"""
@@ -334,9 +352,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
assert isinstance(label, github.Label.Label), label
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url + "/labels/" + label._identity,
None,
None
self.url + "/labels/" + label._identity
)
def set_labels(self, *labels):
@@ -350,8 +366,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PUT",
self.url + "/labels",
None,
post_parameters
input=post_parameters
)
@property
@@ -364,10 +379,13 @@ class Issue(github.GithubObject.CompletableGithubObject):
self._closed_at = github.GithubObject.NotSet
self._closed_by = github.GithubObject.NotSet
self._comments = github.GithubObject.NotSet
self._comments_url = github.GithubObject.NotSet
self._created_at = github.GithubObject.NotSet
self._events_url = github.GithubObject.NotSet
self._html_url = github.GithubObject.NotSet
self._id = github.GithubObject.NotSet
self._labels = github.GithubObject.NotSet
self._labels_url = github.GithubObject.NotSet
self._milestone = github.GithubObject.NotSet
self._number = github.GithubObject.NotSet
self._pull_request = github.GithubObject.NotSet
@@ -381,7 +399,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
def _useAttributes(self, attributes):
if "assignee" in attributes: # pragma no branch
assert attributes["assignee"] is None or isinstance(attributes["assignee"], dict), attributes["assignee"]
self._assignee = None if attributes["assignee"] is None else github.NamedUser.NamedUser(self._requester, attributes["assignee"], completed=False)
self._assignee = None if attributes["assignee"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["assignee"], completed=False)
if "body" in attributes: # pragma no branch
assert attributes["body"] is None or isinstance(attributes["body"], (str, unicode)), attributes["body"]
self._body = attributes["body"]
@@ -390,13 +408,19 @@ class Issue(github.GithubObject.CompletableGithubObject):
self._closed_at = self._parseDatetime(attributes["closed_at"])
if "closed_by" in attributes: # pragma no branch
assert attributes["closed_by"] is None or isinstance(attributes["closed_by"], dict), attributes["closed_by"]
self._closed_by = None if attributes["closed_by"] is None else github.NamedUser.NamedUser(self._requester, attributes["closed_by"], completed=False)
self._closed_by = None if attributes["closed_by"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["closed_by"], completed=False)
if "comments" in attributes: # pragma no branch
assert attributes["comments"] is None or isinstance(attributes["comments"], (int, long)), attributes["comments"]
self._comments = attributes["comments"]
if "comments_url" in attributes: # pragma no branch
assert attributes["comments_url"] is None or isinstance(attributes["comments_url"], (str, unicode)), attributes["comments_url"]
self._comments_url = attributes["comments_url"]
if "created_at" in attributes: # pragma no branch
assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"]
self._created_at = self._parseDatetime(attributes["created_at"])
if "events_url" in attributes: # pragma no branch
assert attributes["events_url"] is None or isinstance(attributes["events_url"], (str, unicode)), attributes["events_url"]
self._events_url = attributes["events_url"]
if "html_url" in attributes: # pragma no branch
assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"]
self._html_url = attributes["html_url"]
@@ -406,21 +430,24 @@ class Issue(github.GithubObject.CompletableGithubObject):
if "labels" in attributes: # pragma no branch
assert attributes["labels"] is None or all(isinstance(element, dict) for element in attributes["labels"]), attributes["labels"]
self._labels = None if attributes["labels"] is None else [
github.Label.Label(self._requester, element, completed=False)
github.Label.Label(self._requester, self._headers, element, completed=False)
for element in attributes["labels"]
]
if "labels_url" in attributes: # pragma no branch
assert attributes["labels_url"] is None or isinstance(attributes["labels_url"], (str, unicode)), attributes["labels_url"]
self._labels_url = attributes["labels_url"]
if "milestone" in attributes: # pragma no branch
assert attributes["milestone"] is None or isinstance(attributes["milestone"], dict), attributes["milestone"]
self._milestone = None if attributes["milestone"] is None else github.Milestone.Milestone(self._requester, attributes["milestone"], completed=False)
self._milestone = None if attributes["milestone"] is None else github.Milestone.Milestone(self._requester, self._headers, attributes["milestone"], completed=False)
if "number" in attributes: # pragma no branch
assert attributes["number"] is None or isinstance(attributes["number"], (int, long)), attributes["number"]
self._number = attributes["number"]
if "pull_request" in attributes: # pragma no branch
assert attributes["pull_request"] is None or isinstance(attributes["pull_request"], dict), attributes["pull_request"]
self._pull_request = None if attributes["pull_request"] is None else github.IssuePullRequest.IssuePullRequest(self._requester, attributes["pull_request"], completed=False)
self._pull_request = None if attributes["pull_request"] is None else github.IssuePullRequest.IssuePullRequest(self._requester, self._headers, attributes["pull_request"], completed=False)
if "repository" in attributes: # pragma no branch
assert attributes["repository"] is None or isinstance(attributes["repository"], dict), attributes["repository"]
self._repository = None if attributes["repository"] is None else github.Repository.Repository(self._requester, attributes["repository"], completed=False)
self._repository = None if attributes["repository"] is None else github.Repository.Repository(self._requester, self._headers, attributes["repository"], completed=False)
if "state" in attributes: # pragma no branch
assert attributes["state"] is None or isinstance(attributes["state"], (str, unicode)), attributes["state"]
self._state = attributes["state"]
@@ -435,4 +462,4 @@ class Issue(github.GithubObject.CompletableGithubObject):
self._url = attributes["url"]
if "user" in attributes: # pragma no branch
assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"]
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)
+16 -6
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Michael Stead <michael.stead@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
@@ -58,6 +59,14 @@ class IssueComment(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def issue_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._issue_url)
return self._NoneIfNotSet(self._issue_url)
@property
def updated_at(self):
"""
@@ -97,9 +106,7 @@ class IssueComment(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def edit(self, body):
@@ -115,8 +122,7 @@ class IssueComment(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -124,6 +130,7 @@ class IssueComment(github.GithubObject.CompletableGithubObject):
self._body = github.GithubObject.NotSet
self._created_at = github.GithubObject.NotSet
self._id = github.GithubObject.NotSet
self._issue_url = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
self._html_url = github.GithubObject.NotSet
@@ -139,6 +146,9 @@ class IssueComment(github.GithubObject.CompletableGithubObject):
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"]
self._id = attributes["id"]
if "issue_url" in attributes: # pragma no branch
assert attributes["issue_url"] is None or isinstance(attributes["issue_url"], (str, unicode)), attributes["issue_url"]
self._issue_url = attributes["issue_url"]
if "updated_at" in attributes: # pragma no branch
assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"]
self._updated_at = self._parseDatetime(attributes["updated_at"])
@@ -150,4 +160,4 @@ class IssueComment(github.GithubObject.CompletableGithubObject):
self._html_url = attributes["html_url"]
if "user" in attributes: # pragma no branch
assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"]
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)
+3 -2
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -102,7 +103,7 @@ class IssueEvent(github.GithubObject.CompletableGithubObject):
def _useAttributes(self, attributes):
if "actor" in attributes: # pragma no branch
assert attributes["actor"] is None or isinstance(attributes["actor"], dict), attributes["actor"]
self._actor = None if attributes["actor"] is None else github.NamedUser.NamedUser(self._requester, attributes["actor"], completed=False)
self._actor = None if attributes["actor"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["actor"], completed=False)
if "commit_id" in attributes: # pragma no branch
assert attributes["commit_id"] is None or isinstance(attributes["commit_id"], (str, unicode)), attributes["commit_id"]
self._commit_id = attributes["commit_id"]
@@ -117,7 +118,7 @@ class IssueEvent(github.GithubObject.CompletableGithubObject):
self._id = attributes["id"]
if "issue" in attributes: # pragma no branch
assert attributes["issue"] is None or isinstance(attributes["issue"], dict), attributes["issue"]
self._issue = None if attributes["issue"] is None else github.Issue.Issue(self._requester, attributes["issue"], completed=False)
self._issue = None if attributes["issue"] is None else github.Issue.Issue(self._requester, self._headers, attributes["issue"], completed=False)
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+3 -5
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
# #
@@ -65,9 +66,7 @@ class Label(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def edit(self, name, color):
@@ -86,8 +85,7 @@ class Label(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
+4 -3
View File
@@ -5,6 +5,7 @@
# Copyright 2012 Steve English <steve.english@navetas.com> #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -57,12 +58,12 @@ class PaginatedList(github.PaginatedList.PaginatedListBase):
headers, data = self.__requester.requestJsonAndCheck(
"GET",
self.__url,
args,
None
parameters=args
)
self.__continue = len(data[self.__key]) > 0
return [
self.__contentClass(self.__requester, self.__convert(element), completed=False)
self.__contentClass(self.__requester, headers, self.__convert(element), completed=False)
for element in data[self.__key]
]
+127 -51
View File
@@ -2,6 +2,7 @@
############################ Copyrights and license ############################
# #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Ed Jackson <ed.jackson@gmail.com> #
# Copyright 2013 Jonathan J Hunt <hunt@braincorporation.com> #
# Copyright 2013 Peter Golm <golm.peter@gmail.com> #
@@ -25,6 +26,7 @@
################################################################################
import urllib
import pickle
from Requester import Requester
import AuthenticatedUser
@@ -37,7 +39,9 @@ import Legacy
import github.GithubObject
import HookDescription
import GitignoreTemplate
import Notification
import Status
import StatusMessage
import RateLimit
DEFAULT_BASE_URL = "https://api.github.com"
@@ -91,8 +95,12 @@ class Github(object):
def __set_per_page(self, value):
self.__requester.per_page = value
# v2: Remove this property? Why should it be necessary to read/modify it after construction
per_page = property(__get_per_page, __set_per_page)
# v2: Provide a unified way to access values of headers of last response
# v2: (and add/keep ad hoc properties for specific useful headers like rate limiting, oauth scopes, etc.)
# v2: Return an instance of a class: using a tuple did not allow to add a field "resettime"
@property
def rate_limiting(self):
"""
@@ -101,12 +109,7 @@ class Github(object):
"""
remaining, limit = self.__requester.rate_limiting
if limit < 0:
self.__requester.requestJsonAndCheck(
'GET',
'/rate_limit',
None,
None
)
self.get_rate_limit()
return self.__requester.rate_limiting
@property
@@ -116,14 +119,22 @@ class Github(object):
:type: int
"""
if self.__requester.rate_limiting_resettime == 0:
self.__requester.requestJsonAndCheck(
'GET',
'/rate_limit',
None,
None
)
self.get_rate_limit()
return self.__requester.rate_limiting_resettime
def get_rate_limit(self):
"""
Don't forget you can access the rate limit returned in headers of last Github API v3 response, by :attr:`github.MainClass.Github.rate_limiting` and :attr:`github.MainClass.Github.rate_limiting_resettime`.
:calls: `GET /rate_limit <http://developer.github.com/v3/rate_limit>`_
:rtype: :class:`github.RateLimit.RateLimit`
"""
headers, attributes = self.__requester.requestJsonAndCheck(
'GET',
'/rate_limit'
)
return RateLimit.RateLimit(self.__requester, headers, attributes, True)
@property
def oauth_scopes(self):
"""
@@ -139,15 +150,13 @@ class Github(object):
"""
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)
return AuthenticatedUser.AuthenticatedUser(self.__requester, {}, {"url": "/user"}, completed=False)
else:
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/users/" + login,
None,
None
"/users/" + login
)
return github.NamedUser.NamedUser(self.__requester, data, completed=True)
return github.NamedUser.NamedUser(self.__requester, headers, data, completed=True)
def get_users(self, since=github.GithubObject.NotSet):
"""
@@ -175,11 +184,9 @@ class Github(object):
assert isinstance(login, (str, unicode)), login
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/orgs/" + login,
None,
None
"/orgs/" + login
)
return github.Organization.Organization(self.__requester, data, completed=True)
return github.Organization.Organization(self.__requester, headers, data, completed=True)
def get_repo(self, full_name):
"""
@@ -189,11 +196,26 @@ class Github(object):
assert isinstance(full_name, (str, unicode)), full_name
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/repos/" + full_name,
None,
None
"/repos/" + full_name
)
return Repository.Repository(self.__requester, headers, data, completed=True)
def get_repos(self, since=github.GithubObject.NotSet):
"""
:calls: `GET /repositories <http://developer.github.com/v3/repos/#list-all-public-repositories>`_
:param since: integer
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
"""
assert since is github.GithubObject.NotSet or isinstance(since, (int, long)), since
url_parameters = dict()
if since is not github.GithubObject.NotSet:
url_parameters["since"] = since
return github.PaginatedList.PaginatedList(
github.Repository.Repository,
self.__requester,
"/repositories",
url_parameters
)
return Repository.Repository(self.__requester, data, completed=True)
def get_gist(self, id):
"""
@@ -204,11 +226,9 @@ class Github(object):
assert isinstance(id, (str, unicode)), id
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/gists/" + id,
None,
None
"/gists/" + id
)
return github.Gist.Gist(self.__requester, data, completed=True)
return github.Gist.Gist(self.__requester, headers, data, completed=True)
def get_gists(self):
"""
@@ -266,11 +286,9 @@ class Github(object):
assert isinstance(email, (str, unicode)), email
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/legacy/user/email/" + email,
None,
None
"/legacy/user/email/" + email
)
return github.NamedUser.NamedUser(self.__requester, Legacy.convertUser(data["user"]), completed=False)
return github.NamedUser.NamedUser(self.__requester, headers, Legacy.convertUser(data["user"]), completed=False)
def render_markdown(self, text, context=github.GithubObject.NotSet):
"""
@@ -290,23 +308,20 @@ class Github(object):
status, headers, data = self.__requester.requestJson(
"POST",
"/markdown",
None,
post_parameters
input=post_parameters
)
return data
def get_hooks(self):
"""
:calls: `GET /hooks <http://developer.github.com/>`_
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.HookDescription.HookDescription`
:rtype: list of :class:`github.HookDescription.HookDescription`
"""
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/hooks",
None,
None
"/hooks"
)
return [HookDescription.HookDescription(self.__requester, attributes, completed=True) for attributes in data]
return [HookDescription.HookDescription(self.__requester, headers, attributes, completed=True) for attributes in data]
def get_gitignore_templates(self):
"""
@@ -315,9 +330,7 @@ class Github(object):
"""
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/gitignore/templates",
None,
None
"/gitignore/templates"
)
return data
@@ -329,18 +342,81 @@ class Github(object):
assert isinstance(name, (str, unicode)), name
headers, attributes = self.__requester.requestJsonAndCheck(
"GET",
"/gitignore/templates/" + name,
None,
None
"/gitignore/templates/" + name
)
return GitignoreTemplate.GitignoreTemplate(self.__requester, attributes, completed=True)
return GitignoreTemplate.GitignoreTemplate(self.__requester, headers, attributes, completed=True)
def create_from_raw_data(self, klass, raw_data):
def create_from_raw_data(self, klass, raw_data, headers={}):
"""
Creates an object from raw_data previously obtained by :attr:`github.GithubObject.GithubObject.raw_data`
Creates an object from raw_data previously obtained by :attr:`github.GithubObject.GithubObject.raw_data`,
and optionaly headers previously obtained by :attr:`github.GithubObject.GithubObject.raw_headers`.
:param klass: the class of the object to create
:param raw_data: dict
:param headers: dict
:rtype: instance of class ``klass``
"""
return klass(self.__requester, raw_data, completed=True)
return klass(self.__requester, headers, raw_data, completed=True)
def dump(self, obj, file, protocol=0):
"""
Dumps (pickles) a PyGithub object to a file-like object.
Some effort is made to not pickle sensitive informations like the Github credentials used in the :class:`Github` instance.
But NO EFFORT is made to remove sensitive information from the object's attributes.
:param obj: the object to pickle
:param file: the file-like object to pickle to
:param protocol: the `pickling protocol <http://docs.python.org/2.7/library/pickle.html#data-stream-format>`_
"""
pickle.dump((obj.__class__, obj.raw_data, obj.raw_headers), file, protocol)
def load(self, f):
"""
Loads (unpickles) a PyGithub object from a file-like object.
:param f: the file-like object to unpickle from
:return: the unpickled object
"""
return self.create_from_raw_data(*pickle.load(f))
def get_api_status(self):
"""
This doesn't work with a Github Enterprise installation, because it always targets https://status.github.com.
:calls: `GET /api/status.json <https://status.github.com/api>`_
:rtype: :class:`github.Status.Status`
"""
headers, attributes = self.__requester.requestJsonAndCheck(
"GET",
"/api/status.json",
cnx="status"
)
return Status.Status(self.__requester, headers, attributes, completed=True)
def get_last_api_status_message(self):
"""
This doesn't work with a Github Enterprise installation, because it always targets https://status.github.com.
:calls: `GET /api/last-message.json <https://status.github.com/api>`_
:rtype: :class:`github.StatusMessage.StatusMessage`
"""
headers, attributes = self.__requester.requestJsonAndCheck(
"GET",
"/api/last-message.json",
cnx="status"
)
return StatusMessage.StatusMessage(self.__requester, headers, attributes, completed=True)
def get_api_status_messages(self):
"""
This doesn't work with a Github Enterprise installation, because it always targets https://status.github.com.
:calls: `GET /api/messages.json <https://status.github.com/api>`_
:rtype: list of :class:`github.StatusMessage.StatusMessage`
"""
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/api/messages.json",
cnx="status"
)
return [StatusMessage.StatusMessage(self.__requester, headers, attributes, completed=True) for attributes in data]
+28 -6
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
# #
@@ -86,6 +87,14 @@ class Milestone(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def labels_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._labels_url)
return self._NoneIfNotSet(self._labels_url)
@property
def number(self):
"""
@@ -118,6 +127,14 @@ class Milestone(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._title)
return self._NoneIfNotSet(self._title)
@property
def updated_at(self):
"""
:type: datetime.datetime
"""
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url(self):
"""
@@ -133,9 +150,7 @@ class Milestone(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def edit(self, title, state=github.GithubObject.NotSet, description=github.GithubObject.NotSet, due_on=github.GithubObject.NotSet):
@@ -163,8 +178,7 @@ class Milestone(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -191,10 +205,12 @@ class Milestone(github.GithubObject.CompletableGithubObject):
self._description = github.GithubObject.NotSet
self._due_on = github.GithubObject.NotSet
self._id = github.GithubObject.NotSet
self._labels_url = github.GithubObject.NotSet
self._number = github.GithubObject.NotSet
self._open_issues = github.GithubObject.NotSet
self._state = github.GithubObject.NotSet
self._title = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
def _useAttributes(self, attributes):
@@ -206,7 +222,7 @@ class Milestone(github.GithubObject.CompletableGithubObject):
self._created_at = self._parseDatetime(attributes["created_at"])
if "creator" in attributes: # pragma no branch
assert attributes["creator"] is None or isinstance(attributes["creator"], dict), attributes["creator"]
self._creator = None if attributes["creator"] is None else github.NamedUser.NamedUser(self._requester, attributes["creator"], completed=False)
self._creator = None if attributes["creator"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["creator"], completed=False)
if "description" in attributes: # pragma no branch
assert attributes["description"] is None or isinstance(attributes["description"], (str, unicode)), attributes["description"]
self._description = attributes["description"]
@@ -216,6 +232,9 @@ class Milestone(github.GithubObject.CompletableGithubObject):
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"]
self._id = attributes["id"]
if "labels_url" in attributes: # pragma no branch
assert attributes["labels_url"] is None or isinstance(attributes["labels_url"], (str, unicode)), attributes["labels_url"]
self._labels_url = attributes["labels_url"]
if "number" in attributes: # pragma no branch
assert attributes["number"] is None or isinstance(attributes["number"], (int, long)), attributes["number"]
self._number = attributes["number"]
@@ -228,6 +247,9 @@ class Milestone(github.GithubObject.CompletableGithubObject):
if "title" in attributes: # pragma no branch
assert attributes["title"] is None or isinstance(attributes["title"], (str, unicode)), attributes["title"]
self._title = attributes["title"]
if "updated_at" in attributes: # pragma no branch
assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"]
self._updated_at = self._parseDatetime(attributes["updated_at"])
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+140 -8
View File
@@ -5,6 +5,7 @@
# Copyright 2012 Steve English <steve.english@navetas.com> #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -112,6 +113,14 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._email)
return self._NoneIfNotSet(self._email)
@property
def events_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._events_url)
return self._NoneIfNotSet(self._events_url)
@property
def followers(self):
"""
@@ -120,6 +129,14 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._followers)
return self._NoneIfNotSet(self._followers)
@property
def followers_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._followers_url)
return self._NoneIfNotSet(self._followers_url)
@property
def following(self):
"""
@@ -128,6 +145,22 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._following)
return self._NoneIfNotSet(self._following)
@property
def following_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._following_url)
return self._NoneIfNotSet(self._following_url)
@property
def gists_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._gists_url)
return self._NoneIfNotSet(self._gists_url)
@property
def gravatar_id(self):
"""
@@ -184,6 +217,14 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._name)
return self._NoneIfNotSet(self._name)
@property
def organizations_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._organizations_url)
return self._NoneIfNotSet(self._organizations_url)
@property
def owned_private_repos(self):
"""
@@ -224,6 +265,38 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._public_repos)
return self._NoneIfNotSet(self._public_repos)
@property
def received_events_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._received_events_url)
return self._NoneIfNotSet(self._received_events_url)
@property
def repos_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._repos_url)
return self._NoneIfNotSet(self._repos_url)
@property
def starred_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._starred_url)
return self._NoneIfNotSet(self._starred_url)
@property
def subscriptions_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._subscriptions_url)
return self._NoneIfNotSet(self._subscriptions_url)
@property
def total_private_repos(self):
"""
@@ -240,6 +313,14 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._type)
return self._NoneIfNotSet(self._type)
@property
def updated_at(self):
"""
:type: datetime.datetime
"""
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url(self):
"""
@@ -248,6 +329,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
# v2: Remove this method
def create_gist(self, public, files, description=github.GithubObject.NotSet):
"""
:calls: `POST /users/:user/gists <http://developer.github.com/v3/todo>`_
@@ -268,10 +350,9 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.url + "/gists",
None,
post_parameters
input=post_parameters
)
return github.Gist.Gist(self._requester, data, completed=True)
return github.Gist.Gist(self._requester, headers, data, completed=True)
def get_events(self):
"""
@@ -390,11 +471,9 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
assert isinstance(name, (str, unicode)), name
headers, data = self._requester.requestJsonAndCheck(
"GET",
"/repos/" + self.login + "/" + name,
None,
None
"/repos/" + self.login + "/" + name
)
return github.Repository.Repository(self._requester, data, completed=True)
return github.Repository.Repository(self._requester, headers, data, completed=True)
def get_repos(self, type=github.GithubObject.NotSet):
"""
@@ -449,6 +528,19 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
None
)
def has_in_following(self, following):
"""
:calls: `GET /users/:user/following/:target_user <http://developer.github.com/v3/users/followers/#check-if-one-user-follows-another>`_
:param following: :class:`github.NamedUser.NamedUser`
:rtype: bool
"""
assert isinstance(following, github.NamedUser.NamedUser), following
status, headers, data = self._requester.requestJson(
"GET",
self.url + "/following/" + following._identity
)
return status == 204
@property
def _identity(self):
return self.login
@@ -463,8 +555,12 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
self._created_at = github.GithubObject.NotSet
self._disk_usage = github.GithubObject.NotSet
self._email = github.GithubObject.NotSet
self._events_url = github.GithubObject.NotSet
self._followers = github.GithubObject.NotSet
self._followers_url = github.GithubObject.NotSet
self._following = github.GithubObject.NotSet
self._following_url = github.GithubObject.NotSet
self._gists_url = github.GithubObject.NotSet
self._gravatar_id = github.GithubObject.NotSet
self._hireable = github.GithubObject.NotSet
self._html_url = github.GithubObject.NotSet
@@ -472,13 +568,19 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
self._location = github.GithubObject.NotSet
self._login = github.GithubObject.NotSet
self._name = github.GithubObject.NotSet
self._organizations_url = github.GithubObject.NotSet
self._owned_private_repos = github.GithubObject.NotSet
self._plan = github.GithubObject.NotSet
self._private_gists = github.GithubObject.NotSet
self._public_gists = github.GithubObject.NotSet
self._public_repos = github.GithubObject.NotSet
self._received_events_url = github.GithubObject.NotSet
self._repos_url = github.GithubObject.NotSet
self._starred_url = github.GithubObject.NotSet
self._subscriptions_url = github.GithubObject.NotSet
self._total_private_repos = github.GithubObject.NotSet
self._type = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
def _useAttributes(self, attributes):
@@ -509,12 +611,24 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
if "email" in attributes: # pragma no branch
assert attributes["email"] is None or isinstance(attributes["email"], (str, unicode)), attributes["email"]
self._email = attributes["email"]
if "events_url" in attributes: # pragma no branch
assert attributes["events_url"] is None or isinstance(attributes["events_url"], (str, unicode)), attributes["events_url"]
self._events_url = attributes["events_url"]
if "followers" in attributes: # pragma no branch
assert attributes["followers"] is None or isinstance(attributes["followers"], (int, long)), attributes["followers"]
self._followers = attributes["followers"]
if "followers_url" in attributes: # pragma no branch
assert attributes["followers_url"] is None or isinstance(attributes["followers_url"], (str, unicode)), attributes["followers_url"]
self._followers_url = attributes["followers_url"]
if "following" in attributes: # pragma no branch
assert attributes["following"] is None or isinstance(attributes["following"], (int, long)), attributes["following"]
self._following = attributes["following"]
if "following_url" in attributes: # pragma no branch
assert attributes["following_url"] is None or isinstance(attributes["following_url"], (str, unicode)), attributes["following_url"]
self._following_url = attributes["following_url"]
if "gists_url" in attributes: # pragma no branch
assert attributes["gists_url"] is None or isinstance(attributes["gists_url"], (str, unicode)), attributes["gists_url"]
self._gists_url = attributes["gists_url"]
if "gravatar_id" in attributes: # pragma no branch
assert attributes["gravatar_id"] is None or isinstance(attributes["gravatar_id"], (str, unicode)), attributes["gravatar_id"]
self._gravatar_id = attributes["gravatar_id"]
@@ -536,12 +650,15 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
if "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
if "organizations_url" in attributes: # pragma no branch
assert attributes["organizations_url"] is None or isinstance(attributes["organizations_url"], (str, unicode)), attributes["organizations_url"]
self._organizations_url = attributes["organizations_url"]
if "owned_private_repos" in attributes: # pragma no branch
assert attributes["owned_private_repos"] is None or isinstance(attributes["owned_private_repos"], (int, long)), attributes["owned_private_repos"]
self._owned_private_repos = attributes["owned_private_repos"]
if "plan" in attributes: # pragma no branch
assert attributes["plan"] is None or isinstance(attributes["plan"], dict), attributes["plan"]
self._plan = None if attributes["plan"] is None else github.Plan.Plan(self._requester, attributes["plan"], completed=False)
self._plan = None if attributes["plan"] is None else github.Plan.Plan(self._requester, self._headers, attributes["plan"], completed=False)
if "private_gists" in attributes: # pragma no branch
assert attributes["private_gists"] is None or isinstance(attributes["private_gists"], (int, long)), attributes["private_gists"]
self._private_gists = attributes["private_gists"]
@@ -551,12 +668,27 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
if "public_repos" in attributes: # pragma no branch
assert attributes["public_repos"] is None or isinstance(attributes["public_repos"], (int, long)), attributes["public_repos"]
self._public_repos = attributes["public_repos"]
if "received_events_url" in attributes: # pragma no branch
assert attributes["received_events_url"] is None or isinstance(attributes["received_events_url"], (str, unicode)), attributes["received_events_url"]
self._received_events_url = attributes["received_events_url"]
if "repos_url" in attributes: # pragma no branch
assert attributes["repos_url"] is None or isinstance(attributes["repos_url"], (str, unicode)), attributes["repos_url"]
self._repos_url = attributes["repos_url"]
if "starred_url" in attributes: # pragma no branch
assert attributes["starred_url"] is None or isinstance(attributes["starred_url"], (str, unicode)), attributes["starred_url"]
self._starred_url = attributes["starred_url"]
if "subscriptions_url" in attributes: # pragma no branch
assert attributes["subscriptions_url"] is None or isinstance(attributes["subscriptions_url"], (str, unicode)), attributes["subscriptions_url"]
self._subscriptions_url = attributes["subscriptions_url"]
if "total_private_repos" in attributes: # pragma no branch
assert attributes["total_private_repos"] is None or isinstance(attributes["total_private_repos"], (int, long)), attributes["total_private_repos"]
self._total_private_repos = attributes["total_private_repos"]
if "type" in attributes: # pragma no branch
assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"]
self._type = attributes["type"]
if "updated_at" in attributes: # pragma no branch
assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"]
self._updated_at = self._parseDatetime(attributes["updated_at"])
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+27 -2
View File
@@ -2,6 +2,7 @@
############################ Copyrights and license ############################
# #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Peter Golm <golm.peter@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
@@ -42,6 +43,14 @@ class Notification(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def last_read_at(self):
"""
:type: datetime.datetime
"""
self._completeIfNotSet(self._last_read_at)
return self._NoneIfNotSet(self._last_read_at)
@property
def repository(self):
"""
@@ -66,6 +75,14 @@ class Notification(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._reason)
return self._NoneIfNotSet(self._reason)
@property
def subscription_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._subscription_url)
return self._NoneIfNotSet(self._subscription_url)
@property
def unread(self):
"""
@@ -92,8 +109,10 @@ class Notification(github.GithubObject.CompletableGithubObject):
def _initAttributes(self):
self._id = github.GithubObject.NotSet
self._last_read_at = github.GithubObject.NotSet
self._repository = github.GithubObject.NotSet
self._reason = github.GithubObject.NotSet
self._subscription_url = github.GithubObject.NotSet
self._unread = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
@@ -102,15 +121,21 @@ class Notification(github.GithubObject.CompletableGithubObject):
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], (str, unicode)), attributes["id"]
self._id = attributes["id"]
if "last_read_at" in attributes: # pragma no branch
assert attributes["last_read_at"] is None or isinstance(attributes["last_read_at"], (str, unicode)), attributes["last_read_at"]
self._last_read_at = self._parseDatetime(attributes["last_read_at"])
if "repository" in attributes: # pragma no branch
assert attributes["repository"] is None or isinstance(attributes["repository"], dict), attributes["repository"]
self._repository = None if attributes["repository"] is None else github.Repository.Repository(self._requester, attributes["repository"], completed=False)
self._repository = None if attributes["repository"] is None else github.Repository.Repository(self._requester, self._headers, attributes["repository"], completed=False)
if "subject" in attributes: # pragma no branch
assert attributes["subject"] is None or isinstance(attributes["subject"], dict), attributes["subject"]
self._subject = None if attributes["subject"] is None else github.NotificationSubject.NotificationSubject(self._requester, attributes["subject"], completed=False)
self._subject = None if attributes["subject"] is None else github.NotificationSubject.NotificationSubject(self._requester, self._headers, attributes["subject"], completed=False)
if "reason" in attributes: # pragma no branch
assert attributes["reason"] is None or isinstance(attributes["reason"], (str, unicode)), attributes["reason"]
self._reason = attributes["reason"]
if "subscription_url" in attributes: # pragma no branch
assert attributes["subscription_url"] is None or isinstance(attributes["subscription_url"], (str, unicode)), attributes["subscription_url"]
self._subscription_url = attributes["subscription_url"]
if "unread" in attributes: # pragma no branch
assert attributes["unread"] is None or isinstance(attributes["unread"], bool), attributes["unread"]
self._unread = attributes["unread"]
+1
View File
@@ -2,6 +2,7 @@
############################ Copyrights and license ############################
# #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+78 -35
View File
@@ -5,6 +5,7 @@
# Copyright 2012 Steve English <steve.english@navetas.com> #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
# #
@@ -106,6 +107,14 @@ class Organization(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._email)
return self._NoneIfNotSet(self._email)
@property
def events_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._events_url)
return self._NoneIfNotSet(self._events_url)
@property
def followers(self):
"""
@@ -162,6 +171,14 @@ class Organization(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._login)
return self._NoneIfNotSet(self._login)
@property
def members_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._members_url)
return self._NoneIfNotSet(self._members_url)
@property
def name(self):
"""
@@ -202,6 +219,14 @@ class Organization(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._public_gists)
return self._NoneIfNotSet(self._public_gists)
@property
def public_members_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._public_members_url)
return self._NoneIfNotSet(self._public_members_url)
@property
def public_repos(self):
"""
@@ -210,6 +235,14 @@ class Organization(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._public_repos)
return self._NoneIfNotSet(self._public_repos)
@property
def repos_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._repos_url)
return self._NoneIfNotSet(self._repos_url)
@property
def total_private_repos(self):
"""
@@ -226,6 +259,14 @@ class Organization(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._type)
return self._NoneIfNotSet(self._type)
@property
def updated_at(self):
"""
:type: datetime.datetime
"""
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url(self):
"""
@@ -243,9 +284,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
assert isinstance(public_member, github.NamedUser.NamedUser), public_member
headers, data = self._requester.requestJsonAndCheck(
"PUT",
self.url + "/public_members/" + public_member._identity,
None,
None
self.url + "/public_members/" + public_member._identity
)
def create_fork(self, repo):
@@ -261,10 +300,9 @@ class Organization(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
"/repos/" + repo.owner.login + "/" + repo.name + "/forks",
url_parameters,
None
parameters=url_parameters
)
return github.Repository.Repository(self._requester, data, completed=True)
return github.Repository.Repository(self._requester, headers, data, completed=True)
def create_repo(self, name, description=github.GithubObject.NotSet, homepage=github.GithubObject.NotSet, private=github.GithubObject.NotSet, has_issues=github.GithubObject.NotSet, has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet, team_id=github.GithubObject.NotSet, auto_init=github.GithubObject.NotSet, gitignore_template=github.GithubObject.NotSet):
"""
@@ -315,10 +353,9 @@ class Organization(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.url + "/repos",
None,
post_parameters
input=post_parameters
)
return github.Repository.Repository(self._requester, data, completed=True)
return github.Repository.Repository(self._requester, headers, data, completed=True)
def create_team(self, name, repo_names=github.GithubObject.NotSet, permission=github.GithubObject.NotSet):
"""
@@ -341,10 +378,9 @@ class Organization(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.url + "/teams",
None,
post_parameters
input=post_parameters
)
return github.Team.Team(self._requester, data, completed=True)
return github.Team.Team(self._requester, headers, data, completed=True)
def edit(self, billing_email=github.GithubObject.NotSet, blog=github.GithubObject.NotSet, company=github.GithubObject.NotSet, email=github.GithubObject.NotSet, location=github.GithubObject.NotSet, name=github.GithubObject.NotSet):
"""
@@ -379,8 +415,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -467,11 +502,9 @@ class Organization(github.GithubObject.CompletableGithubObject):
assert isinstance(name, (str, unicode)), name
headers, data = self._requester.requestJsonAndCheck(
"GET",
"/repos/" + self.login + "/" + name,
None,
None
"/repos/" + self.login + "/" + name
)
return github.Repository.Repository(self._requester, data, completed=True)
return github.Repository.Repository(self._requester, headers, data, completed=True)
def get_repos(self, type=github.GithubObject.NotSet):
"""
@@ -499,11 +532,9 @@ class Organization(github.GithubObject.CompletableGithubObject):
assert isinstance(id, (int, long)), id
headers, data = self._requester.requestJsonAndCheck(
"GET",
"/teams/" + str(id),
None,
None
"/teams/" + str(id)
)
return github.Team.Team(self._requester, data, completed=True)
return github.Team.Team(self._requester, headers, data, completed=True)
def get_teams(self):
"""
@@ -526,9 +557,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
assert isinstance(member, github.NamedUser.NamedUser), member
status, headers, data = self._requester.requestJson(
"GET",
self.url + "/members/" + member._identity,
None,
None
self.url + "/members/" + member._identity
)
return status == 204
@@ -541,9 +570,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
assert isinstance(public_member, github.NamedUser.NamedUser), public_member
status, headers, data = self._requester.requestJson(
"GET",
self.url + "/public_members/" + public_member._identity,
None,
None
self.url + "/public_members/" + public_member._identity
)
return status == 204
@@ -556,9 +583,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
assert isinstance(member, github.NamedUser.NamedUser), member
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url + "/members/" + member._identity,
None,
None
self.url + "/members/" + member._identity
)
def remove_from_public_members(self, public_member):
@@ -570,9 +595,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
assert isinstance(public_member, github.NamedUser.NamedUser), public_member
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url + "/public_members/" + public_member._identity,
None,
None
self.url + "/public_members/" + public_member._identity
)
def _initAttributes(self):
@@ -584,6 +607,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
self._created_at = github.GithubObject.NotSet
self._disk_usage = github.GithubObject.NotSet
self._email = github.GithubObject.NotSet
self._events_url = github.GithubObject.NotSet
self._followers = github.GithubObject.NotSet
self._following = github.GithubObject.NotSet
self._gravatar_id = github.GithubObject.NotSet
@@ -591,14 +615,18 @@ class Organization(github.GithubObject.CompletableGithubObject):
self._id = github.GithubObject.NotSet
self._location = github.GithubObject.NotSet
self._login = github.GithubObject.NotSet
self._members_url = github.GithubObject.NotSet
self._name = github.GithubObject.NotSet
self._owned_private_repos = github.GithubObject.NotSet
self._plan = github.GithubObject.NotSet
self._private_gists = github.GithubObject.NotSet
self._public_gists = github.GithubObject.NotSet
self._public_members_url = github.GithubObject.NotSet
self._public_repos = github.GithubObject.NotSet
self._repos_url = github.GithubObject.NotSet
self._total_private_repos = github.GithubObject.NotSet
self._type = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
def _useAttributes(self, attributes):
@@ -626,6 +654,9 @@ class Organization(github.GithubObject.CompletableGithubObject):
if "email" in attributes: # pragma no branch
assert attributes["email"] is None or isinstance(attributes["email"], (str, unicode)), attributes["email"]
self._email = attributes["email"]
if "events_url" in attributes: # pragma no branch
assert attributes["events_url"] is None or isinstance(attributes["events_url"], (str, unicode)), attributes["events_url"]
self._events_url = attributes["events_url"]
if "followers" in attributes: # pragma no branch
assert attributes["followers"] is None or isinstance(attributes["followers"], (int, long)), attributes["followers"]
self._followers = attributes["followers"]
@@ -647,6 +678,9 @@ class Organization(github.GithubObject.CompletableGithubObject):
if "login" in attributes: # pragma no branch
assert attributes["login"] is None or isinstance(attributes["login"], (str, unicode)), attributes["login"]
self._login = attributes["login"]
if "members_url" in attributes: # pragma no branch
assert attributes["members_url"] is None or isinstance(attributes["members_url"], (str, unicode)), attributes["members_url"]
self._members_url = attributes["members_url"]
if "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
@@ -655,22 +689,31 @@ class Organization(github.GithubObject.CompletableGithubObject):
self._owned_private_repos = attributes["owned_private_repos"]
if "plan" in attributes: # pragma no branch
assert attributes["plan"] is None or isinstance(attributes["plan"], dict), attributes["plan"]
self._plan = None if attributes["plan"] is None else github.Plan.Plan(self._requester, attributes["plan"], completed=False)
self._plan = None if attributes["plan"] is None else github.Plan.Plan(self._requester, self._headers, attributes["plan"], completed=False)
if "private_gists" in attributes: # pragma no branch
assert attributes["private_gists"] is None or isinstance(attributes["private_gists"], (int, long)), attributes["private_gists"]
self._private_gists = attributes["private_gists"]
if "public_gists" in attributes: # pragma no branch
assert attributes["public_gists"] is None or isinstance(attributes["public_gists"], (int, long)), attributes["public_gists"]
self._public_gists = attributes["public_gists"]
if "public_members_url" in attributes: # pragma no branch
assert attributes["public_members_url"] is None or isinstance(attributes["public_members_url"], (str, unicode)), attributes["public_members_url"]
self._public_members_url = attributes["public_members_url"]
if "public_repos" in attributes: # pragma no branch
assert attributes["public_repos"] is None or isinstance(attributes["public_repos"], (int, long)), attributes["public_repos"]
self._public_repos = attributes["public_repos"]
if "repos_url" in attributes: # pragma no branch
assert attributes["repos_url"] is None or isinstance(attributes["repos_url"], (str, unicode)), attributes["repos_url"]
self._repos_url = attributes["repos_url"]
if "total_private_repos" in attributes: # pragma no branch
assert attributes["total_private_repos"] is None or isinstance(attributes["total_private_repos"], (int, long)), attributes["total_private_repos"]
self._total_private_repos = attributes["total_private_repos"]
if "type" in attributes: # pragma no branch
assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"]
self._type = attributes["type"]
if "updated_at" in attributes: # pragma no branch
assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"]
self._updated_at = self._parseDatetime(attributes["updated_at"])
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+18 -5
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Bill Mill <bill.mill@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 davidbrai <davidbrai@gmail.com> #
@@ -118,7 +119,11 @@ class PaginatedList(PaginatedListBase):
self._reversed = False
def _getLastPageUrl(self):
headers, data = self.__requester.requestJsonAndCheck("GET", self.__firstUrl, self.__nextParams, None)
headers, data = self.__requester.requestJsonAndCheck(
"GET",
self.__firstUrl,
parameters=self.__nextParams
)
links = self.__parseLinkHeader(headers)
lastUrl = links.get("last")
return lastUrl
@@ -139,7 +144,11 @@ class PaginatedList(PaginatedListBase):
return self.__nextUrl is not None
def _fetchNextPage(self):
headers, data = self.__requester.requestJsonAndCheck("GET", self.__nextUrl, self.__nextParams, None)
headers, data = self.__requester.requestJsonAndCheck(
"GET",
self.__nextUrl,
parameters=self.__nextParams
)
self.__nextUrl = None
if len(data) > 0:
@@ -152,7 +161,7 @@ class PaginatedList(PaginatedListBase):
self.__nextParams = None
content = [
self.__contentClass(self.__requester, element, completed=False)
self.__contentClass(self.__requester, headers, element, completed=False)
for element in data
]
if self._reversed:
@@ -176,9 +185,13 @@ class PaginatedList(PaginatedListBase):
params["page"] = page + 1
if self.__requester.per_page != 30:
params["per_page"] = self.__requester.per_page
headers, data = self.__requester.requestJsonAndCheck("GET", self.__firstUrl, params, None)
headers, data = self.__requester.requestJsonAndCheck(
"GET",
self.__firstUrl,
parameters=params
)
return [
self.__contentClass(self.__requester, element, completed=False)
self.__contentClass(self.__requester, headers, element, completed=False)
for element in data
]
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
+102 -27
View File
@@ -5,6 +5,7 @@
# Copyright 2012 Michael Stead <michael.stead@gmail.com> #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
# #
@@ -98,6 +99,14 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._comments)
return self._NoneIfNotSet(self._comments)
@property
def comments_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._comments_url)
return self._NoneIfNotSet(self._comments_url)
@property
def commits(self):
"""
@@ -106,6 +115,14 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._commits)
return self._NoneIfNotSet(self._commits)
@property
def commits_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._commits_url)
return self._NoneIfNotSet(self._commits_url)
@property
def created_at(self):
"""
@@ -162,6 +179,14 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._issue_url)
return self._NoneIfNotSet(self._issue_url)
@property
def merge_commit_sha(self):
"""
:type: string
"""
self._completeIfNotSet(self._merge_commit_sha)
return self._NoneIfNotSet(self._merge_commit_sha)
@property
def mergeable(self):
"""
@@ -170,6 +195,14 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._mergeable)
return self._NoneIfNotSet(self._mergeable)
@property
def mergeable_state(self):
"""
:type: string
"""
self._completeIfNotSet(self._mergeable_state)
return self._NoneIfNotSet(self._mergeable_state)
@property
def merged(self):
"""
@@ -194,6 +227,14 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._merged_by)
return self._NoneIfNotSet(self._merged_by)
@property
def milestone(self):
"""
:type: :class:`github.Milestone.Milestone`
"""
self._completeIfNotSet(self._milestone)
return self._NoneIfNotSet(self._milestone)
@property
def number(self):
"""
@@ -210,6 +251,14 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._patch_url)
return self._NoneIfNotSet(self._patch_url)
@property
def review_comment_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._review_comment_url)
return self._NoneIfNotSet(self._review_comment_url)
@property
def review_comments(self):
"""
@@ -218,6 +267,14 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._review_comments)
return self._NoneIfNotSet(self._review_comments)
@property
def review_comments_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._review_comments_url)
return self._NoneIfNotSet(self._review_comments_url)
@property
def state(self):
"""
@@ -291,10 +348,9 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.url + "/comments",
None,
post_parameters
input=post_parameters
)
return github.PullRequestComment.PullRequestComment(self._requester, data, completed=True)
return github.PullRequestComment.PullRequestComment(self._requester, headers, data, completed=True)
def create_issue_comment(self, body):
"""
@@ -309,10 +365,9 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"POST",
self._parentUrl(self._parentUrl(self.url)) + "/issues/" + str(self.number) + "/comments",
None,
post_parameters
input=post_parameters
)
return github.IssueComment.IssueComment(self._requester, data, completed=True)
return github.IssueComment.IssueComment(self._requester, headers, data, completed=True)
def edit(self, title=github.GithubObject.NotSet, body=github.GithubObject.NotSet, state=github.GithubObject.NotSet):
"""
@@ -335,8 +390,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -357,11 +411,9 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
assert isinstance(id, (int, long)), id
headers, data = self._requester.requestJsonAndCheck(
"GET",
self._parentUrl(self.url) + "/comments/" + str(id),
None,
None
self._parentUrl(self.url) + "/comments/" + str(id)
)
return github.PullRequestComment.PullRequestComment(self._requester, data, completed=True)
return github.PullRequestComment.PullRequestComment(self._requester, headers, data, completed=True)
def get_comments(self):
"""
@@ -415,11 +467,9 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
assert isinstance(id, (int, long)), id
headers, data = self._requester.requestJsonAndCheck(
"GET",
self._parentUrl(self._parentUrl(self.url)) + "/issues/comments/" + str(id),
None,
None
self._parentUrl(self._parentUrl(self.url)) + "/issues/comments/" + str(id)
)
return github.IssueComment.IssueComment(self._requester, data, completed=True)
return github.IssueComment.IssueComment(self._requester, headers, data, completed=True)
def get_issue_comments(self):
"""
@@ -440,9 +490,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
"""
status, headers, data = self._requester.requestJson(
"GET",
self.url + "/merge",
None,
None
self.url + "/merge"
)
return status == 204
@@ -459,10 +507,9 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PUT",
self.url + "/merge",
None,
post_parameters
input=post_parameters
)
return github.PullRequestMergeStatus.PullRequestMergeStatus(self._requester, data, completed=True)
return github.PullRequestMergeStatus.PullRequestMergeStatus(self._requester, headers, data, completed=True)
def _initAttributes(self):
self._additions = github.GithubObject.NotSet
@@ -472,7 +519,9 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._changed_files = github.GithubObject.NotSet
self._closed_at = github.GithubObject.NotSet
self._comments = github.GithubObject.NotSet
self._comments_url = github.GithubObject.NotSet
self._commits = github.GithubObject.NotSet
self._commits_url = github.GithubObject.NotSet
self._created_at = github.GithubObject.NotSet
self._deletions = github.GithubObject.NotSet
self._diff_url = github.GithubObject.NotSet
@@ -480,13 +529,18 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._html_url = github.GithubObject.NotSet
self._id = github.GithubObject.NotSet
self._issue_url = github.GithubObject.NotSet
self._merge_commit_sha = github.GithubObject.NotSet
self._mergeable = github.GithubObject.NotSet
self._mergeable_state = github.GithubObject.NotSet
self._merged = github.GithubObject.NotSet
self._merged_at = github.GithubObject.NotSet
self._merged_by = github.GithubObject.NotSet
self._milestone = github.GithubObject.NotSet
self._number = github.GithubObject.NotSet
self._patch_url = github.GithubObject.NotSet
self._review_comment_url = github.GithubObject.NotSet
self._review_comments = github.GithubObject.NotSet
self._review_comments_url = github.GithubObject.NotSet
self._state = github.GithubObject.NotSet
self._title = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
@@ -499,10 +553,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._additions = attributes["additions"]
if "assignee" in attributes: # pragma no branch
assert attributes["assignee"] is None or isinstance(attributes["assignee"], dict), attributes["assignee"]
self._assignee = None if attributes["assignee"] is None else github.NamedUser.NamedUser(self._requester, attributes["assignee"], completed=False)
self._assignee = None if attributes["assignee"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["assignee"], completed=False)
if "base" in attributes: # pragma no branch
assert attributes["base"] is None or isinstance(attributes["base"], dict), attributes["base"]
self._base = None if attributes["base"] is None else github.PullRequestPart.PullRequestPart(self._requester, attributes["base"], completed=False)
self._base = None if attributes["base"] is None else github.PullRequestPart.PullRequestPart(self._requester, self._headers, attributes["base"], completed=False)
if "body" in attributes: # pragma no branch
assert attributes["body"] is None or isinstance(attributes["body"], (str, unicode)), attributes["body"]
self._body = attributes["body"]
@@ -515,9 +569,15 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
if "comments" in attributes: # pragma no branch
assert attributes["comments"] is None or isinstance(attributes["comments"], (int, long)), attributes["comments"]
self._comments = attributes["comments"]
if "comments_url" in attributes: # pragma no branch
assert attributes["comments_url"] is None or isinstance(attributes["comments_url"], (str, unicode)), attributes["comments_url"]
self._comments_url = attributes["comments_url"]
if "commits" in attributes: # pragma no branch
assert attributes["commits"] is None or isinstance(attributes["commits"], (int, long)), attributes["commits"]
self._commits = attributes["commits"]
if "commits_url" in attributes: # pragma no branch
assert attributes["commits_url"] is None or isinstance(attributes["commits_url"], (str, unicode)), attributes["commits_url"]
self._commits_url = attributes["commits_url"]
if "created_at" in attributes: # pragma no branch
assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"]
self._created_at = self._parseDatetime(attributes["created_at"])
@@ -529,7 +589,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._diff_url = attributes["diff_url"]
if "head" in attributes: # pragma no branch
assert attributes["head"] is None or isinstance(attributes["head"], dict), attributes["head"]
self._head = None if attributes["head"] is None else github.PullRequestPart.PullRequestPart(self._requester, attributes["head"], completed=False)
self._head = None if attributes["head"] is None else github.PullRequestPart.PullRequestPart(self._requester, self._headers, attributes["head"], completed=False)
if "html_url" in attributes: # pragma no branch
assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"]
self._html_url = attributes["html_url"]
@@ -539,9 +599,15 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
if "issue_url" in attributes: # pragma no branch
assert attributes["issue_url"] is None or isinstance(attributes["issue_url"], (str, unicode)), attributes["issue_url"]
self._issue_url = attributes["issue_url"]
if "merge_commit_sha" in attributes: # pragma no branch
assert attributes["merge_commit_sha"] is None or isinstance(attributes["merge_commit_sha"], (str, unicode)), attributes["merge_commit_sha"]
self._merge_commit_sha = attributes["merge_commit_sha"]
if "mergeable" in attributes: # pragma no branch
assert attributes["mergeable"] is None or isinstance(attributes["mergeable"], bool), attributes["mergeable"]
self._mergeable = attributes["mergeable"]
if "mergeable_state" in attributes: # pragma no branch
assert attributes["mergeable_state"] is None or isinstance(attributes["mergeable_state"], (str, unicode)), attributes["mergeable_state"]
self._mergeable_state = attributes["mergeable_state"]
if "merged" in attributes: # pragma no branch
assert attributes["merged"] is None or isinstance(attributes["merged"], bool), attributes["merged"]
self._merged = attributes["merged"]
@@ -550,16 +616,25 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._merged_at = self._parseDatetime(attributes["merged_at"])
if "merged_by" in attributes: # pragma no branch
assert attributes["merged_by"] is None or isinstance(attributes["merged_by"], dict), attributes["merged_by"]
self._merged_by = None if attributes["merged_by"] is None else github.NamedUser.NamedUser(self._requester, attributes["merged_by"], completed=False)
self._merged_by = None if attributes["merged_by"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["merged_by"], completed=False)
if "milestone" in attributes: # pragma no branch
assert attributes["milestone"] is None or isinstance(attributes["milestone"], dict), attributes["milestone"]
self._milestone = None if attributes["milestone"] is None else github.Milestone.Milestone(self._requester, self._headers, attributes["milestone"], completed=False)
if "number" in attributes: # pragma no branch
assert attributes["number"] is None or isinstance(attributes["number"], (int, long)), attributes["number"]
self._number = attributes["number"]
if "patch_url" in attributes: # pragma no branch
assert attributes["patch_url"] is None or isinstance(attributes["patch_url"], (str, unicode)), attributes["patch_url"]
self._patch_url = attributes["patch_url"]
if "review_comment_url" in attributes: # pragma no branch
assert attributes["review_comment_url"] is None or isinstance(attributes["review_comment_url"], (str, unicode)), attributes["review_comment_url"]
self._review_comment_url = attributes["review_comment_url"]
if "review_comments" in attributes: # pragma no branch
assert attributes["review_comments"] is None or isinstance(attributes["review_comments"], (int, long)), attributes["review_comments"]
self._review_comments = attributes["review_comments"]
if "review_comments_url" in attributes: # pragma no branch
assert attributes["review_comments_url"] is None or isinstance(attributes["review_comments_url"], (str, unicode)), attributes["review_comments_url"]
self._review_comments_url = attributes["review_comments_url"]
if "state" in attributes: # pragma no branch
assert attributes["state"] is None or isinstance(attributes["state"], (str, unicode)), attributes["state"]
self._state = attributes["state"]
@@ -574,4 +649,4 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
self._url = attributes["url"]
if "user" in attributes: # pragma no branch
assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"]
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)
+28 -6
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Michael Stead <michael.stead@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
@@ -59,6 +60,14 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def diff_hunk(self):
"""
:type: string
"""
self._completeIfNotSet(self._diff_hunk)
return self._NoneIfNotSet(self._diff_hunk)
@property
def id(self):
"""
@@ -99,6 +108,14 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._position)
return self._NoneIfNotSet(self._position)
@property
def pull_request_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._pull_request_url)
return self._NoneIfNotSet(self._pull_request_url)
@property
def updated_at(self):
"""
@@ -138,9 +155,7 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def edit(self, body):
@@ -156,8 +171,7 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -165,11 +179,13 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
self._body = github.GithubObject.NotSet
self._commit_id = github.GithubObject.NotSet
self._created_at = github.GithubObject.NotSet
self._diff_hunk = github.GithubObject.NotSet
self._id = github.GithubObject.NotSet
self._original_commit_id = github.GithubObject.NotSet
self._original_position = github.GithubObject.NotSet
self._path = github.GithubObject.NotSet
self._position = github.GithubObject.NotSet
self._pull_request_url = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
self._html_url = github.GithubObject.NotSet
@@ -185,6 +201,9 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
if "created_at" in attributes: # pragma no branch
assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"]
self._created_at = self._parseDatetime(attributes["created_at"])
if "diff_hunk" in attributes: # pragma no branch
assert attributes["diff_hunk"] is None or isinstance(attributes["diff_hunk"], (str, unicode)), attributes["diff_hunk"]
self._diff_hunk = attributes["diff_hunk"]
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"]
self._id = attributes["id"]
@@ -200,6 +219,9 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
if "position" in attributes: # pragma no branch
assert attributes["position"] is None or isinstance(attributes["position"], (int, long)), attributes["position"]
self._position = attributes["position"]
if "pull_request_url" in attributes: # pragma no branch
assert attributes["pull_request_url"] is None or isinstance(attributes["pull_request_url"], (str, unicode)), attributes["pull_request_url"]
self._pull_request_url = attributes["pull_request_url"]
if "updated_at" in attributes: # pragma no branch
assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"]
self._updated_at = self._parseDatetime(attributes["updated_at"])
@@ -211,4 +233,4 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
self._html_url = attributes["html_url"]
if "user" in attributes: # pragma no branch
assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"]
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)
+1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
# #
+3 -2
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -85,10 +86,10 @@ class PullRequestPart(github.GithubObject.NonCompletableGithubObject):
self._ref = attributes["ref"]
if "repo" in attributes: # pragma no branch
assert attributes["repo"] is None or isinstance(attributes["repo"], dict), attributes["repo"]
self._repo = None if attributes["repo"] is None else github.Repository.Repository(self._requester, attributes["repo"], completed=False)
self._repo = None if attributes["repo"] is None else github.Repository.Repository(self._requester, self._headers, attributes["repo"], completed=False)
if "sha" in attributes: # pragma no branch
assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"]
self._sha = attributes["sha"]
if "user" in attributes: # pragma no branch
assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"]
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)
+68
View File
@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
############################ Copyrights and license ############################
# #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/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 github.GithubObject
import datetime
class Rate(github.GithubObject.NonCompletableGithubObject):
"""
This class represents rate limits as defined in http://developer.github.com/v3/rate_limit
"""
@property
def limit(self):
"""
:type: integer
"""
return self._NoneIfNotSet(self._limit)
@property
def remaining(self):
"""
:type: integer
"""
return self._NoneIfNotSet(self._remaining)
@property
def reset(self):
"""
:type: datetime.datetime
"""
return self._NoneIfNotSet(self._reset)
def _initAttributes(self):
self._limit = github.GithubObject.NotSet
self._remaining = github.GithubObject.NotSet
self._reset = github.GithubObject.NotSet
def _useAttributes(self, attributes):
if "limit" in attributes: # pragma no branch
assert attributes["limit"] is None or isinstance(attributes["limit"], (int, long)), attributes["limit"]
self._limit = attributes["limit"]
if "remaining" in attributes: # pragma no branch
assert attributes["remaining"] is None or isinstance(attributes["remaining"], (int, long)), attributes["remaining"]
self._remaining = attributes["remaining"]
if "reset" in attributes: # pragma no branch
assert attributes["reset"] is None or isinstance(attributes["reset"], (int, long)), attributes["reset"]
self._reset = datetime.datetime.utcfromtimestamp(attributes["reset"])
+46
View File
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
############################ Copyrights and license ############################
# #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/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 github.GithubObject
import github.Rate
class RateLimit(github.GithubObject.NonCompletableGithubObject):
"""
This class represents rate limits as defined in http://developer.github.com/v3/rate_limit
"""
@property
def rate(self):
"""
:type: class:`github.Rate.Rate`
"""
return self._NoneIfNotSet(self._rate)
def _initAttributes(self):
self._rate = github.GithubObject.NotSet
def _useAttributes(self, attributes):
if "rate" in attributes: # pragma no branch
assert attributes["rate"] is None or isinstance(attributes["rate"], dict), attributes["rate"]
self._rate = None if attributes["rate"] is None else github.Rate.Rate(self._requester, self._headers, attributes["rate"], completed=False)
+565 -152
View File
File diff suppressed because it is too large Load Diff
+5 -7
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Srijan Choudhary <srijan4@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
@@ -33,8 +34,8 @@ class RepositoryKey(github.GithubObject.CompletableGithubObject):
This class represents RepositoryKeys. The reference can be found here http://developer.github.com/v3/repos/keys/
"""
def __init__(self, requester, attributes, completed, repoUrl):
github.GithubObject.CompletableGithubObject.__init__(self, requester, attributes, completed)
def __init__(self, requester, headers, attributes, completed, repoUrl):
github.GithubObject.CompletableGithubObject.__init__(self, requester, headers, attributes, completed)
self.__repoUrl = repoUrl
@property
@@ -88,9 +89,7 @@ class RepositoryKey(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.__customUrl,
None,
None
self.__customUrl
)
def edit(self, title=github.GithubObject.NotSet, key=github.GithubObject.NotSet):
@@ -110,8 +109,7 @@ class RepositoryKey(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.__customUrl,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
+90 -18
View File
@@ -9,6 +9,7 @@
# Copyright 2012 Steve English <steve.english@navetas.com> #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Ed Jackson <ed.jackson@gmail.com> #
# Copyright 2013 Jonathan J Hunt <hunt@braincorporation.com> #
# Copyright 2013 Mark Roddy <markroddy@gmail.com> #
@@ -37,6 +38,7 @@ import base64
import urllib
import urlparse
import sys
import Consts
atLeastPython26 = sys.hexversion >= 0x02060000
atLeastPython3 = sys.hexversion >= 0x03000000
@@ -63,7 +65,66 @@ class Requester:
cls.__httpConnectionClass = httplib.HTTPConnection
cls.__httpsConnectionClass = httplib.HTTPSConnection
#############################################################
# For Debug
@classmethod
def setDebugFlag(cls, flag):
cls.DEBUG_FLAG = flag
@classmethod
def setOnCheckMe(cls, onCheckMe):
cls.ON_CHECK_ME = onCheckMe
DEBUG_FLAG = False
DEBUG_FRAME_BUFFER_SIZE = 1024
DEBUG_HEADER_KEY = "DEBUG_FRAME"
ON_CHECK_ME = None
def NEW_DEBUG_FRAME(self, requestHeader):
'''
Initialize a debug frame with requestHeader
Frame count is updated and will be attached to respond header
The structure of a frame: [requestHeader, statusCode, responseHeader, raw_data]
Some of them may be None
'''
if self.DEBUG_FLAG: # pragma no branch (Flag always set in tests)
new_frame = [requestHeader, None, None, None]
if self._frameCount < self.DEBUG_FRAME_BUFFER_SIZE - 1: # pragma no branch (Should be covered)
self._frameBuffer.append(new_frame)
else:
self._frameBuffer[0] = new_frame # pragma no cover (Should be covered)
self._frameCount = len(self._frameBuffer) - 1
def DEBUG_ON_RESPONSE(self, statusCode, responseHeader, data):
'''
Update current frame with response
Current frame index will be attached to responseHeader
'''
if self.DEBUG_FLAG: # pragma no branch (Flag always set in tests)
self._frameBuffer[self._frameCount][1:4] = [statusCode, responseHeader, data]
responseHeader[self.DEBUG_HEADER_KEY] = self._frameCount
def check_me(self, obj):
if self.DEBUG_FLAG and self.ON_CHECK_ME is not None: # pragma no branch (Flag always set in tests)
frame = None
if self.DEBUG_HEADER_KEY in obj._headers:
frame_index = obj._headers[self.DEBUG_HEADER_KEY]
frame = self._frameBuffer[frame_index]
self.ON_CHECK_ME(obj, frame)
def _initializeDebugFeature(self):
self._frameCount = 0
self._frameBuffer = []
#############################################################
def __init__(self, login_or_token, password, base_url, timeout, client_id, client_secret, user_agent, per_page):
self._initializeDebugFeature()
if password is not None:
login = login_or_token
if atLeastPython3:
@@ -103,11 +164,11 @@ class Requester:
'See http://developer.github.com/v3/#user-agent-required'
self.__userAgent = user_agent
def requestJsonAndCheck(self, verb, url, parameters, input):
return self.__check(*self.requestJson(verb, url, parameters, input))
def requestJsonAndCheck(self, verb, url, parameters=None, headers=None, input=None, cnx=None):
return self.__check(*self.requestJson(verb, url, parameters, headers, input, cnx))
def requestMultipartAndCheck(self, verb, url, parameters, input):
return self.__check(*self.requestMultipart(verb, url, parameters, input))
def requestMultipartAndCheck(self, verb, url, parameters=None, headers=None, input=None):
return self.__check(*self.requestMultipart(verb, url, parameters, headers, input))
def __check(self, status, responseHeaders, output):
output = self.__structuredFromJson(output)
@@ -116,13 +177,13 @@ class Requester:
return responseHeaders, output
def __createException(self, status, output):
if status == 401 and output["message"] == "Bad credentials":
if status == 401 and output.get("message") == "Bad credentials":
cls = GithubException.BadCredentialsException
elif status == 403 and output["message"].startswith("Missing or invalid User Agent string"):
elif status == 403 and output.get("message").startswith("Missing or invalid User Agent string"):
cls = GithubException.BadUserAgentException
elif status == 403 and output["message"].startswith("API Rate Limit Exceeded"):
elif status == 403 and output.get("message").startswith("API Rate Limit Exceeded"):
cls = GithubException.RateLimitExceededException
elif status == 404 and output["message"] == "Not Found":
elif status == 404 and output.get("message") == "Not Found":
cls = GithubException.UnknownObjectException
else:
cls = GithubException.GithubException
@@ -139,13 +200,13 @@ class Requester:
except ValueError, e:
return {'data': data}
def requestJson(self, verb, url, parameters, input):
def requestJson(self, verb, url, parameters=None, headers=None, input=None, cnx=None):
def encode(input):
return "application/json", json.dumps(input)
return self.__requestEncode(verb, url, parameters, input, encode)
return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode)
def requestMultipart(self, verb, url, parameters, input):
def requestMultipart(self, verb, url, parameters=None, headers=None, input=None):
def encode(input):
boundary = "----------------------------3c3ba8b523b2"
eol = "\r\n"
@@ -159,14 +220,15 @@ class Requester:
encoded_input += "--" + boundary + "--" + eol
return "multipart/form-data; boundary=" + boundary, encoded_input
return self.__requestEncode(verb, url, parameters, input, encode)
return self.__requestEncode(None, verb, url, parameters, headers, input, encode)
def __requestEncode(self, verb, url, parameters, input, encode):
def __requestEncode(self, cnx, verb, url, parameters, requestHeaders, input, encode):
assert verb in ["HEAD", "GET", "POST", "PATCH", "PUT", "DELETE"]
if parameters is None:
parameters = dict()
if requestHeaders is None:
requestHeaders = dict()
requestHeaders = dict()
self.__authenticate(url, requestHeaders, parameters)
requestHeaders["User-Agent"] = self.__userAgent
@@ -177,7 +239,9 @@ class Requester:
if input is not None:
requestHeaders["Content-Type"], encoded_input = encode(input)
status, responseHeaders, output = self.__requestRaw(verb, url, requestHeaders, encoded_input)
self.NEW_DEBUG_FRAME(requestHeaders)
status, responseHeaders, output = self.__requestRaw(cnx, 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"]))
@@ -187,10 +251,16 @@ class Requester:
if "x-oauth-scopes" in responseHeaders:
self.oauth_scopes = responseHeaders["x-oauth-scopes"].split(", ")
self.DEBUG_ON_RESPONSE(status, responseHeaders, output)
return status, responseHeaders, output
def __requestRaw(self, verb, url, requestHeaders, input):
cnx = self.__createConnection()
def __requestRaw(self, cnx, verb, url, requestHeaders, input):
if cnx is None:
cnx = self.__createConnection()
else:
assert cnx == "status"
cnx = self.__httpsConnectionClass("status.github.com", 443)
cnx.request(
verb,
url,
@@ -244,7 +314,7 @@ class Requester:
kwds["strict"] = True # Useless in Python3, would generate a deprecation warning
if atLeastPython26: # pragma no branch (Branch useful only with Python 2.5)
kwds["timeout"] = self.__timeout # Did not exist before Python2.6
return self.__connectionClass(host=self.__hostname, port=self.__port, **kwds)
return self.__connectionClass(self.__hostname, self.__port, **kwds)
def __log(self, verb, url, requestHeaders, input, status, responseHeaders, output):
logger = logging.getLogger(__name__)
@@ -254,4 +324,6 @@ class Requester:
requestHeaders["Authorization"] = "Basic (login and password removed)"
elif requestHeaders["Authorization"].startswith("token"):
requestHeaders["Authorization"] = "token (oauth token removed)"
else: # pragma no cover (Cannot happen, but could if we add an authentication method => be prepared)
requestHeaders["Authorization"] = "(unknown auth removed)" # pragma no cover (Cannot happen, but could if we add an authentication method => be prepared)
logger.debug("%s %s://%s%s %s %s ==> %i %s %s", str(verb), self.__scheme, self.__hostname, str(url), str(requestHeaders), str(input), status, str(responseHeaders), str(output))
+56
View File
@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
############################ Copyrights and license ############################
# #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/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 github.GithubObject
class Status(github.GithubObject.NonCompletableGithubObject):
"""
This class represents status as defined in https://status.github.com/api
"""
@property
def status(self):
"""
:type: string
"""
return self._NoneIfNotSet(self._status)
@property
def last_updated(self):
"""
:type: datetime.datetime
"""
return self._NoneIfNotSet(self._last_updated)
def _initAttributes(self):
self._status = github.GithubObject.NotSet
self._last_updated = github.GithubObject.NotSet
def _useAttributes(self, attributes):
if "status" in attributes: # pragma no branch
assert attributes["status"] is None or isinstance(attributes["status"], (str, unicode)), attributes["status"]
self._status = attributes["status"]
if "last_updated" in attributes: # pragma no branch
assert attributes["last_updated"] is None or isinstance(attributes["last_updated"], (str, unicode)), attributes["last_updated"]
self._last_updated = self._parseDatetime(attributes["last_updated"])
+66
View File
@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-
############################ Copyrights and license ############################
# #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/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 github.GithubObject
class StatusMessage(github.GithubObject.NonCompletableGithubObject):
"""
This class represents status messages as defined in https://status.github.com/api
"""
@property
def body(self):
"""
:type: string
"""
return self._NoneIfNotSet(self._body)
@property
def status(self):
"""
:type: string
"""
return self._NoneIfNotSet(self._status)
@property
def created_on(self):
"""
:type: datetime.datetime
"""
return self._NoneIfNotSet(self._created_on)
def _initAttributes(self):
self._status = github.GithubObject.NotSet
self._created_on = github.GithubObject.NotSet
def _useAttributes(self, attributes):
if "body" in attributes: # pragma no branch
assert attributes["body"] is None or isinstance(attributes["body"], (str, unicode)), attributes["body"]
self._body = attributes["body"]
if "status" in attributes: # pragma no branch
assert attributes["status"] is None or isinstance(attributes["status"], (str, unicode)), attributes["status"]
self._status = attributes["status"]
if "created_on" in attributes: # pragma no branch
assert attributes["created_on"] is None or isinstance(attributes["created_on"], (str, unicode)), attributes["created_on"]
self._created_on = self._parseDatetime(attributes["created_on"])
+2 -1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
# #
@@ -71,7 +72,7 @@ class Tag(github.GithubObject.NonCompletableGithubObject):
def _useAttributes(self, attributes):
if "commit" in attributes: # pragma no branch
assert attributes["commit"] is None or isinstance(attributes["commit"], dict), attributes["commit"]
self._commit = None if attributes["commit"] is None else github.Commit.Commit(self._requester, attributes["commit"], completed=False)
self._commit = None if attributes["commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["commit"], completed=False)
if "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
+45 -23
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
# #
@@ -52,6 +53,14 @@ class Team(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._members_count)
return self._NoneIfNotSet(self._members_count)
@property
def members_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._members_url)
return self._NoneIfNotSet(self._members_url)
@property
def name(self):
"""
@@ -76,6 +85,22 @@ class Team(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._repos_count)
return self._NoneIfNotSet(self._repos_count)
@property
def repositories_url(self):
"""
:type: string
"""
self._completeIfNotSet(self._repositories_url)
return self._NoneIfNotSet(self._repositories_url)
@property
def slug(self):
"""
:type: string
"""
self._completeIfNotSet(self._slug)
return self._NoneIfNotSet(self._slug)
@property
def url(self):
"""
@@ -93,9 +118,7 @@ class Team(github.GithubObject.CompletableGithubObject):
assert isinstance(member, github.NamedUser.NamedUser), member
headers, data = self._requester.requestJsonAndCheck(
"PUT",
self.url + "/members/" + member._identity,
None,
None
self.url + "/members/" + member._identity
)
def add_to_repos(self, repo):
@@ -107,9 +130,7 @@ class Team(github.GithubObject.CompletableGithubObject):
assert isinstance(repo, github.Repository.Repository), repo
headers, data = self._requester.requestJsonAndCheck(
"PUT",
self.url + "/repos/" + repo._identity,
None,
None
self.url + "/repos/" + repo._identity
)
def delete(self):
@@ -119,9 +140,7 @@ class Team(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def edit(self, name, permission=github.GithubObject.NotSet):
@@ -141,8 +160,7 @@ class Team(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
@@ -179,9 +197,7 @@ class Team(github.GithubObject.CompletableGithubObject):
assert isinstance(member, github.NamedUser.NamedUser), member
status, headers, data = self._requester.requestJson(
"GET",
self.url + "/members/" + member._identity,
None,
None
self.url + "/members/" + member._identity
)
return status == 204
@@ -194,9 +210,7 @@ class Team(github.GithubObject.CompletableGithubObject):
assert isinstance(repo, github.Repository.Repository), repo
status, headers, data = self._requester.requestJson(
"GET",
self.url + "/repos/" + repo._identity,
None,
None
self.url + "/repos/" + repo._identity
)
return status == 204
@@ -209,9 +223,7 @@ class Team(github.GithubObject.CompletableGithubObject):
assert isinstance(member, github.NamedUser.NamedUser), member
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url + "/members/" + member._identity,
None,
None
self.url + "/members/" + member._identity
)
def remove_from_repos(self, repo):
@@ -223,9 +235,7 @@ class Team(github.GithubObject.CompletableGithubObject):
assert isinstance(repo, github.Repository.Repository), repo
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url + "/repos/" + repo._identity,
None,
None
self.url + "/repos/" + repo._identity
)
@property
@@ -235,9 +245,12 @@ class Team(github.GithubObject.CompletableGithubObject):
def _initAttributes(self):
self._id = github.GithubObject.NotSet
self._members_count = github.GithubObject.NotSet
self._members_url = github.GithubObject.NotSet
self._name = github.GithubObject.NotSet
self._permission = github.GithubObject.NotSet
self._repos_count = github.GithubObject.NotSet
self._repositories_url = github.GithubObject.NotSet
self._slug = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
def _useAttributes(self, attributes):
@@ -247,6 +260,9 @@ class Team(github.GithubObject.CompletableGithubObject):
if "members_count" in attributes: # pragma no branch
assert attributes["members_count"] is None or isinstance(attributes["members_count"], (int, long)), attributes["members_count"]
self._members_count = attributes["members_count"]
if "members_url" in attributes: # pragma no branch
assert attributes["members_url"] is None or isinstance(attributes["members_url"], (str, unicode)), attributes["members_url"]
self._members_url = attributes["members_url"]
if "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
@@ -256,6 +272,12 @@ class Team(github.GithubObject.CompletableGithubObject):
if "repos_count" in attributes: # pragma no branch
assert attributes["repos_count"] is None or isinstance(attributes["repos_count"], (int, long)), attributes["repos_count"]
self._repos_count = attributes["repos_count"]
if "repositories_url" in attributes: # pragma no branch
assert attributes["repositories_url"] is None or isinstance(attributes["repositories_url"], (str, unicode)), attributes["repositories_url"]
self._repositories_url = attributes["repositories_url"]
if "slug" in attributes: # pragma no branch
assert attributes["slug"] is None or isinstance(attributes["slug"], (str, unicode)), attributes["slug"]
self._slug = attributes["slug"]
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+3 -5
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2013 martinqt <m.ki2@laposte.net> #
# #
@@ -79,9 +80,7 @@ class UserKey(github.GithubObject.CompletableGithubObject):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.url,
None,
None
self.url
)
def edit(self, title=github.GithubObject.NotSet, key=github.GithubObject.NotSet):
@@ -101,8 +100,7 @@ class UserKey(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
None,
post_parameters
input=post_parameters
)
self._useAttributes(data)
+6 -1
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -56,6 +57,7 @@ from PullRequestFile import *
from RateLimiting import *
from Repository import *
from RepositoryKey import *
from Status import *
from Tag import *
from Team import *
from UserKey import *
@@ -65,6 +67,9 @@ from Exceptions import *
from Enterprise import *
from Logging_ import *
from RawData import *
from ConditionalRequestUpdate import *
from Persistence import *
from ExposeAllAttributes import *
from Issue33 import *
from Issue50 import *
@@ -76,6 +81,6 @@ from Issue133 import *
from Issue134 import *
from Issue139 import *
from Issue140 import *
# from Issue142 import * # Deactivated for Travis-CI because Github has lowered the rate limitations
from Issue142 import *
from Issue158 import *
from Issue174 import *
+44
View File
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
############################ Copyrights and license ############################
# #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/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/>. #
# #
################################################################################
# #193: Line endings should be linux style
import Framework
import github
class ConditionalRequestUpdate(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.repo = self.g.get_repo("akfish/PyGithub")
def testDidNotUpdate(self):
self.assertFalse(self.repo.update(), msg="The repo is not changes. But update() != False")
def testDidUpdate(self):
self.assertTrue(self.repo.update(), msg="The repo should be changed by now. But update() != True")
def testUpdateObjectWithoutEtag(self):
r = self.g.get_repo("jacquev6/PyGithub")
self.assertTrue(r.update())
+160
View File
@@ -0,0 +1,160 @@
# -*- coding: utf-8 -*-
############################ Copyrights and license ############################
# #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/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 ExposeAllAttributes(Framework.TestCase):
def testAllClasses(self):
authenticatedUser = self.g.get_user()
namedUser = self.g.get_user("nvie")
repository = authenticatedUser.get_repo("PyGithub")
organization = self.g.get_organization("BeaverSoftware")
plan = authenticatedUser.plan
branch = repository.get_branch("master")
commit = repository.get_commit("1292bf0e22c796e91cc3d6e24b544aece8c21f2a")
commitStats = commit.stats
commitStatus = commit.get_statuses()[0]
milestone = repository.get_milestone(17)
gist = self.g.get_gist("149016")
gistComment = gist.get_comment(4565)
gistFile = gist.files[".gitignore"]
gistHistoryState = gist.history[0]
gitCommit = repository.get_git_commit("be37b8a7f3a68631c32672dcd84d9eba27438ee6")
gitAuthor = gitCommit.author
gitTree = repository.get_git_tree("6f7c2d8c66d78863f7b91792deaead619799a1ce")
gitTreeElement = gitTree.tree[0]
gitBlob = repository.get_git_blob("681fb61f1761743a02f5c790f1c762cbfe8cfad1")
gitRef = repository.get_git_ref("tags/v1.17.0")
gitObject = gitRef.object
issue = repository.get_issue(188)
issueComment = issue.get_comment(22686536)
issueEvent = issue.get_events()[0]
issuePullRequest = issue.pull_request
gitignoreTemplate = self.g.get_gitignore_template("Python")
team = organization.get_team(141487)
label = repository.get_label("Bug")
pullRequest = repository.get_pull(31)
pullRequestComment = pullRequest.get_review_comment(1580134)
pullRequestPart = pullRequest.base
file = pullRequest.get_files()[0]
commitComment = repository.get_comment(3630301)
status = self.g.get_api_status()
statusMessage = self.g.get_last_api_status_message()
rateLimit = self.g.get_rate_limit()
rate = rateLimit.rate
hook = repository.get_hooks()[0]
hookResponse = hook.last_response
hookDescription = self.g.get_hooks()[0]
comparison = repository.compare("master", "develop")
contentFile = repository.get_file_contents("README.rst")
permissions = repository.permissions
event = repository.get_events()[0]
notification = authenticatedUser.get_notification("8406712")
notificationSubject = notification.subject
missingAttributes = self.gatherMissingAttributes([
authenticatedUser,
# authorization, # Security issue if put as-is in ReplayData
# authorizationApplication, # Security issue if put as-is in ReplayData
branch,
commit,
commitComment,
commitStats,
commitStatus,
comparison,
contentFile,
# download, # Deprecated: https://github.com/blog/1302-goodbye-uploads
event,
file,
gist,
gistComment,
gistFile,
gistHistoryState,
gitAuthor,
gitBlob,
gitCommit,
gitignoreTemplate,
gitObject,
gitRef,
# gitTag,
gitTree,
gitTreeElement,
hook,
hookDescription,
hookResponse,
issue,
issueComment,
issueEvent,
issuePullRequest,
label,
milestone,
namedUser,
notification,
notificationSubject,
organization,
permissions,
plan,
pullRequest,
pullRequestComment,
# pullRequestMergeStatus, # Only obtained when merging a pull request through the API
pullRequestPart,
rate,
rateLimit,
repository,
# repositoryKey, # Security issue if put as-is in ReplayData
status,
statusMessage,
# tag,
team,
# userKey, # Security issue if put as-is in ReplayData
])
for className, attributesMissingInClass in sorted(missingAttributes.iteritems()):
for attrName, value in sorted(attributesMissingInClass.iteritems()):
print className, attrName, "->", repr(value)
self.assertEqual(sum(len(attrs) for attrs in missingAttributes.values()), 0)
def findMissingAttributes(self, obj):
if hasattr(obj, "update"):
obj.update()
className = obj.__class__.__name__
missingAttributes = {}
for attribute in obj.raw_data:
if attribute != "_links":
if not hasattr(obj, attribute):
missingAttributes[attribute] = obj.raw_data[attribute]
return (className, missingAttributes)
def gatherMissingAttributes(self, objs):
allMissingAttributes = dict()
for obj in objs:
className, attributesMissingInClass = self.findMissingAttributes(obj)
if len(attributesMissingInClass) > 0:
if className not in allMissingAttributes:
allMissingAttributes[className] = dict()
allMissingAttributes[className].update(attributesMissingInClass)
return allMissingAttributes
+17
View File
@@ -4,6 +4,7 @@
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 AKFish <akfish@gmail.com> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
@@ -244,8 +245,24 @@ class BasicTestCase(unittest.TestCase):
class TestCase(BasicTestCase):
def doCheckFrame(self, obj, frame):
if obj._headers == {} and frame is None:
return
if obj._headers is None and frame == {}:
return
self.assertEqual(obj._headers, frame[2])
def getFrameChecker(self):
return lambda requester, obj, frame: self.doCheckFrame(obj, frame)
def setUp(self):
BasicTestCase.setUp(self)
# Set up frame debugging
github.GithubObject.GithubObject.setCheckAfterInitFlag(True)
github.Requester.Requester.setDebugFlag(True)
github.Requester.Requester.setOnCheckMe(self.getFrameChecker())
self.g = github.Github(self.login, self.password)
+4 -4
View File
@@ -108,12 +108,12 @@ class Gist(Framework.TestCase):
self.assertFalse(self.gist.is_starred())
def testFork(self):
gist = self.g.get_gist("2729818") # Random gist
gist = self.g.get_gist("6296553") # Random gist
myGist = gist.create_fork()
self.assertEqual(myGist.id, "2729865")
self.assertEqual(myGist.id, "6296732")
self.assertEqual(myGist.fork_of, None) # WTF
sameGist = self.g.get_gist("2729865")
self.assertEqual(sameGist.fork_of.id, "2729818")
sameGist = self.g.get_gist("6296732")
self.assertEqual(sameGist.fork_of.id, "6296553")
def testDelete(self):
self.gist.delete()
+6
View File
@@ -128,3 +128,9 @@ class Github(Framework.TestCase):
def testGetUsersSince(self):
self.assertListKeyBegin(self.g.get_users(since=1000), lambda u: u.login, ["sbecker"])
def testGetRepos(self):
self.assertListKeyBegin(self.g.get_repos(), lambda r: r.name, ["grit", "merb-core", "rubinius", "god", "jsawesome", "jspec", "exception_logger", "ambition"])
def testGetReposSince(self):
self.assertListKeyBegin(self.g.get_repos(since=1000), lambda r: r.name, ["jquery-humanize-messages-plugin", "4slicer", "fixture-scenarios", "mongrel_proctitle", "rails-plugins"])
+3 -3
View File
@@ -25,8 +25,8 @@ import unittest
import github
class Issue142(unittest.TestCase): # https://github.com/jacquev6/PyGithub/issues/140
class Issue142(unittest.TestCase): # https://github.com/jacquev6/PyGithub/issues/142
def testDecodeJson(self):
# This test has to hit GitHub for real, because the record-replay framework looses types
# and python3 does not behave like python3 for strings and bytes
self.assertEqual(github.Github().get_user("jacquev6").name, "Vincent Jacques")
# and python3 does not behave like python2 for strings and bytes
self.assertEqual(github.Github().get_rate_limit().rate.limit, 60)
+4
View File
@@ -109,6 +109,10 @@ class NamedUser(Framework.TestCase):
def testGetFollowing(self):
self.assertListKeyEqual(self.user.get_following(), lambda f: f.login, ["nvie", "schacon", "jamis", "chad", "unclebob", "dabrahams", "jnorthrup", "brugidou", "regisb", "walidk", "tanzilli", "fjardon", "r3c", "sdanzan", "vineus", "cjuniet", "gturri", "ant9000", "asquini", "claudyus", "jardon-u", "s-bernard", "kamaradclimber", "Lyloa"])
def testHasInFollowing(self):
nvie = self.g.get_user("nvie")
self.assertTrue(self.user.has_in_following(nvie))
def testGetOrgs(self):
self.assertListKeyEqual(self.user.get_orgs(), lambda o: o.login, ["BeaverSoftware"])
+55
View File
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
############################ Copyrights and license ############################
# #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/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
if Framework.atLeastPython26:
from io import BytesIO as IO
else:
from StringIO import StringIO as IO
class Persistence(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.repo = self.g.get_repo("akfish/PyGithub")
self.dumpedRepo = IO()
self.g.dump(self.repo, self.dumpedRepo)
self.dumpedRepo.seek(0)
def tearDown(self):
self.dumpedRepo.close()
def testLoad(self):
loadedRepo = self.g.load(self.dumpedRepo)
self.assertTrue(isinstance(loadedRepo, github.Repository.Repository))
self.assertTrue(loadedRepo._requester is self.repo._requester)
self.assertTrue(loadedRepo.owner._requester is self.repo._requester)
self.assertEqual(loadedRepo.name, "PyGithub")
self.assertEqual(loadedRepo.url, "https://api.github.com/repos/akfish/PyGithub")
def testLoadAndUpdate(self):
loadedRepo = self.g.load(self.dumpedRepo)
self.assertTrue(loadedRepo.update())
+8
View File
@@ -24,6 +24,8 @@
# #
################################################################################
import datetime
import Framework
@@ -36,3 +38,9 @@ class RateLimiting(Framework.TestCase):
def testResetTime(self):
self.assertEqual(self.g.rate_limiting_resettime, 1375802816)
def testGetRateLimit(self):
rateLimit = self.g.get_rate_limit()
self.assertEqual(rateLimit.rate.limit, 5000)
self.assertEqual(rateLimit.rate.remaining, 5000)
self.assertEqual(rateLimit.rate.reset, datetime.datetime(2013, 9, 6, 10, 29, 57))
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
https
GET
api.github.com
None
/repos/akfish/PyGithub
{'If-None-Match': '"8600bedcb7fed1d8065e1693e05529ce"', 'User-Agent': 'PyGithub/Python', 'Authorization': 'Basic login_and_password_removed', 'If-Modified-Since': 'Thu, 22 Aug 2013 02:09:11 GMT'}
null
304
[('status', '304 Not Modified'), ('x-ratelimit-remaining', '4988'), ('x-content-type-options', 'nosniff'), ('access-control-expose-headers', 'ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes'), ('access-control-allow-credentials', 'true'), ('vary', 'Accept-Encoding'), ('server', 'GitHub.com'), ('last-modified', 'Thu, 22 Aug 2013 02:09:11 GMT'), ('x-ratelimit-limit', '5000'), ('etag', '"8600bedcb7fed1d8065e1693e05529ce"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Thu, 22 Aug 2013 02:13:10 GMT'), ('access-control-allow-origin', '*'), ('x-ratelimit-reset', '1377140429')]
File diff suppressed because one or more lines are too long
@@ -0,0 +1,22 @@
https
GET
api.github.com
None
/repos/jacquev6/PyGithub
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4911'), ('content-length', '1129'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('date', 'Sun, 27 May 2012 07:17:09 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"clone_url":"https://github.com/jacquev6/PyGithub.git","has_downloads":true,"watchers":15,"git_url":"git://github.com/jacquev6/PyGithub.git","updated_at":"2012-05-27T06:55:28Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://vincent-jacques.net/PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub","mirror_url":null,"has_wiki":false,"has_issues":true,"fork":false,"forks":3,"size":308,"private":false,"open_issues":16,"svn_url":"https://github.com/jacquev6/PyGithub","owner":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"name":"PyGithub","language":"Python","description":"Python library implementing the full Github API v3","ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-27T06:00:28Z","created_at":"2012-02-25T12:53:47Z","id":3544490,"html_url":"https://github.com/jacquev6/PyGithub","full_name":"jacquev6/PyGithub"}
https
GET
api.github.com
None
/repos/jacquev6/PyGithub
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4911'), ('content-length', '1129'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('date', 'Sun, 27 May 2012 07:17:09 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"clone_url":"https://github.com/jacquev6/PyGithub.git","has_downloads":true,"watchers":15,"git_url":"git://github.com/jacquev6/PyGithub.git","updated_at":"2012-05-27T06:55:28Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://vincent-jacques.net/PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub","mirror_url":null,"has_wiki":false,"has_issues":true,"fork":false,"forks":3,"size":308,"private":false,"open_issues":16,"svn_url":"https://github.com/jacquev6/PyGithub","owner":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"name":"PyGithub","language":"Python","description":"Python library implementing the full Github API v3","ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-27T06:00:28Z","created_at":"2012-02-25T12:53:47Z","id":3544490,"html_url":"https://github.com/jacquev6/PyGithub","full_name":"jacquev6/PyGithub"}
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
+1 -1
View File
@@ -2,7 +2,7 @@ https
POST
api.github.com
None
/repos/jacquev6/PyGithub/hooks/257993/test
/repos/jacquev6/PyGithub/hooks/257993/tests
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
null
204
@@ -0,0 +1,22 @@
https
GET
api.github.com
None
/users/nvie
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4996'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('access-control-expose-headers', 'ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes'), ('access-control-allow-credentials', 'true'), ('vary', 'Accept, Authorization, Cookie, Accept-Encoding'), ('content-length', '1218'), ('server', 'GitHub.com'), ('last-modified', 'Wed, 21 Aug 2013 16:26:40 GMT'), ('x-ratelimit-limit', '5000'), ('etag', '"8e2b307f8fb4186bfb512febd7215fc8"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 21 Aug 2013 17:20:44 GMT'), ('access-control-allow-origin', '*'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1377108637')]
{"login":"nvie","id":83844,"avatar_url":"https://2.gravatar.com/avatar/466ef7561a0b100dc5a1021959962d28?d=https%3A%2F%2Fidenticons.github.com%2Fe6d0513ce49cc06cb956251623cb8fd9.png","gravatar_id":"466ef7561a0b100dc5a1021959962d28","url":"https://api.github.com/users/nvie","html_url":"https://github.com/nvie","followers_url":"https://api.github.com/users/nvie/followers","following_url":"https://api.github.com/users/nvie/following{/other_user}","gists_url":"https://api.github.com/users/nvie/gists{/gist_id}","starred_url":"https://api.github.com/users/nvie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nvie/subscriptions","organizations_url":"https://api.github.com/users/nvie/orgs","repos_url":"https://api.github.com/users/nvie/repos","events_url":"https://api.github.com/users/nvie/events{/privacy}","received_events_url":"https://api.github.com/users/nvie/received_events","type":"User","name":"Vincent Driessen","company":"3rd Cloud","blog":"http://nvie.com","location":"Netherlands","email":"vincent@3rdcloud.com","hireable":true,"bio":null,"public_repos":86,"followers":530,"following":45,"created_at":"2009-05-12T21:19:38Z","updated_at":"2013-08-21T16:26:40Z","public_gists":38}
https
GET
api.github.com
None
/users/jacquev6/following/nvie
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
null
204
[('status', '204 No Content'), ('x-ratelimit-remaining', '4995'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('access-control-expose-headers', 'ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes'), ('vary', 'Accept-Encoding'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('access-control-allow-credentials', 'true'), ('date', 'Wed, 21 Aug 2013 17:20:48 GMT'), ('access-control-allow-origin', '*'), ('x-ratelimit-reset', '1377108637')]
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
https
GET
api.github.com
None
/rate_limit
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '5000'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('access-control-expose-headers', 'ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes'), ('x-github-request-id', '1a3fa558-6663-4055-91e3-b6824f5f850e'), ('access-control-allow-credentials', 'true'), ('vary', 'Accept-Encoding'), ('content-length', '59'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('cache-control', 'no-cache'), ('date', 'Fri, 06 Sep 2013 09:29:57 GMT'), ('access-control-allow-origin', '*'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1378463397')]
{"rate":{"limit":5000,"remaining":5000,"reset":1378463397}}
@@ -0,0 +1,11 @@
https
GET
status.github.com
443
/api/last-message.json
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
null
200
[('status', '200 OK'), ('content-length', '93'), ('vary', 'Accept-Encoding'), ('server', 'GitHub.com'), ('connection', 'keep-alive'), ('date', 'Fri, 06 Sep 2013 08:34:01 GMT'), ('content-type', 'application/json;charset=utf-8')]
{"status":"good","body":"Everything operating normally.","created_on":"2013-09-01T15:41:46Z"}
@@ -0,0 +1,11 @@
https
GET
status.github.com
443
/api/messages.json
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
null
200
[('status', '200 OK'), ('content-length', '1492'), ('vary', 'Accept-Encoding'), ('server', 'GitHub.com'), ('connection', 'keep-alive'), ('date', 'Fri, 06 Sep 2013 08:41:31 GMT'), ('content-type', 'application/json;charset=utf-8')]
[{"status":"good","body":"Everything operating normally.","created_on":"2013-09-01T15:41:46Z"},{"status":"minor","body":"GitHub Pages are currently unavailable. We're investigating the problem.","created_on":"2013-09-01T15:26:59Z"},{"status":"good","body":"Everything operating normally.","created_on":"2013-09-01T15:17:24Z"},{"status":"minor","body":"We are investigating an increased rate of errors on GitHub.com","created_on":"2013-09-01T15:14:24Z"},{"status":"good","body":"Everything operating normally.","created_on":"2013-09-01T06:52:46Z"},{"status":"minor","body":"Some GitHub pages are again unavailable. We are continuing to investigate.","created_on":"2013-09-01T06:50:31Z"},{"status":"good","body":"Everything operating normally.","created_on":"2013-09-01T06:47:25Z"},{"status":"minor","body":"Some GitHub pages are temporarily unavailable.","created_on":"2013-09-01T06:43:03Z"},{"status":"good","body":"We're back up, now featuring a massively upgraded DB cluster with SSDs and 10Gbps networking! Thanks for your patience.","created_on":"2013-08-31T12:13:04Z"},{"status":"major","body":"We're beginning our scheduled maintenance now, and expect to be back up in 20 minutes. https://github.com/blog/1603-site-maintenance-august-31st-2013","created_on":"2013-08-31T12:00:13Z"},{"status":"good","body":"Everything operating normally.","created_on":"2013-08-31T11:45:50Z"},{"status":"minor","body":"We are investigating issues with GitHub Pages","created_on":"2013-08-31T11:43:39Z"}]
@@ -0,0 +1,11 @@
https
GET
status.github.com
443
/api/status.json
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
null
200
[('status', '200 OK'), ('content-length', '55'), ('vary', 'Accept-Encoding'), ('server', 'GitHub.com'), ('connection', 'keep-alive'), ('date', 'Fri, 06 Sep 2013 08:29:36 GMT'), ('content-type', 'application/json;charset=utf-8')]
{"status":"good","last_updated":"2013-09-06T08:29:27Z"}
+43
View File
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
############################ Copyrights and license ############################
# #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/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
import datetime
class Status(Framework.TestCase):
def testGetStatus(self):
status = self.g.get_api_status()
self.assertEqual(status.status, "good")
self.assertEqual(status.last_updated, datetime.datetime(2013, 9, 6, 8, 29, 27))
def testGetLastMessage(self):
message = self.g.get_last_api_status_message()
self.assertEqual(message.status, "good")
self.assertEqual(message.body, "Everything operating normally.")
self.assertEqual(message.created_on, datetime.datetime(2013, 9, 1, 15, 41, 46))
def testGetMessages(self):
self.assertListKeyEqual(self.g.get_api_status_messages(), lambda m: m.status, ["good", "minor", "good", "minor", "good", "minor", "good", "minor", "good", "major", "good", "minor"])
+119
View File
@@ -0,0 +1,119 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
############################ Copyrights and license ############################
# #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/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 sys
import os.path
# This script is unable to add an attribute after all the existing ones
# but, well, I'll do it manually in that case.
className, attributeName, attributeType = sys.argv[1:]
types = {
"string": ("string", "(str, unicode)", "attributes[\"" + attributeName + "\"]"),
"int": ("integer", "(int, long)", "attributes[\"" + attributeName + "\"]"),
"bool": ("bool", "bool", "attributes[\"" + attributeName + "\"]"),
"datetime": ("datetime.datetime", "(str, unicode)", "self._parseDatetime(attributes[\"" + attributeName + "\"])"),
}
attributeDocType, attributeAssertType, attributeValue = types[attributeType]
fileName = os.path.join("github", className + ".py")
with open(fileName) as f:
lines = list(f)
newLines = []
i = 0
added = False
isProperty = False
while not added:
line = lines[i].rstrip()
i += 1
if line == " @property":
isProperty = True
if line.startswith(" def "):
if isProperty:
attrName = line[8:-7]
if attrName != "_identity" and attrName > attributeName:
newLines.append(" def " + attributeName + "(self):")
newLines.append(" \"\"\"")
newLines.append(" :type: " + attributeDocType)
newLines.append(" \"\"\"")
newLines.append(" self._completeIfNotSet(self._" + attributeName + ")")
newLines.append(" return self._NoneIfNotSet(self._" + attributeName + ")")
newLines.append("")
newLines.append(" @property")
added = True
isProperty = False
newLines.append(line)
added = False
inInit = False
while not added:
line = lines[i].rstrip()
i += 1
if line == " def _initAttributes(self):":
inInit = True
if inInit:
if line.endswith(" = github.GithubObject.NotSet"):
attrName = line[14:-29]
if attrName > attributeName:
newLines.append(" self._" + attributeName + " = github.GithubObject.NotSet")
added = True
newLines.append(line)
added = False
inUse = False
while not added:
line = lines[i].rstrip()
i += 1
if line == " def _useAttributes(self, attributes):":
inUse = True
if inUse:
if line.endswith(" in attributes: # pragma no branch"):
attrName = line[12:-36]
if attrName > attributeName:
newLines.append(" if \"" + attributeName + "\" in attributes: # pragma no branch")
newLines.append(" assert attributes[\"" + attributeName + "\"] is None or isinstance(attributes[\"" + attributeName + "\"], " + attributeAssertType + "), attributes[\"" + attributeName + "\"]")
newLines.append(" self._" + attributeName + " = " + attributeValue)
added = True
newLines.append(line)
while i < len(lines):
line = lines[i].rstrip()
i += 1
newLines.append(line)
with open(fileName, "wb") as f:
for line in newLines:
f.write(line + "\n")
+5 -2
View File
@@ -41,6 +41,9 @@ def parseReference():
undocumentedUrls = [
("/hooks", "GET"), # Mentioned somewhere
("/hub", "POST"), # Described in content/v3/repos/hooks.md
("/api/status.json", "GET"), # https://status.github.com/api
("/api/last-message.json", "GET"), # https://status.github.com/api
("/api/messages.json", "GET"), # https://status.github.com/api
]
uninterestingUrls = [
("/markdown/raw", "POST"), # Job is done by /markdown => useless in PyGithub
@@ -74,7 +77,7 @@ def parseReference():
urls[url] = docUrl
for url in undocumentedUrls:
urls[url] = "http://developer.github.com/"
urls[url] = None
for url in uninterestingUrls:
del urls[url]
@@ -112,7 +115,7 @@ def main():
printUrls("called by PyGithub but not existing in Github API v3", set(lib) - set(ref))
for key in set(lib) & set(ref):
(url, verb) = key
if lib[key] != ref[key]:
if ref[key] is not None and lib[key] != ref[key] and not lib[key].startswith(ref[key] + "/#"):
print "sed -i \"s@:calls: ." + verb + " " + url + " ." + lib[key] + ".._" + "@:calls: \\`" + verb + " " + url + " \\<" + ref[key] + "\\>\\`_@\" github/*.py"
+2
View File
@@ -132,6 +132,8 @@ def findHeadersAndFiles():
dirs.remove(".git")
if "developer.github.com" in dirs:
dirs.remove("developer.github.com")
if "build" in dirs:
dirs.remove("build")
for filename in files:
fullname = os.path.join(root, filename)