Merge branch 'develop'

This commit is contained in:
Vincent Jacques
2012-09-30 19:53:09 +02:00
441 changed files with 6598 additions and 6151 deletions
-2
View File
@@ -1,6 +1,4 @@
*.pyc
GithubCredentials.py
.coverage
/dist
/MANIFEST
/test/htmlcov/
+7
View File
@@ -0,0 +1,7 @@
language: python
python:
- "2.7"
- "2.6"
- "2.5"
install: if [ "$(python --version 2>&1)" == "Python 2.5.6" ]; then pip install -r python25-requirements.txt --use-mirrors; fi
script: python ./setup.py test
+23 -7
View File
@@ -11,14 +11,17 @@ PyGithub is stable. I will maintain it up to date with the API, and fix bugs if
What's new?
===========
[Version 1.7](https://github.com/jacquev6/PyGithub/issues?milestone=12&state=closed) (September 12th, 2012)
-----------------------------------------------------------------------------------------------------------
[![Build Status](https://secure.travis-ci.org/jacquev6/PyGithub.png)](http://travis-ci.org/jacquev6/PyGithub)
* Be able to clear the assignee and the milestone of an Issue. Thank you [quixotique](https://github.com/quixotique) for the merge request
* Fix an AssertionFailure in `Organization.get_xxx` when using Github Enterprise. Thank you [mnsanghvi](https://github.com/mnsanghvi) for pointing that
* Expose pagination to users needing it (`PaginatedList.get_page`). Thank you [kukuts](https://github.com/kukuts) for asking
* Improve handling of legacy search APIs
* Small refactoring (documentation, removal of old code generation artifacts)
[Version 1.8.0](https://github.com/jacquev6/PyGithub/issues?milestone=13&state=closed) (September 26th, 2012)
-------------------------------------------------------------------------------------------------------------
* Enable [Travis CI](http://travis-ci.org/#!/jacquev6/PyGithub)
* Fix error 500 when json payload contains percent character (`%`). Thank you again [quixotique](https://github.com/quixotique) for pointing that and reporting it to Github
* Enable debug logging. Logger name is `"github"`. Simple logging can be enabled by `github.enable_console_debug_logging()`. Thank you [quixotique](https://github.com/quixotique) for the merge request and the advice
* Publish tests in the PyPi source archive to ease QA tests of the [FreeBSD port](http://www.freshports.org/devel/py-pygithub/). Thank you [koobs](https://github.com/koobs) for maintaining this port
* Switch to [Semantic Versioning](http://semver.org/)
* Respect [pep8 Style Guide for Python Code](http://www.python.org/dev/peps/pep-0008/)
Previous versions
-----------------
@@ -74,3 +77,16 @@ Projects using PyGithub
* [Upverter](https://upverter.com) is a web-based schematic capture and PCB layout tool for people who design electronics. Designers can attach a Github project to an Upverter project.
* [Tratihubis](http://pypi.python.org/pypi/tratihubis/) converts Trac tickets to Github issues
* https://github.com/CMB/cligh
* https://github.com/natduca/quickopen uses PyGithub to automaticaly create issues
* https://gist.github.com/3433798
* https://github.com/zsiciarz/aquila-dsp.org
* https://github.com/robcowie/virtualenvwrapper.github
They talk about PyGithub
========================
* http://stackoverflow.com/questions/10625190/most-suitable-python-library-for-github-api-v3
* http://stackoverflow.com/questions/12379637/django-social-auth-github-authentication
* http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/py-pygithub/
* http://oddshocks.com/blog/2012/08/02/developing-charsheet/
+10
View File
@@ -1,3 +1,13 @@
[Version 1.8.0](https://github.com/jacquev6/PyGithub/issues?milestone=13&state=closed) (September 26th, 2012)
-------------------------------------------------------------------------------------------------------------
* Enable [Travis CI](http://travis-ci.org/#!/jacquev6/PyGithub)
* Fix error 500 when json payload contains percent character (`%`). Thank you again [quixotique](https://github.com/quixotique) for pointing that and reporting it to Github
* Enable debug logging. Logger name is `"github"`. Simple logging can be enabled by `github.enable_console_debug_logging()`. Thank you [quixotique](https://github.com/quixotique) for the merge request and the advice
* Publish tests in the PyPi source archive to ease QA tests of the [FreeBSD port](http://www.freshports.org/devel/py-pygithub/). Thank you [koobs](https://github.com/koobs) for maintaining this port
* Switch to [Semantic Versioning](http://semver.org/)
* Respect [pep8 Style Guide for Python Code](http://www.python.org/dev/peps/pep-0008/)
[Version 1.7](https://github.com/jacquev6/PyGithub/issues?milestone=12&state=closed) (September 12th, 2012)
===========================================================================================================
+268 -267
View File
@@ -25,134 +25,135 @@ import Issue
import Event
import Authorization
class AuthenticatedUser( GithubObject.GithubObject ):
class AuthenticatedUser(GithubObject.GithubObject):
@property
def avatar_url( self ):
self._completeIfNotSet( self._avatar_url )
return self._NoneIfNotSet( self._avatar_url )
def avatar_url(self):
self._completeIfNotSet(self._avatar_url)
return self._NoneIfNotSet(self._avatar_url)
@property
def bio( self ):
self._completeIfNotSet( self._bio )
return self._NoneIfNotSet( self._bio )
def bio(self):
self._completeIfNotSet(self._bio)
return self._NoneIfNotSet(self._bio)
@property
def blog( self ):
self._completeIfNotSet( self._blog )
return self._NoneIfNotSet( self._blog )
def blog(self):
self._completeIfNotSet(self._blog)
return self._NoneIfNotSet(self._blog)
@property
def collaborators( self ):
self._completeIfNotSet( self._collaborators )
return self._NoneIfNotSet( self._collaborators )
def collaborators(self):
self._completeIfNotSet(self._collaborators)
return self._NoneIfNotSet(self._collaborators)
@property
def company( self ):
self._completeIfNotSet( self._company )
return self._NoneIfNotSet( self._company )
def company(self):
self._completeIfNotSet(self._company)
return self._NoneIfNotSet(self._company)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def disk_usage( self ):
self._completeIfNotSet( self._disk_usage )
return self._NoneIfNotSet( self._disk_usage )
def disk_usage(self):
self._completeIfNotSet(self._disk_usage)
return self._NoneIfNotSet(self._disk_usage)
@property
def email( self ):
self._completeIfNotSet( self._email )
return self._NoneIfNotSet( self._email )
def email(self):
self._completeIfNotSet(self._email)
return self._NoneIfNotSet(self._email)
@property
def followers( self ):
self._completeIfNotSet( self._followers )
return self._NoneIfNotSet( self._followers )
def followers(self):
self._completeIfNotSet(self._followers)
return self._NoneIfNotSet(self._followers)
@property
def following( self ):
self._completeIfNotSet( self._following )
return self._NoneIfNotSet( self._following )
def following(self):
self._completeIfNotSet(self._following)
return self._NoneIfNotSet(self._following)
@property
def gravatar_id( self ):
self._completeIfNotSet( self._gravatar_id )
return self._NoneIfNotSet( self._gravatar_id )
def gravatar_id(self):
self._completeIfNotSet(self._gravatar_id)
return self._NoneIfNotSet(self._gravatar_id)
@property
def hireable( self ):
self._completeIfNotSet( self._hireable )
return self._NoneIfNotSet( self._hireable )
def hireable(self):
self._completeIfNotSet(self._hireable)
return self._NoneIfNotSet(self._hireable)
@property
def html_url( self ):
self._completeIfNotSet( self._html_url )
return self._NoneIfNotSet( self._html_url )
def html_url(self):
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def location( self ):
self._completeIfNotSet( self._location )
return self._NoneIfNotSet( self._location )
def location(self):
self._completeIfNotSet(self._location)
return self._NoneIfNotSet(self._location)
@property
def login( self ):
self._completeIfNotSet( self._login )
return self._NoneIfNotSet( self._login )
def login(self):
self._completeIfNotSet(self._login)
return self._NoneIfNotSet(self._login)
@property
def name( self ):
self._completeIfNotSet( self._name )
return self._NoneIfNotSet( self._name )
def name(self):
self._completeIfNotSet(self._name)
return self._NoneIfNotSet(self._name)
@property
def owned_private_repos( self ):
self._completeIfNotSet( self._owned_private_repos )
return self._NoneIfNotSet( self._owned_private_repos )
def owned_private_repos(self):
self._completeIfNotSet(self._owned_private_repos)
return self._NoneIfNotSet(self._owned_private_repos)
@property
def plan( self ):
self._completeIfNotSet( self._plan )
return self._NoneIfNotSet( self._plan )
def plan(self):
self._completeIfNotSet(self._plan)
return self._NoneIfNotSet(self._plan)
@property
def private_gists( self ):
self._completeIfNotSet( self._private_gists )
return self._NoneIfNotSet( self._private_gists )
def private_gists(self):
self._completeIfNotSet(self._private_gists)
return self._NoneIfNotSet(self._private_gists)
@property
def public_gists( self ):
self._completeIfNotSet( self._public_gists )
return self._NoneIfNotSet( self._public_gists )
def public_gists(self):
self._completeIfNotSet(self._public_gists)
return self._NoneIfNotSet(self._public_gists)
@property
def public_repos( self ):
self._completeIfNotSet( self._public_repos )
return self._NoneIfNotSet( self._public_repos )
def public_repos(self):
self._completeIfNotSet(self._public_repos)
return self._NoneIfNotSet(self._public_repos)
@property
def total_private_repos( self ):
self._completeIfNotSet( self._total_private_repos )
return self._NoneIfNotSet( self._total_private_repos )
def total_private_repos(self):
self._completeIfNotSet(self._total_private_repos)
return self._NoneIfNotSet(self._total_private_repos)
@property
def type( self ):
self._completeIfNotSet( self._type )
return self._NoneIfNotSet( self._type )
def type(self):
self._completeIfNotSet(self._type)
return self._NoneIfNotSet(self._type)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def add_to_emails( self, *emails ):
assert all( isinstance( element, ( str, unicode ) ) for element in emails ), emails
def add_to_emails(self, *emails):
assert all(isinstance(element, (str, unicode)) for element in emails), emails
post_parameters = emails
headers, data = self._requester.requestAndCheck(
"POST",
@@ -161,8 +162,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
post_parameters
)
def add_to_following( self, following ):
assert isinstance( following, NamedUser.NamedUser ), following
def add_to_following(self, following):
assert isinstance(following, NamedUser.NamedUser), following
headers, data = self._requester.requestAndCheck(
"PUT",
"/user/following/" + following._identity,
@@ -170,8 +171,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def add_to_starred( self, starred ):
assert isinstance( starred, Repository.Repository ), starred
def add_to_starred(self, starred):
assert isinstance(starred, Repository.Repository), starred
headers, data = self._requester.requestAndCheck(
"PUT",
"/user/starred/" + starred._identity,
@@ -179,8 +180,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def add_to_subscriptions( self, subscription ):
assert isinstance( subscription, Repository.Repository ), subscription
def add_to_subscriptions(self, subscription):
assert isinstance(subscription, Repository.Repository), subscription
headers, data = self._requester.requestAndCheck(
"PUT",
"/user/subscriptions/" + subscription._identity,
@@ -188,8 +189,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def add_to_watched( self, watched ):
assert isinstance( watched, Repository.Repository ), watched
def add_to_watched(self, watched):
assert isinstance(watched, Repository.Repository), watched
headers, data = self._requester.requestAndCheck(
"PUT",
"/user/watched/" + watched._identity,
@@ -197,56 +198,56 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def create_authorization( self, scopes = GithubObject.NotSet, note = GithubObject.NotSet, note_url = GithubObject.NotSet ):
assert scopes is GithubObject.NotSet or all( isinstance( element, ( str, unicode ) ) for element in scopes ), scopes
assert note is GithubObject.NotSet or isinstance( note, ( str, unicode ) ), note
assert note_url is GithubObject.NotSet or isinstance( note_url, ( str, unicode ) ), note_url
def create_authorization(self, scopes=GithubObject.NotSet, note=GithubObject.NotSet, note_url=GithubObject.NotSet):
assert scopes is GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in scopes), scopes
assert note is GithubObject.NotSet or isinstance(note, (str, unicode)), note
assert note_url is GithubObject.NotSet or isinstance(note_url, (str, unicode)), note_url
post_parameters = dict()
if scopes is not GithubObject.NotSet:
post_parameters[ "scopes" ] = scopes
post_parameters["scopes"] = scopes
if note is not GithubObject.NotSet:
post_parameters[ "note" ] = note
post_parameters["note"] = note
if note_url is not GithubObject.NotSet:
post_parameters[ "note_url" ] = note_url
post_parameters["note_url"] = note_url
headers, data = self._requester.requestAndCheck(
"POST",
"/authorizations",
None,
post_parameters
)
return Authorization.Authorization( self._requester, data, completed = True )
return Authorization.Authorization(self._requester, data, completed=True)
def create_fork( self, repo ):
assert isinstance( repo, Repository.Repository ), repo
def create_fork(self, repo):
assert isinstance(repo, Repository.Repository), repo
headers, data = self._requester.requestAndCheck(
"POST",
"/repos/" + repo.owner.login + "/" + repo.name + "/forks",
None,
None
)
return Repository.Repository( self._requester, data, completed = True )
return Repository.Repository(self._requester, data, completed=True)
def create_gist( self, public, files, description = GithubObject.NotSet ):
assert isinstance( public, bool ), public
assert all( isinstance( element, InputFileContent.InputFileContent ) for element in files.itervalues() ), files
assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description
def create_gist(self, public, files, description=GithubObject.NotSet):
assert isinstance(public, bool), public
assert all(isinstance(element, InputFileContent.InputFileContent) for element in files.itervalues()), files
assert description is GithubObject.NotSet or isinstance(description, (str, unicode)), description
post_parameters = {
"public": public,
"files": dict( ( key, value._identity ) for key, value in files.iteritems() ),
"files": dict((key, value._identity) for key, value in files.iteritems()),
}
if description is not GithubObject.NotSet:
post_parameters[ "description" ] = description
post_parameters["description"] = description
headers, data = self._requester.requestAndCheck(
"POST",
"/gists",
None,
post_parameters
)
return Gist.Gist( self._requester, data, completed = True )
return Gist.Gist(self._requester, data, completed=True)
def create_key( self, title, key ):
assert isinstance( title, ( str, unicode ) ), title
assert isinstance( key, ( str, unicode ) ), key
def create_key(self, title, key):
assert isinstance(title, (str, unicode)), title
assert isinstance(key, (str, unicode)), key
post_parameters = {
"title": title,
"key": key,
@@ -257,81 +258,81 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None,
post_parameters
)
return UserKey.UserKey( self._requester, data, completed = True )
return UserKey.UserKey(self._requester, data, completed=True)
def create_repo( self, name, description = GithubObject.NotSet, homepage = GithubObject.NotSet, private = GithubObject.NotSet, has_issues = GithubObject.NotSet, has_wiki = GithubObject.NotSet, has_downloads = GithubObject.NotSet ):
assert isinstance( name, ( str, unicode ) ), name
assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description
assert homepage is GithubObject.NotSet or isinstance( homepage, ( str, unicode ) ), homepage
assert private is GithubObject.NotSet or isinstance( private, bool ), private
assert has_issues is GithubObject.NotSet or isinstance( has_issues, bool ), has_issues
assert has_wiki is GithubObject.NotSet or isinstance( has_wiki, bool ), has_wiki
assert has_downloads is GithubObject.NotSet or isinstance( has_downloads, bool ), has_downloads
def create_repo(self, name, description=GithubObject.NotSet, homepage=GithubObject.NotSet, private=GithubObject.NotSet, has_issues=GithubObject.NotSet, has_wiki=GithubObject.NotSet, has_downloads=GithubObject.NotSet):
assert isinstance(name, (str, unicode)), name
assert description is GithubObject.NotSet or isinstance(description, (str, unicode)), description
assert homepage is GithubObject.NotSet or isinstance(homepage, (str, unicode)), homepage
assert private is GithubObject.NotSet or isinstance(private, bool), private
assert has_issues is GithubObject.NotSet or isinstance(has_issues, bool), has_issues
assert has_wiki is GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki
assert has_downloads is GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads
post_parameters = {
"name": name,
}
if description is not GithubObject.NotSet:
post_parameters[ "description" ] = description
post_parameters["description"] = description
if homepage is not GithubObject.NotSet:
post_parameters[ "homepage" ] = homepage
post_parameters["homepage"] = homepage
if private is not GithubObject.NotSet:
post_parameters[ "private" ] = private
post_parameters["private"] = private
if has_issues is not GithubObject.NotSet:
post_parameters[ "has_issues" ] = has_issues
post_parameters["has_issues"] = has_issues
if has_wiki is not GithubObject.NotSet:
post_parameters[ "has_wiki" ] = has_wiki
post_parameters["has_wiki"] = has_wiki
if has_downloads is not GithubObject.NotSet:
post_parameters[ "has_downloads" ] = has_downloads
post_parameters["has_downloads"] = has_downloads
headers, data = self._requester.requestAndCheck(
"POST",
"/user/repos",
None,
post_parameters
)
return Repository.Repository( self._requester, data, completed = True )
return Repository.Repository(self._requester, data, completed=True)
def edit( self, name = GithubObject.NotSet, email = GithubObject.NotSet, blog = GithubObject.NotSet, company = GithubObject.NotSet, location = GithubObject.NotSet, hireable = GithubObject.NotSet, bio = GithubObject.NotSet ):
assert name is GithubObject.NotSet or isinstance( name, ( str, unicode ) ), name
assert email is GithubObject.NotSet or isinstance( email, ( str, unicode ) ), email
assert blog is GithubObject.NotSet or isinstance( blog, ( str, unicode ) ), blog
assert company is GithubObject.NotSet or isinstance( company, ( str, unicode ) ), company
assert location is GithubObject.NotSet or isinstance( location, ( str, unicode ) ), location
assert hireable is GithubObject.NotSet or isinstance( hireable, bool ), hireable
assert bio is GithubObject.NotSet or isinstance( bio, ( str, unicode ) ), bio
def edit(self, name=GithubObject.NotSet, email=GithubObject.NotSet, blog=GithubObject.NotSet, company=GithubObject.NotSet, location=GithubObject.NotSet, hireable=GithubObject.NotSet, bio=GithubObject.NotSet):
assert name is GithubObject.NotSet or isinstance(name, (str, unicode)), name
assert email is GithubObject.NotSet or isinstance(email, (str, unicode)), email
assert blog is GithubObject.NotSet or isinstance(blog, (str, unicode)), blog
assert company is GithubObject.NotSet or isinstance(company, (str, unicode)), company
assert location is GithubObject.NotSet or isinstance(location, (str, unicode)), location
assert hireable is GithubObject.NotSet or isinstance(hireable, bool), hireable
assert bio is GithubObject.NotSet or isinstance(bio, (str, unicode)), bio
post_parameters = dict()
if name is not GithubObject.NotSet:
post_parameters[ "name" ] = name
post_parameters["name"] = name
if email is not GithubObject.NotSet:
post_parameters[ "email" ] = email
post_parameters["email"] = email
if blog is not GithubObject.NotSet:
post_parameters[ "blog" ] = blog
post_parameters["blog"] = blog
if company is not GithubObject.NotSet:
post_parameters[ "company" ] = company
post_parameters["company"] = company
if location is not GithubObject.NotSet:
post_parameters[ "location" ] = location
post_parameters["location"] = location
if hireable is not GithubObject.NotSet:
post_parameters[ "hireable" ] = hireable
post_parameters["hireable"] = hireable
if bio is not GithubObject.NotSet:
post_parameters[ "bio" ] = bio
post_parameters["bio"] = bio
headers, data = self._requester.requestAndCheck(
"PATCH",
"/user",
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def get_authorization( self, id ):
assert isinstance( id, int ), id
def get_authorization(self, id):
assert isinstance(id, int), id
headers, data = self._requester.requestAndCheck(
"GET",
"/authorizations/" + str( id ),
"/authorizations/" + str(id),
None,
None
)
return Authorization.Authorization( self._requester, data, completed = True )
return Authorization.Authorization(self._requester, data, completed=True)
def get_authorizations( self ):
def get_authorizations(self):
return PaginatedList.PaginatedList(
Authorization.Authorization,
self._requester,
@@ -339,7 +340,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def get_emails( self ):
def get_emails(self):
headers, data = self._requester.requestAndCheck(
"GET",
"/user/emails",
@@ -348,7 +349,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
)
return data
def get_events( self ):
def get_events(self):
return PaginatedList.PaginatedList(
Event.Event,
self._requester,
@@ -356,7 +357,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def get_followers( self ):
def get_followers(self):
return PaginatedList.PaginatedList(
NamedUser.NamedUser,
self._requester,
@@ -364,7 +365,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def get_following( self ):
def get_following(self):
return PaginatedList.PaginatedList(
NamedUser.NamedUser,
self._requester,
@@ -372,7 +373,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def get_gists( self ):
def get_gists(self):
return PaginatedList.PaginatedList(
Gist.Gist,
self._requester,
@@ -380,7 +381,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def get_issues( self ):
def get_issues(self):
return PaginatedList.PaginatedList(
Issue.Issue,
self._requester,
@@ -388,17 +389,17 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def get_key( self, id ):
assert isinstance( id, int ), id
def get_key(self, id):
assert isinstance(id, int), id
headers, data = self._requester.requestAndCheck(
"GET",
"/user/keys/" + str( id ),
"/user/keys/" + str(id),
None,
None
)
return UserKey.UserKey( self._requester, data, completed = True )
return UserKey.UserKey(self._requester, data, completed=True)
def get_keys( self ):
def get_keys(self):
return PaginatedList.PaginatedList(
UserKey.UserKey,
self._requester,
@@ -406,8 +407,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def get_organization_events( self, org ):
assert isinstance( org, Organization.Organization ), org
def get_organization_events(self, org):
assert isinstance(org, Organization.Organization), org
return PaginatedList.PaginatedList(
Event.Event,
self._requester,
@@ -415,7 +416,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def get_orgs( self ):
def get_orgs(self):
return PaginatedList.PaginatedList(
Organization.Organization,
self._requester,
@@ -423,27 +424,27 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def get_repo( self, name ):
assert isinstance( name, ( str, unicode ) ), name
def get_repo(self, name):
assert isinstance(name, (str, unicode)), name
headers, data = self._requester.requestAndCheck(
"GET",
"/repos/" + self.login + "/" + name,
None,
None
)
return Repository.Repository( self._requester, data, completed = True )
return Repository.Repository(self._requester, data, completed=True)
def get_repos( self, type = GithubObject.NotSet, sort = GithubObject.NotSet, direction = GithubObject.NotSet ):
assert type is GithubObject.NotSet or isinstance( type, ( str, unicode ) ), type
assert sort is GithubObject.NotSet or isinstance( sort, ( str, unicode ) ), sort
assert direction is GithubObject.NotSet or isinstance( direction, ( str, unicode ) ), direction
def get_repos(self, type=GithubObject.NotSet, sort=GithubObject.NotSet, direction=GithubObject.NotSet):
assert type is GithubObject.NotSet or isinstance(type, (str, unicode)), type
assert sort is GithubObject.NotSet or isinstance(sort, (str, unicode)), sort
assert direction is GithubObject.NotSet or isinstance(direction, (str, unicode)), direction
url_parameters = dict()
if type is not GithubObject.NotSet:
url_parameters[ "type" ] = type
url_parameters["type"] = type
if sort is not GithubObject.NotSet:
url_parameters[ "sort" ] = sort
url_parameters["sort"] = sort
if direction is not GithubObject.NotSet:
url_parameters[ "direction" ] = direction
url_parameters["direction"] = direction
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
@@ -451,7 +452,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
url_parameters
)
def get_starred( self ):
def get_starred(self):
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
@@ -459,7 +460,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def get_starred_gists( self ):
def get_starred_gists(self):
return PaginatedList.PaginatedList(
Gist.Gist,
self._requester,
@@ -467,7 +468,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def get_subscriptions( self ):
def get_subscriptions(self):
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
@@ -475,7 +476,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def get_watched( self ):
def get_watched(self):
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
@@ -483,8 +484,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def has_in_following( self, following ):
assert isinstance( following, NamedUser.NamedUser ), following
def has_in_following(self, following):
assert isinstance(following, NamedUser.NamedUser), following
status, headers, data = self._requester.requestRaw(
"GET",
"/user/following/" + following._identity,
@@ -493,8 +494,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
)
return status == 204
def has_in_starred( self, starred ):
assert isinstance( starred, Repository.Repository ), starred
def has_in_starred(self, starred):
assert isinstance(starred, Repository.Repository), starred
status, headers, data = self._requester.requestRaw(
"GET",
"/user/starred/" + starred._identity,
@@ -503,8 +504,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
)
return status == 204
def has_in_subscriptions( self, subscription ):
assert isinstance( subscription, Repository.Repository ), subscription
def has_in_subscriptions(self, subscription):
assert isinstance(subscription, Repository.Repository), subscription
status, headers, data = self._requester.requestRaw(
"GET",
"/user/subscriptions/" + subscription._identity,
@@ -513,8 +514,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
)
return status == 204
def has_in_watched( self, watched ):
assert isinstance( watched, Repository.Repository ), watched
def has_in_watched(self, watched):
assert isinstance(watched, Repository.Repository), watched
status, headers, data = self._requester.requestRaw(
"GET",
"/user/watched/" + watched._identity,
@@ -523,8 +524,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
)
return status == 204
def remove_from_emails( self, *emails ):
assert all( isinstance( element, ( str, unicode ) ) for element in emails ), emails
def remove_from_emails(self, *emails):
assert all(isinstance(element, (str, unicode)) for element in emails), emails
post_parameters = emails
headers, data = self._requester.requestAndCheck(
"DELETE",
@@ -533,8 +534,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
post_parameters
)
def remove_from_following( self, following ):
assert isinstance( following, NamedUser.NamedUser ), following
def remove_from_following(self, following):
assert isinstance(following, NamedUser.NamedUser), following
headers, data = self._requester.requestAndCheck(
"DELETE",
"/user/following/" + following._identity,
@@ -542,8 +543,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def remove_from_starred( self, starred ):
assert isinstance( starred, Repository.Repository ), starred
def remove_from_starred(self, starred):
assert isinstance(starred, Repository.Repository), starred
headers, data = self._requester.requestAndCheck(
"DELETE",
"/user/starred/" + starred._identity,
@@ -551,8 +552,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def remove_from_subscriptions( self, subscription ):
assert isinstance( subscription, Repository.Repository ), subscription
def remove_from_subscriptions(self, subscription):
assert isinstance(subscription, Repository.Repository), subscription
headers, data = self._requester.requestAndCheck(
"DELETE",
"/user/subscriptions/" + subscription._identity,
@@ -560,8 +561,8 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def remove_from_watched( self, watched ):
assert isinstance( watched, Repository.Repository ), watched
def remove_from_watched(self, watched):
assert isinstance(watched, Repository.Repository), watched
headers, data = self._requester.requestAndCheck(
"DELETE",
"/user/watched/" + watched._identity,
@@ -569,7 +570,7 @@ class AuthenticatedUser( GithubObject.GithubObject ):
None
)
def _initAttributes( self ):
def _initAttributes(self):
self._avatar_url = GithubObject.NotSet
self._bio = GithubObject.NotSet
self._blog = GithubObject.NotSet
@@ -596,79 +597,79 @@ class AuthenticatedUser( GithubObject.GithubObject ):
self._type = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "avatar_url" in attributes: # pragma no branch
assert attributes[ "avatar_url" ] is None or isinstance( attributes[ "avatar_url" ], ( str, unicode ) ), attributes[ "avatar_url" ]
self._avatar_url = attributes[ "avatar_url" ]
if "bio" in attributes: # pragma no branch
assert attributes[ "bio" ] is None or isinstance( attributes[ "bio" ], ( str, unicode ) ), attributes[ "bio" ]
self._bio = attributes[ "bio" ]
if "blog" in attributes: # pragma no branch
assert attributes[ "blog" ] is None or isinstance( attributes[ "blog" ], ( str, unicode ) ), attributes[ "blog" ]
self._blog = attributes[ "blog" ]
if "collaborators" in attributes: # pragma no branch
assert attributes[ "collaborators" ] is None or isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ]
self._collaborators = attributes[ "collaborators" ]
if "company" in attributes: # pragma no branch
assert attributes[ "company" ] is None or isinstance( attributes[ "company" ], ( str, unicode ) ), attributes[ "company" ]
self._company = attributes[ "company" ]
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 "disk_usage" in attributes: # pragma no branch
assert attributes[ "disk_usage" ] is None or isinstance( attributes[ "disk_usage" ], int ), attributes[ "disk_usage" ]
self._disk_usage = attributes[ "disk_usage" ]
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 "followers" in attributes: # pragma no branch
assert attributes[ "followers" ] is None or isinstance( attributes[ "followers" ], int ), attributes[ "followers" ]
self._followers = attributes[ "followers" ]
if "following" in attributes: # pragma no branch
assert attributes[ "following" ] is None or isinstance( attributes[ "following" ], int ), attributes[ "following" ]
self._following = attributes[ "following" ]
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" ]
if "hireable" in attributes: # pragma no branch
assert attributes[ "hireable" ] is None or isinstance( attributes[ "hireable" ], bool ), attributes[ "hireable" ]
self._hireable = attributes[ "hireable" ]
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" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "location" in attributes: # pragma no branch
assert attributes[ "location" ] is None or isinstance( attributes[ "location" ], ( str, unicode ) ), attributes[ "location" ]
self._location = attributes[ "location" ]
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 "name" in attributes: # pragma no branch
assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ]
self._name = attributes[ "name" ]
if "owned_private_repos" in attributes: # pragma no branch
assert attributes[ "owned_private_repos" ] is None or isinstance( attributes[ "owned_private_repos" ], int ), 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 Plan.Plan( self._requester, attributes[ "plan" ], completed = False )
if "private_gists" in attributes: # pragma no branch
assert attributes[ "private_gists" ] is None or isinstance( attributes[ "private_gists" ], int ), 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 ), attributes[ "public_gists" ]
self._public_gists = attributes[ "public_gists" ]
if "public_repos" in attributes: # pragma no branch
assert attributes[ "public_repos" ] is None or isinstance( attributes[ "public_repos" ], int ), attributes[ "public_repos" ]
self._public_repos = attributes[ "public_repos" ]
if "total_private_repos" in attributes: # pragma no branch
assert attributes[ "total_private_repos" ] is None or isinstance( attributes[ "total_private_repos" ], int ), 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 "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
def _useAttributes(self, attributes):
if "avatar_url" in attributes: # pragma no branch
assert attributes["avatar_url"] is None or isinstance(attributes["avatar_url"], (str, unicode)), attributes["avatar_url"]
self._avatar_url = attributes["avatar_url"]
if "bio" in attributes: # pragma no branch
assert attributes["bio"] is None or isinstance(attributes["bio"], (str, unicode)), attributes["bio"]
self._bio = attributes["bio"]
if "blog" in attributes: # pragma no branch
assert attributes["blog"] is None or isinstance(attributes["blog"], (str, unicode)), attributes["blog"]
self._blog = attributes["blog"]
if "collaborators" in attributes: # pragma no branch
assert attributes["collaborators"] is None or isinstance(attributes["collaborators"], int), attributes["collaborators"]
self._collaborators = attributes["collaborators"]
if "company" in attributes: # pragma no branch
assert attributes["company"] is None or isinstance(attributes["company"], (str, unicode)), attributes["company"]
self._company = attributes["company"]
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 "disk_usage" in attributes: # pragma no branch
assert attributes["disk_usage"] is None or isinstance(attributes["disk_usage"], int), attributes["disk_usage"]
self._disk_usage = attributes["disk_usage"]
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 "followers" in attributes: # pragma no branch
assert attributes["followers"] is None or isinstance(attributes["followers"], int), attributes["followers"]
self._followers = attributes["followers"]
if "following" in attributes: # pragma no branch
assert attributes["following"] is None or isinstance(attributes["following"], int), attributes["following"]
self._following = attributes["following"]
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"]
if "hireable" in attributes: # pragma no branch
assert attributes["hireable"] is None or isinstance(attributes["hireable"], bool), attributes["hireable"]
self._hireable = attributes["hireable"]
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"], int), attributes["id"]
self._id = attributes["id"]
if "location" in attributes: # pragma no branch
assert attributes["location"] is None or isinstance(attributes["location"], (str, unicode)), attributes["location"]
self._location = attributes["location"]
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 "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
if "owned_private_repos" in attributes: # pragma no branch
assert attributes["owned_private_repos"] is None or isinstance(attributes["owned_private_repos"], int), 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 Plan.Plan(self._requester, attributes["plan"], completed=False)
if "private_gists" in attributes: # pragma no branch
assert attributes["private_gists"] is None or isinstance(attributes["private_gists"], int), 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), attributes["public_gists"]
self._public_gists = attributes["public_gists"]
if "public_repos" in attributes: # pragma no branch
assert attributes["public_repos"] is None or isinstance(attributes["public_repos"], int), attributes["public_repos"]
self._public_repos = attributes["public_repos"]
if "total_private_repos" in attributes: # pragma no branch
assert attributes["total_private_repos"] is None or isinstance(attributes["total_private_repos"], int), 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 "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+71 -70
View File
@@ -15,53 +15,54 @@ import GithubObject
import AuthorizationApplication
class Authorization( GithubObject.GithubObject ):
class Authorization(GithubObject.GithubObject):
@property
def app( self ):
self._completeIfNotSet( self._app )
return self._NoneIfNotSet( self._app )
def app(self):
self._completeIfNotSet(self._app)
return self._NoneIfNotSet(self._app)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def note( self ):
self._completeIfNotSet( self._note )
return self._NoneIfNotSet( self._note )
def note(self):
self._completeIfNotSet(self._note)
return self._NoneIfNotSet(self._note)
@property
def note_url( self ):
self._completeIfNotSet( self._note_url )
return self._NoneIfNotSet( self._note_url )
def note_url(self):
self._completeIfNotSet(self._note_url)
return self._NoneIfNotSet(self._note_url)
@property
def scopes( self ):
self._completeIfNotSet( self._scopes )
return self._NoneIfNotSet( self._scopes )
def scopes(self):
self._completeIfNotSet(self._scopes)
return self._NoneIfNotSet(self._scopes)
@property
def token( self ):
self._completeIfNotSet( self._token )
return self._NoneIfNotSet( self._token )
def token(self):
self._completeIfNotSet(self._token)
return self._NoneIfNotSet(self._token)
@property
def updated_at( self ):
self._completeIfNotSet( self._updated_at )
return self._NoneIfNotSet( self._updated_at )
def updated_at(self):
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -69,32 +70,32 @@ class Authorization( GithubObject.GithubObject ):
None
)
def edit( self, scopes = GithubObject.NotSet, add_scopes = GithubObject.NotSet, remove_scopes = GithubObject.NotSet, note = GithubObject.NotSet, note_url = GithubObject.NotSet ):
assert scopes is GithubObject.NotSet or all( isinstance( element, ( str, unicode ) ) for element in scopes ), scopes
assert add_scopes is GithubObject.NotSet or all( isinstance( element, ( str, unicode ) ) for element in add_scopes ), add_scopes
assert remove_scopes is GithubObject.NotSet or all( isinstance( element, ( str, unicode ) ) for element in remove_scopes ), remove_scopes
assert note is GithubObject.NotSet or isinstance( note, ( str, unicode ) ), note
assert note_url is GithubObject.NotSet or isinstance( note_url, ( str, unicode ) ), note_url
def edit(self, scopes=GithubObject.NotSet, add_scopes=GithubObject.NotSet, remove_scopes=GithubObject.NotSet, note=GithubObject.NotSet, note_url=GithubObject.NotSet):
assert scopes is GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in scopes), scopes
assert add_scopes is GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in add_scopes), add_scopes
assert remove_scopes is GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in remove_scopes), remove_scopes
assert note is GithubObject.NotSet or isinstance(note, (str, unicode)), note
assert note_url is GithubObject.NotSet or isinstance(note_url, (str, unicode)), note_url
post_parameters = dict()
if scopes is not GithubObject.NotSet:
post_parameters[ "scopes" ] = scopes
post_parameters["scopes"] = scopes
if add_scopes is not GithubObject.NotSet:
post_parameters[ "add_scopes" ] = add_scopes
post_parameters["add_scopes"] = add_scopes
if remove_scopes is not GithubObject.NotSet:
post_parameters[ "remove_scopes" ] = remove_scopes
post_parameters["remove_scopes"] = remove_scopes
if note is not GithubObject.NotSet:
post_parameters[ "note" ] = note
post_parameters["note"] = note
if note_url is not GithubObject.NotSet:
post_parameters[ "note_url" ] = note_url
post_parameters["note_url"] = note_url
headers, data = self._requester.requestAndCheck(
"PATCH",
self.url,
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def _initAttributes( self ):
def _initAttributes(self):
self._app = GithubObject.NotSet
self._created_at = GithubObject.NotSet
self._id = GithubObject.NotSet
@@ -105,31 +106,31 @@ class Authorization( GithubObject.GithubObject ):
self._updated_at = GithubObject.NotSet
self._url = GithubObject.NotSet
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 AuthorizationApplication.AuthorizationApplication( self._requester, 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" ] )
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "note" in attributes: # pragma no branch
assert attributes[ "note" ] is None or isinstance( attributes[ "note" ], ( str, unicode ) ), attributes[ "note" ]
self._note = attributes[ "note" ]
if "note_url" in attributes: # pragma no branch
assert attributes[ "note_url" ] is None or isinstance( attributes[ "note_url" ], ( str, unicode ) ), attributes[ "note_url" ]
self._note_url = attributes[ "note_url" ]
if "scopes" in attributes: # pragma no branch
assert attributes[ "scopes" ] is None or all( isinstance( element, ( str, unicode ) ) for element in attributes[ "scopes" ] ), attributes[ "scopes" ]
self._scopes = attributes[ "scopes" ]
if "token" in attributes: # pragma no branch
assert attributes[ "token" ] is None or isinstance( attributes[ "token" ], ( str, unicode ) ), attributes[ "token" ]
self._token = attributes[ "token" ]
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" ]
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 AuthorizationApplication.AuthorizationApplication(self._requester, 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"])
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], int), attributes["id"]
self._id = attributes["id"]
if "note" in attributes: # pragma no branch
assert attributes["note"] is None or isinstance(attributes["note"], (str, unicode)), attributes["note"]
self._note = attributes["note"]
if "note_url" in attributes: # pragma no branch
assert attributes["note_url"] is None or isinstance(attributes["note_url"], (str, unicode)), attributes["note_url"]
self._note_url = attributes["note_url"]
if "scopes" in attributes: # pragma no branch
assert attributes["scopes"] is None or all(isinstance(element, (str, unicode)) for element in attributes["scopes"]), attributes["scopes"]
self._scopes = attributes["scopes"]
if "token" in attributes: # pragma no branch
assert attributes["token"] is None or isinstance(attributes["token"], (str, unicode)), attributes["token"]
self._token = attributes["token"]
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 -15
View File
@@ -13,25 +13,26 @@
import GithubObject
class AuthorizationApplication( GithubObject.GithubObject ):
class AuthorizationApplication(GithubObject.GithubObject):
@property
def name( self ):
self._completeIfNotSet( self._name )
return self._NoneIfNotSet( self._name )
def name(self):
self._completeIfNotSet(self._name)
return self._NoneIfNotSet(self._name)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def _initAttributes( self ):
def _initAttributes(self):
self._name = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
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 "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
def _useAttributes(self, attributes):
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 "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+14 -13
View File
@@ -15,23 +15,24 @@ import GithubObject
import Commit
class Branch( GithubObject.BasicGithubObject ):
class Branch(GithubObject.BasicGithubObject):
@property
def commit( self ):
return self._NoneIfNotSet( self._commit )
def commit(self):
return self._NoneIfNotSet(self._commit)
@property
def name( self ):
return self._NoneIfNotSet( self._name )
def name(self):
return self._NoneIfNotSet(self._name)
def _initAttributes( self ):
def _initAttributes(self):
self._commit = GithubObject.NotSet
self._name = GithubObject.NotSet
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 Commit.Commit( self._requester, 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" ]
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 Commit.Commit(self._requester, 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"]
+77 -76
View File
@@ -22,89 +22,90 @@ import CommitStats
import Commit
import CommitComment
class Commit( GithubObject.GithubObject ):
class Commit(GithubObject.GithubObject):
@property
def author( self ):
self._completeIfNotSet( self._author )
return self._NoneIfNotSet( self._author )
def author(self):
self._completeIfNotSet(self._author)
return self._NoneIfNotSet(self._author)
@property
def commit( self ):
self._completeIfNotSet( self._commit )
return self._NoneIfNotSet( self._commit )
def commit(self):
self._completeIfNotSet(self._commit)
return self._NoneIfNotSet(self._commit)
@property
def committer( self ):
self._completeIfNotSet( self._committer )
return self._NoneIfNotSet( self._committer )
def committer(self):
self._completeIfNotSet(self._committer)
return self._NoneIfNotSet(self._committer)
@property
def files( self ):
self._completeIfNotSet( self._files )
return self._NoneIfNotSet( self._files )
def files(self):
self._completeIfNotSet(self._files)
return self._NoneIfNotSet(self._files)
@property
def parents( self ):
self._completeIfNotSet( self._parents )
return self._NoneIfNotSet( self._parents )
def parents(self):
self._completeIfNotSet(self._parents)
return self._NoneIfNotSet(self._parents)
@property
def sha( self ):
self._completeIfNotSet( self._sha )
return self._NoneIfNotSet( self._sha )
def sha(self):
self._completeIfNotSet(self._sha)
return self._NoneIfNotSet(self._sha)
@property
def stats( self ):
self._completeIfNotSet( self._stats )
return self._NoneIfNotSet( self._stats )
def stats(self):
self._completeIfNotSet(self._stats)
return self._NoneIfNotSet(self._stats)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def create_comment( self, body, line = GithubObject.NotSet, path = GithubObject.NotSet, position = GithubObject.NotSet ):
assert isinstance( body, ( str, unicode ) ), body
assert line is GithubObject.NotSet or isinstance( line, int ), line
assert path is GithubObject.NotSet or isinstance( path, ( str, unicode ) ), path
assert position is GithubObject.NotSet or isinstance( position, int ), position
def create_comment(self, body, line=GithubObject.NotSet, path=GithubObject.NotSet, position=GithubObject.NotSet):
assert isinstance(body, (str, unicode)), body
assert line is GithubObject.NotSet or isinstance(line, int), line
assert path is GithubObject.NotSet or isinstance(path, (str, unicode)), path
assert position is GithubObject.NotSet or isinstance(position, int), position
post_parameters = {
"body": body,
}
if line is not GithubObject.NotSet:
post_parameters[ "line" ] = line
post_parameters["line"] = line
if path is not GithubObject.NotSet:
post_parameters[ "path" ] = path
post_parameters["path"] = path
if position is not GithubObject.NotSet:
post_parameters[ "position" ] = position
post_parameters["position"] = position
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/comments",
None,
post_parameters
)
return CommitComment.CommitComment( self._requester, data, completed = True )
return CommitComment.CommitComment(self._requester, data, completed=True)
def create_status( self, state, target_url = GithubObject.NotSet, description = GithubObject.NotSet ):
assert isinstance( state, ( str, unicode ) ), state
assert target_url is GithubObject.NotSet or isinstance( target_url, ( str, unicode ) ), target_url
assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description
def create_status(self, state, target_url=GithubObject.NotSet, description=GithubObject.NotSet):
assert isinstance(state, (str, unicode)), state
assert target_url is GithubObject.NotSet or isinstance(target_url, (str, unicode)), target_url
assert description is GithubObject.NotSet or isinstance(description, (str, unicode)), description
post_parameters = {
"state": state,
}
if target_url is not GithubObject.NotSet:
post_parameters[ "target_url" ] = target_url
post_parameters["target_url"] = target_url
if description is not GithubObject.NotSet:
post_parameters[ "description" ] = description
post_parameters["description"] = description
headers, data = self._requester.requestAndCheck(
"POST",
self._parentUrl( self._parentUrl( self.url ) ) + "/statuses/" + self.sha,
self._parentUrl(self._parentUrl(self.url)) + "/statuses/" + self.sha,
None,
post_parameters
)
return CommitStatus.CommitStatus( self._requester, data, completed = True )
return CommitStatus.CommitStatus(self._requester, data, completed=True)
def get_comments( self ):
def get_comments(self):
return PaginatedList.PaginatedList(
CommitComment.CommitComment,
self._requester,
@@ -112,19 +113,19 @@ class Commit( GithubObject.GithubObject ):
None
)
def get_statuses( self ):
def get_statuses(self):
return PaginatedList.PaginatedList(
CommitStatus.CommitStatus,
self._requester,
self._parentUrl( self._parentUrl( self.url ) ) + "/statuses/" + self.sha,
self._parentUrl(self._parentUrl(self.url)) + "/statuses/" + self.sha,
None
)
@property
def _identity( self ):
def _identity(self):
return self.sha
def _initAttributes( self ):
def _initAttributes(self):
self._author = GithubObject.NotSet
self._commit = GithubObject.NotSet
self._committer = GithubObject.NotSet
@@ -134,34 +135,34 @@ class Commit( GithubObject.GithubObject ):
self._stats = GithubObject.NotSet
self._url = GithubObject.NotSet
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 NamedUser.NamedUser( self._requester, attributes[ "author" ], completed = False )
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 GitCommit.GitCommit( self._requester, 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 NamedUser.NamedUser( self._requester, 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 [
File.File( self._requester, element, completed = False )
for element in attributes[ "files" ]
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 NamedUser.NamedUser(self._requester, attributes["author"], completed=False)
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 GitCommit.GitCommit(self._requester, 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 NamedUser.NamedUser(self._requester, 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 [
File.File(self._requester, element, completed=False)
for element in attributes["files"]
]
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 )
for element in attributes[ "parents" ]
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)
for element in attributes["parents"]
]
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 "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 CommitStats.CommitStats( self._requester, 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" ]
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 "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 CommitStats.CommitStats(self._requester, 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"]
+74 -73
View File
@@ -15,63 +15,64 @@ import GithubObject
import NamedUser
class CommitComment( GithubObject.GithubObject ):
class CommitComment(GithubObject.GithubObject):
@property
def body( self ):
self._completeIfNotSet( self._body )
return self._NoneIfNotSet( self._body )
def body(self):
self._completeIfNotSet(self._body)
return self._NoneIfNotSet(self._body)
@property
def commit_id( self ):
self._completeIfNotSet( self._commit_id )
return self._NoneIfNotSet( self._commit_id )
def commit_id(self):
self._completeIfNotSet(self._commit_id)
return self._NoneIfNotSet(self._commit_id)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def html_url( self ):
self._completeIfNotSet( self._html_url )
return self._NoneIfNotSet( self._html_url )
def html_url(self):
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def line( self ):
self._completeIfNotSet( self._line )
return self._NoneIfNotSet( self._line )
def line(self):
self._completeIfNotSet(self._line)
return self._NoneIfNotSet(self._line)
@property
def path( self ):
self._completeIfNotSet( self._path )
return self._NoneIfNotSet( self._path )
def path(self):
self._completeIfNotSet(self._path)
return self._NoneIfNotSet(self._path)
@property
def position( self ):
self._completeIfNotSet( self._position )
return self._NoneIfNotSet( self._position )
def position(self):
self._completeIfNotSet(self._position)
return self._NoneIfNotSet(self._position)
@property
def updated_at( self ):
self._completeIfNotSet( self._updated_at )
return self._NoneIfNotSet( self._updated_at )
def updated_at(self):
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
@property
def user( self ):
self._completeIfNotSet( self._user )
return self._NoneIfNotSet( self._user )
def user(self):
self._completeIfNotSet(self._user)
return self._NoneIfNotSet(self._user)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -79,8 +80,8 @@ class CommitComment( GithubObject.GithubObject ):
None
)
def edit( self, body ):
assert isinstance( body, ( str, unicode ) ), body
def edit(self, body):
assert isinstance(body, (str, unicode)), body
post_parameters = {
"body": body,
}
@@ -90,9 +91,9 @@ class CommitComment( GithubObject.GithubObject ):
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def _initAttributes( self ):
def _initAttributes(self):
self._body = GithubObject.NotSet
self._commit_id = GithubObject.NotSet
self._created_at = GithubObject.NotSet
@@ -105,37 +106,37 @@ class CommitComment( GithubObject.GithubObject ):
self._url = GithubObject.NotSet
self._user = 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 "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" ]
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 "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" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "line" in attributes: # pragma no branch
assert attributes[ "line" ] is None or isinstance( attributes[ "line" ], int ), attributes[ "line" ]
self._line = attributes[ "line" ]
if "path" in attributes: # pragma no branch
assert attributes[ "path" ] is None or isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ]
self._path = attributes[ "path" ]
if "position" in attributes: # pragma no branch
assert attributes[ "position" ] is None or isinstance( attributes[ "position" ], int ), attributes[ "position" ]
self._position = attributes[ "position" ]
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 NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False )
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 "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"]
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 "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"], int), attributes["id"]
self._id = attributes["id"]
if "line" in attributes: # pragma no branch
assert attributes["line"] is None or isinstance(attributes["line"], int), attributes["line"]
self._line = attributes["line"]
if "path" in attributes: # pragma no branch
assert attributes["path"] is None or isinstance(attributes["path"], (str, unicode)), attributes["path"]
self._path = attributes["path"]
if "position" in attributes: # pragma no branch
assert attributes["position"] is None or isinstance(attributes["position"], int), attributes["position"]
self._position = attributes["position"]
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 NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
+19 -18
View File
@@ -13,31 +13,32 @@
import GithubObject
class CommitStats( GithubObject.BasicGithubObject ):
class CommitStats(GithubObject.BasicGithubObject):
@property
def additions( self ):
return self._NoneIfNotSet( self._additions )
def additions(self):
return self._NoneIfNotSet(self._additions)
@property
def deletions( self ):
return self._NoneIfNotSet( self._deletions )
def deletions(self):
return self._NoneIfNotSet(self._deletions)
@property
def total( self ):
return self._NoneIfNotSet( self._total )
def total(self):
return self._NoneIfNotSet(self._total)
def _initAttributes( self ):
def _initAttributes(self):
self._additions = GithubObject.NotSet
self._deletions = GithubObject.NotSet
self._total = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "additions" in attributes: # pragma no branch
assert attributes[ "additions" ] is None or isinstance( attributes[ "additions" ], int ), attributes[ "additions" ]
self._additions = attributes[ "additions" ]
if "deletions" in attributes: # pragma no branch
assert attributes[ "deletions" ] is None or isinstance( attributes[ "deletions" ], int ), attributes[ "deletions" ]
self._deletions = attributes[ "deletions" ]
if "total" in attributes: # pragma no branch
assert attributes[ "total" ] is None or isinstance( attributes[ "total" ], int ), attributes[ "total" ]
self._total = attributes[ "total" ]
def _useAttributes(self, attributes):
if "additions" in attributes: # pragma no branch
assert attributes["additions"] is None or isinstance(attributes["additions"], int), attributes["additions"]
self._additions = attributes["additions"]
if "deletions" in attributes: # pragma no branch
assert attributes["deletions"] is None or isinstance(attributes["deletions"], int), attributes["deletions"]
self._deletions = attributes["deletions"]
if "total" in attributes: # pragma no branch
assert attributes["total"] is None or isinstance(attributes["total"], int), attributes["total"]
self._total = attributes["total"]
+39 -38
View File
@@ -15,36 +15,37 @@ import GithubObject
import NamedUser
class CommitStatus( GithubObject.BasicGithubObject ):
class CommitStatus(GithubObject.BasicGithubObject):
@property
def created_at( self ):
return self._NoneIfNotSet( self._created_at )
def created_at(self):
return self._NoneIfNotSet(self._created_at)
@property
def creator( self ):
return self._NoneIfNotSet( self._creator )
def creator(self):
return self._NoneIfNotSet(self._creator)
@property
def description( self ):
return self._NoneIfNotSet( self._description )
def description(self):
return self._NoneIfNotSet(self._description)
@property
def id( self ):
return self._NoneIfNotSet( self._id )
def id(self):
return self._NoneIfNotSet(self._id)
@property
def state( self ):
return self._NoneIfNotSet( self._state )
def state(self):
return self._NoneIfNotSet(self._state)
@property
def target_url( self ):
return self._NoneIfNotSet( self._target_url )
def target_url(self):
return self._NoneIfNotSet(self._target_url)
@property
def updated_at( self ):
return self._NoneIfNotSet( self._updated_at )
def updated_at(self):
return self._NoneIfNotSet(self._updated_at)
def _initAttributes( self ):
def _initAttributes(self):
self._created_at = GithubObject.NotSet
self._creator = GithubObject.NotSet
self._description = GithubObject.NotSet
@@ -53,25 +54,25 @@ class CommitStatus( GithubObject.BasicGithubObject ):
self._target_url = GithubObject.NotSet
self._updated_at = GithubObject.NotSet
def _useAttributes( self, attributes ):
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 "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 NamedUser.NamedUser( self._requester, 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" ]
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "state" in attributes: # pragma no branch
assert attributes[ "state" ] is None or isinstance( attributes[ "state" ], ( str, unicode ) ), attributes[ "state" ]
self._state = attributes[ "state" ]
if "target_url" in attributes: # pragma no branch
assert attributes[ "target_url" ] is None or isinstance( attributes[ "target_url" ], ( str, unicode ) ), attributes[ "target_url" ]
self._target_url = attributes[ "target_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" ] )
def _useAttributes(self, attributes):
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 "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 NamedUser.NamedUser(self._requester, 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"]
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], int), attributes["id"]
self._id = attributes["id"]
if "state" in attributes: # pragma no branch
assert attributes["state"] is None or isinstance(attributes["state"], (str, unicode)), attributes["state"]
self._state = attributes["state"]
if "target_url" in attributes: # pragma no branch
assert attributes["target_url"] is None or isinstance(attributes["target_url"], (str, unicode)), attributes["target_url"]
self._target_url = attributes["target_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"])
+80 -79
View File
@@ -16,68 +16,69 @@ import GithubObject
import Commit
import File
class Comparison( GithubObject.GithubObject ):
class Comparison(GithubObject.GithubObject):
@property
def ahead_by( self ):
self._completeIfNotSet( self._ahead_by )
return self._NoneIfNotSet( self._ahead_by )
def ahead_by(self):
self._completeIfNotSet(self._ahead_by)
return self._NoneIfNotSet(self._ahead_by)
@property
def base_commit( self ):
self._completeIfNotSet( self._base_commit )
return self._NoneIfNotSet( self._base_commit )
def base_commit(self):
self._completeIfNotSet(self._base_commit)
return self._NoneIfNotSet(self._base_commit)
@property
def behind_by( self ):
self._completeIfNotSet( self._behind_by )
return self._NoneIfNotSet( self._behind_by )
def behind_by(self):
self._completeIfNotSet(self._behind_by)
return self._NoneIfNotSet(self._behind_by)
@property
def commits( self ):
self._completeIfNotSet( self._commits )
return self._NoneIfNotSet( self._commits )
def commits(self):
self._completeIfNotSet(self._commits)
return self._NoneIfNotSet(self._commits)
@property
def diff_url( self ):
self._completeIfNotSet( self._diff_url )
return self._NoneIfNotSet( self._diff_url )
def diff_url(self):
self._completeIfNotSet(self._diff_url)
return self._NoneIfNotSet(self._diff_url)
@property
def files( self ):
self._completeIfNotSet( self._files )
return self._NoneIfNotSet( self._files )
def files(self):
self._completeIfNotSet(self._files)
return self._NoneIfNotSet(self._files)
@property
def html_url( self ):
self._completeIfNotSet( self._html_url )
return self._NoneIfNotSet( self._html_url )
def html_url(self):
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def patch_url( self ):
self._completeIfNotSet( self._patch_url )
return self._NoneIfNotSet( self._patch_url )
def patch_url(self):
self._completeIfNotSet(self._patch_url)
return self._NoneIfNotSet(self._patch_url)
@property
def permalink_url( self ):
self._completeIfNotSet( self._permalink_url )
return self._NoneIfNotSet( self._permalink_url )
def permalink_url(self):
self._completeIfNotSet(self._permalink_url)
return self._NoneIfNotSet(self._permalink_url)
@property
def status( self ):
self._completeIfNotSet( self._status )
return self._NoneIfNotSet( self._status )
def status(self):
self._completeIfNotSet(self._status)
return self._NoneIfNotSet(self._status)
@property
def total_commits( self ):
self._completeIfNotSet( self._total_commits )
return self._NoneIfNotSet( self._total_commits )
def total_commits(self):
self._completeIfNotSet(self._total_commits)
return self._NoneIfNotSet(self._total_commits)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def _initAttributes( self ):
def _initAttributes(self):
self._ahead_by = GithubObject.NotSet
self._base_commit = GithubObject.NotSet
self._behind_by = GithubObject.NotSet
@@ -91,46 +92,46 @@ class Comparison( GithubObject.GithubObject ):
self._total_commits = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "ahead_by" in attributes: # pragma no branch
assert attributes[ "ahead_by" ] is None or isinstance( attributes[ "ahead_by" ], int ), attributes[ "ahead_by" ]
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 Commit.Commit( self._requester, 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 ), 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 [
Commit.Commit( self._requester, element, completed = False )
for element in attributes[ "commits" ]
def _useAttributes(self, attributes):
if "ahead_by" in attributes: # pragma no branch
assert attributes["ahead_by"] is None or isinstance(attributes["ahead_by"], int), attributes["ahead_by"]
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 Commit.Commit(self._requester, 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), 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 [
Commit.Commit(self._requester, element, completed=False)
for element in attributes["commits"]
]
if "diff_url" in attributes: # pragma no branch
assert attributes[ "diff_url" ] is None or isinstance( attributes[ "diff_url" ], ( str, unicode ) ), attributes[ "diff_url" ]
self._diff_url = attributes[ "diff_url" ]
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 [
File.File( self._requester, element, completed = False )
for element in attributes[ "files" ]
if "diff_url" in attributes: # pragma no branch
assert attributes["diff_url"] is None or isinstance(attributes["diff_url"], (str, unicode)), attributes["diff_url"]
self._diff_url = attributes["diff_url"]
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 [
File.File(self._requester, 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 "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 "permalink_url" in attributes: # pragma no branch
assert attributes[ "permalink_url" ] is None or isinstance( attributes[ "permalink_url" ], ( str, unicode ) ), attributes[ "permalink_url" ]
self._permalink_url = attributes[ "permalink_url" ]
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 "total_commits" in attributes: # pragma no branch
assert attributes[ "total_commits" ] is None or isinstance( attributes[ "total_commits" ], int ), attributes[ "total_commits" ]
self._total_commits = attributes[ "total_commits" ]
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 "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 "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 "permalink_url" in attributes: # pragma no branch
assert attributes["permalink_url"] is None or isinstance(attributes["permalink_url"], (str, unicode)), attributes["permalink_url"]
self._permalink_url = attributes["permalink_url"]
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 "total_commits" in attributes: # pragma no branch
assert attributes["total_commits"] is None or isinstance(attributes["total_commits"], int), attributes["total_commits"]
self._total_commits = attributes["total_commits"]
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+39 -38
View File
@@ -13,36 +13,37 @@
import GithubObject
class ContentFile( GithubObject.BasicGithubObject ):
class ContentFile(GithubObject.BasicGithubObject):
@property
def content( self ):
return self._NoneIfNotSet( self._content )
def content(self):
return self._NoneIfNotSet(self._content)
@property
def encoding( self ):
return self._NoneIfNotSet( self._encoding )
def encoding(self):
return self._NoneIfNotSet(self._encoding)
@property
def name( self ):
return self._NoneIfNotSet( self._name )
def name(self):
return self._NoneIfNotSet(self._name)
@property
def path( self ):
return self._NoneIfNotSet( self._path )
def path(self):
return self._NoneIfNotSet(self._path)
@property
def sha( self ):
return self._NoneIfNotSet( self._sha )
def sha(self):
return self._NoneIfNotSet(self._sha)
@property
def size( self ):
return self._NoneIfNotSet( self._size )
def size(self):
return self._NoneIfNotSet(self._size)
@property
def type( self ):
return self._NoneIfNotSet( self._type )
def type(self):
return self._NoneIfNotSet(self._type)
def _initAttributes( self ):
def _initAttributes(self):
self._content = GithubObject.NotSet
self._encoding = GithubObject.NotSet
self._name = GithubObject.NotSet
@@ -51,25 +52,25 @@ class ContentFile( GithubObject.BasicGithubObject ):
self._size = GithubObject.NotSet
self._type = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "content" in attributes: # pragma no branch
assert attributes[ "content" ] is None or isinstance( attributes[ "content" ], ( str, unicode ) ), attributes[ "content" ]
self._content = attributes[ "content" ]
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 "name" in attributes: # pragma no branch
assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ]
self._name = attributes[ "name" ]
if "path" in attributes: # pragma no branch
assert attributes[ "path" ] is None or isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ]
self._path = attributes[ "path" ]
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 "size" in attributes: # pragma no branch
assert attributes[ "size" ] is None or isinstance( attributes[ "size" ], int ), 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" ]
def _useAttributes(self, attributes):
if "content" in attributes: # pragma no branch
assert attributes["content"] is None or isinstance(attributes["content"], (str, unicode)), attributes["content"]
self._content = attributes["content"]
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 "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
if "path" in attributes: # pragma no branch
assert attributes["path"] is None or isinstance(attributes["path"], (str, unicode)), attributes["path"]
self._path = attributes["path"]
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 "size" in attributes: # pragma no branch
assert attributes["size"] is None or isinstance(attributes["size"], int), 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"]
+125 -124
View File
@@ -13,108 +13,109 @@
import GithubObject
class Download( GithubObject.GithubObject ):
class Download(GithubObject.GithubObject):
@property
def accesskeyid( self ):
self._completeIfNotSet( self._accesskeyid )
return self._NoneIfNotSet( self._accesskeyid )
def accesskeyid(self):
self._completeIfNotSet(self._accesskeyid)
return self._NoneIfNotSet(self._accesskeyid)
@property
def acl( self ):
self._completeIfNotSet( self._acl )
return self._NoneIfNotSet( self._acl )
def acl(self):
self._completeIfNotSet(self._acl)
return self._NoneIfNotSet(self._acl)
@property
def bucket( self ):
self._completeIfNotSet( self._bucket )
return self._NoneIfNotSet( self._bucket )
def bucket(self):
self._completeIfNotSet(self._bucket)
return self._NoneIfNotSet(self._bucket)
@property
def content_type( self ):
self._completeIfNotSet( self._content_type )
return self._NoneIfNotSet( self._content_type )
def content_type(self):
self._completeIfNotSet(self._content_type)
return self._NoneIfNotSet(self._content_type)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def description( self ):
self._completeIfNotSet( self._description )
return self._NoneIfNotSet( self._description )
def description(self):
self._completeIfNotSet(self._description)
return self._NoneIfNotSet(self._description)
@property
def download_count( self ):
self._completeIfNotSet( self._download_count )
return self._NoneIfNotSet( self._download_count )
def download_count(self):
self._completeIfNotSet(self._download_count)
return self._NoneIfNotSet(self._download_count)
@property
def expirationdate( self ):
self._completeIfNotSet( self._expirationdate )
return self._NoneIfNotSet( self._expirationdate )
def expirationdate(self):
self._completeIfNotSet(self._expirationdate)
return self._NoneIfNotSet(self._expirationdate)
@property
def html_url( self ):
self._completeIfNotSet( self._html_url )
return self._NoneIfNotSet( self._html_url )
def html_url(self):
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def mime_type( self ):
self._completeIfNotSet( self._mime_type )
return self._NoneIfNotSet( self._mime_type )
def mime_type(self):
self._completeIfNotSet(self._mime_type)
return self._NoneIfNotSet(self._mime_type)
@property
def name( self ):
self._completeIfNotSet( self._name )
return self._NoneIfNotSet( self._name )
def name(self):
self._completeIfNotSet(self._name)
return self._NoneIfNotSet(self._name)
@property
def path( self ):
self._completeIfNotSet( self._path )
return self._NoneIfNotSet( self._path )
def path(self):
self._completeIfNotSet(self._path)
return self._NoneIfNotSet(self._path)
@property
def policy( self ):
self._completeIfNotSet( self._policy )
return self._NoneIfNotSet( self._policy )
def policy(self):
self._completeIfNotSet(self._policy)
return self._NoneIfNotSet(self._policy)
@property
def prefix( self ):
self._completeIfNotSet( self._prefix )
return self._NoneIfNotSet( self._prefix )
def prefix(self):
self._completeIfNotSet(self._prefix)
return self._NoneIfNotSet(self._prefix)
@property
def redirect( self ):
self._completeIfNotSet( self._redirect )
return self._NoneIfNotSet( self._redirect )
def redirect(self):
self._completeIfNotSet(self._redirect)
return self._NoneIfNotSet(self._redirect)
@property
def s3_url( self ):
self._completeIfNotSet( self._s3_url )
return self._NoneIfNotSet( self._s3_url )
def s3_url(self):
self._completeIfNotSet(self._s3_url)
return self._NoneIfNotSet(self._s3_url)
@property
def signature( self ):
self._completeIfNotSet( self._signature )
return self._NoneIfNotSet( self._signature )
def signature(self):
self._completeIfNotSet(self._signature)
return self._NoneIfNotSet(self._signature)
@property
def size( self ):
self._completeIfNotSet( self._size )
return self._NoneIfNotSet( self._size )
def size(self):
self._completeIfNotSet(self._size)
return self._NoneIfNotSet(self._size)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -122,7 +123,7 @@ class Download( GithubObject.GithubObject ):
None
)
def _initAttributes( self ):
def _initAttributes(self):
self._accesskeyid = GithubObject.NotSet
self._acl = GithubObject.NotSet
self._bucket = GithubObject.NotSet
@@ -144,64 +145,64 @@ class Download( GithubObject.GithubObject ):
self._size = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "accesskeyid" in attributes: # pragma no branch
assert attributes[ "accesskeyid" ] is None or isinstance( attributes[ "accesskeyid" ], ( str, unicode ) ), attributes[ "accesskeyid" ]
self._accesskeyid = attributes[ "accesskeyid" ]
if "acl" in attributes: # pragma no branch
assert attributes[ "acl" ] is None or isinstance( attributes[ "acl" ], ( str, unicode ) ), attributes[ "acl" ]
self._acl = attributes[ "acl" ]
if "bucket" in attributes: # pragma no branch
assert attributes[ "bucket" ] is None or isinstance( attributes[ "bucket" ], ( str, unicode ) ), attributes[ "bucket" ]
self._bucket = attributes[ "bucket" ]
if "content_type" in attributes: # pragma no branch
assert attributes[ "content_type" ] is None or isinstance( attributes[ "content_type" ], ( str, unicode ) ), attributes[ "content_type" ]
self._content_type = attributes[ "content_type" ]
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 "download_count" in attributes: # pragma no branch
assert attributes[ "download_count" ] is None or isinstance( attributes[ "download_count" ], int ), attributes[ "download_count" ]
self._download_count = attributes[ "download_count" ]
if "expirationdate" in attributes: # pragma no branch
assert attributes[ "expirationdate" ] is None or isinstance( attributes[ "expirationdate" ], ( str, unicode ) ), attributes[ "expirationdate" ]
self._expirationdate = self._parseDatetime( attributes[ "expirationdate" ] )
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" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "mime_type" in attributes: # pragma no branch
assert attributes[ "mime_type" ] is None or isinstance( attributes[ "mime_type" ], ( str, unicode ) ), attributes[ "mime_type" ]
self._mime_type = attributes[ "mime_type" ]
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 "path" in attributes: # pragma no branch
assert attributes[ "path" ] is None or isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ]
self._path = attributes[ "path" ]
if "policy" in attributes: # pragma no branch
assert attributes[ "policy" ] is None or isinstance( attributes[ "policy" ], ( str, unicode ) ), attributes[ "policy" ]
self._policy = attributes[ "policy" ]
if "prefix" in attributes: # pragma no branch
assert attributes[ "prefix" ] is None or isinstance( attributes[ "prefix" ], ( str, unicode ) ), attributes[ "prefix" ]
self._prefix = attributes[ "prefix" ]
if "redirect" in attributes: # pragma no branch
assert attributes[ "redirect" ] is None or isinstance( attributes[ "redirect" ], bool ), attributes[ "redirect" ]
self._redirect = attributes[ "redirect" ]
if "s3_url" in attributes: # pragma no branch
assert attributes[ "s3_url" ] is None or isinstance( attributes[ "s3_url" ], ( str, unicode ) ), attributes[ "s3_url" ]
self._s3_url = attributes[ "s3_url" ]
if "signature" in attributes: # pragma no branch
assert attributes[ "signature" ] is None or isinstance( attributes[ "signature" ], ( str, unicode ) ), attributes[ "signature" ]
self._signature = attributes[ "signature" ]
if "size" in attributes: # pragma no branch
assert attributes[ "size" ] is None or isinstance( attributes[ "size" ], int ), attributes[ "size" ]
self._size = attributes[ "size" ]
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
def _useAttributes(self, attributes):
if "accesskeyid" in attributes: # pragma no branch
assert attributes["accesskeyid"] is None or isinstance(attributes["accesskeyid"], (str, unicode)), attributes["accesskeyid"]
self._accesskeyid = attributes["accesskeyid"]
if "acl" in attributes: # pragma no branch
assert attributes["acl"] is None or isinstance(attributes["acl"], (str, unicode)), attributes["acl"]
self._acl = attributes["acl"]
if "bucket" in attributes: # pragma no branch
assert attributes["bucket"] is None or isinstance(attributes["bucket"], (str, unicode)), attributes["bucket"]
self._bucket = attributes["bucket"]
if "content_type" in attributes: # pragma no branch
assert attributes["content_type"] is None or isinstance(attributes["content_type"], (str, unicode)), attributes["content_type"]
self._content_type = attributes["content_type"]
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 "download_count" in attributes: # pragma no branch
assert attributes["download_count"] is None or isinstance(attributes["download_count"], int), attributes["download_count"]
self._download_count = attributes["download_count"]
if "expirationdate" in attributes: # pragma no branch
assert attributes["expirationdate"] is None or isinstance(attributes["expirationdate"], (str, unicode)), attributes["expirationdate"]
self._expirationdate = self._parseDatetime(attributes["expirationdate"])
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"], int), attributes["id"]
self._id = attributes["id"]
if "mime_type" in attributes: # pragma no branch
assert attributes["mime_type"] is None or isinstance(attributes["mime_type"], (str, unicode)), attributes["mime_type"]
self._mime_type = attributes["mime_type"]
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 "path" in attributes: # pragma no branch
assert attributes["path"] is None or isinstance(attributes["path"], (str, unicode)), attributes["path"]
self._path = attributes["path"]
if "policy" in attributes: # pragma no branch
assert attributes["policy"] is None or isinstance(attributes["policy"], (str, unicode)), attributes["policy"]
self._policy = attributes["policy"]
if "prefix" in attributes: # pragma no branch
assert attributes["prefix"] is None or isinstance(attributes["prefix"], (str, unicode)), attributes["prefix"]
self._prefix = attributes["prefix"]
if "redirect" in attributes: # pragma no branch
assert attributes["redirect"] is None or isinstance(attributes["redirect"], bool), attributes["redirect"]
self._redirect = attributes["redirect"]
if "s3_url" in attributes: # pragma no branch
assert attributes["s3_url"] is None or isinstance(attributes["s3_url"], (str, unicode)), attributes["s3_url"]
self._s3_url = attributes["s3_url"]
if "signature" in attributes: # pragma no branch
assert attributes["signature"] is None or isinstance(attributes["signature"], (str, unicode)), attributes["signature"]
self._signature = attributes["signature"]
if "size" in attributes: # pragma no branch
assert attributes["size"] is None or isinstance(attributes["size"], int), attributes["size"]
self._size = attributes["size"]
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+44 -43
View File
@@ -17,40 +17,41 @@ import Organization
import Repository
import NamedUser
class Event( GithubObject.BasicGithubObject ):
class Event(GithubObject.BasicGithubObject):
@property
def actor( self ):
return self._NoneIfNotSet( self._actor )
def actor(self):
return self._NoneIfNotSet(self._actor)
@property
def created_at( self ):
return self._NoneIfNotSet( self._created_at )
def created_at(self):
return self._NoneIfNotSet(self._created_at)
@property
def id( self ):
return self._NoneIfNotSet( self._id )
def id(self):
return self._NoneIfNotSet(self._id)
@property
def org( self ):
return self._NoneIfNotSet( self._org )
def org(self):
return self._NoneIfNotSet(self._org)
@property
def payload( self ):
return self._NoneIfNotSet( self._payload )
def payload(self):
return self._NoneIfNotSet(self._payload)
@property
def public( self ):
return self._NoneIfNotSet( self._public )
def public(self):
return self._NoneIfNotSet(self._public)
@property
def repo( self ):
return self._NoneIfNotSet( self._repo )
def repo(self):
return self._NoneIfNotSet(self._repo)
@property
def type( self ):
return self._NoneIfNotSet( self._type )
def type(self):
return self._NoneIfNotSet(self._type)
def _initAttributes( self ):
def _initAttributes(self):
self._actor = GithubObject.NotSet
self._created_at = GithubObject.NotSet
self._id = GithubObject.NotSet
@@ -60,28 +61,28 @@ class Event( GithubObject.BasicGithubObject ):
self._repo = GithubObject.NotSet
self._type = GithubObject.NotSet
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 NamedUser.NamedUser( self._requester, 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" ] )
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 "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 Organization.Organization( self._requester, 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" ]
if "public" in attributes: # pragma no branch
assert attributes[ "public" ] is None or isinstance( attributes[ "public" ], bool ), attributes[ "public" ]
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 Repository.Repository( self._requester, 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" ]
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 NamedUser.NamedUser(self._requester, 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"])
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 "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 Organization.Organization(self._requester, 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"]
if "public" in attributes: # pragma no branch
assert attributes["public"] is None or isinstance(attributes["public"], bool), attributes["public"]
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 Repository.Repository(self._requester, 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"]
+49 -48
View File
@@ -13,44 +13,45 @@
import GithubObject
class File( GithubObject.BasicGithubObject ):
class File(GithubObject.BasicGithubObject):
@property
def additions( self ):
return self._NoneIfNotSet( self._additions )
def additions(self):
return self._NoneIfNotSet(self._additions)
@property
def blob_url( self ):
return self._NoneIfNotSet( self._blob_url )
def blob_url(self):
return self._NoneIfNotSet(self._blob_url)
@property
def changes( self ):
return self._NoneIfNotSet( self._changes )
def changes(self):
return self._NoneIfNotSet(self._changes)
@property
def deletions( self ):
return self._NoneIfNotSet( self._deletions )
def deletions(self):
return self._NoneIfNotSet(self._deletions)
@property
def filename( self ):
return self._NoneIfNotSet( self._filename )
def filename(self):
return self._NoneIfNotSet(self._filename)
@property
def patch( self ):
return self._NoneIfNotSet( self._patch )
def patch(self):
return self._NoneIfNotSet(self._patch)
@property
def raw_url( self ):
return self._NoneIfNotSet( self._raw_url )
def raw_url(self):
return self._NoneIfNotSet(self._raw_url)
@property
def sha( self ):
return self._NoneIfNotSet( self._sha )
def sha(self):
return self._NoneIfNotSet(self._sha)
@property
def status( self ):
return self._NoneIfNotSet( self._status )
def status(self):
return self._NoneIfNotSet(self._status)
def _initAttributes( self ):
def _initAttributes(self):
self._additions = GithubObject.NotSet
self._blob_url = GithubObject.NotSet
self._changes = GithubObject.NotSet
@@ -61,31 +62,31 @@ class File( GithubObject.BasicGithubObject ):
self._sha = GithubObject.NotSet
self._status = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "additions" in attributes: # pragma no branch
assert attributes[ "additions" ] is None or isinstance( attributes[ "additions" ], int ), attributes[ "additions" ]
self._additions = attributes[ "additions" ]
if "blob_url" in attributes: # pragma no branch
assert attributes[ "blob_url" ] is None or isinstance( attributes[ "blob_url" ], ( str, unicode ) ), attributes[ "blob_url" ]
self._blob_url = attributes[ "blob_url" ]
if "changes" in attributes: # pragma no branch
assert attributes[ "changes" ] is None or isinstance( attributes[ "changes" ], int ), attributes[ "changes" ]
self._changes = attributes[ "changes" ]
if "deletions" in attributes: # pragma no branch
assert attributes[ "deletions" ] is None or isinstance( attributes[ "deletions" ], int ), attributes[ "deletions" ]
self._deletions = attributes[ "deletions" ]
if "filename" in attributes: # pragma no branch
assert attributes[ "filename" ] is None or isinstance( attributes[ "filename" ], ( str, unicode ) ), attributes[ "filename" ]
self._filename = attributes[ "filename" ]
if "patch" in attributes: # pragma no branch
assert attributes[ "patch" ] is None or isinstance( attributes[ "patch" ], ( str, unicode ) ), attributes[ "patch" ]
self._patch = attributes[ "patch" ]
if "raw_url" in attributes: # pragma no branch
assert attributes[ "raw_url" ] is None or isinstance( attributes[ "raw_url" ], ( str, unicode ) ), attributes[ "raw_url" ]
self._raw_url = attributes[ "raw_url" ]
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 "status" in attributes: # pragma no branch
assert attributes[ "status" ] is None or isinstance( attributes[ "status" ], ( str, unicode ) ), attributes[ "status" ]
self._status = attributes[ "status" ]
def _useAttributes(self, attributes):
if "additions" in attributes: # pragma no branch
assert attributes["additions"] is None or isinstance(attributes["additions"], int), attributes["additions"]
self._additions = attributes["additions"]
if "blob_url" in attributes: # pragma no branch
assert attributes["blob_url"] is None or isinstance(attributes["blob_url"], (str, unicode)), attributes["blob_url"]
self._blob_url = attributes["blob_url"]
if "changes" in attributes: # pragma no branch
assert attributes["changes"] is None or isinstance(attributes["changes"], int), attributes["changes"]
self._changes = attributes["changes"]
if "deletions" in attributes: # pragma no branch
assert attributes["deletions"] is None or isinstance(attributes["deletions"], int), attributes["deletions"]
self._deletions = attributes["deletions"]
if "filename" in attributes: # pragma no branch
assert attributes["filename"] is None or isinstance(attributes["filename"], (str, unicode)), attributes["filename"]
self._filename = attributes["filename"]
if "patch" in attributes: # pragma no branch
assert attributes["patch"] is None or isinstance(attributes["patch"], (str, unicode)), attributes["patch"]
self._patch = attributes["patch"]
if "raw_url" in attributes: # pragma no branch
assert attributes["raw_url"] is None or isinstance(attributes["raw_url"], (str, unicode)), attributes["raw_url"]
self._raw_url = attributes["raw_url"]
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 "status" in attributes: # pragma no branch
assert attributes["status"] is None or isinstance(attributes["status"], (str, unicode)), attributes["status"]
self._status = attributes["status"]
+120 -119
View File
@@ -21,84 +21,85 @@ import GistFile
import InputFileContent
import GistHistoryState
class Gist( GithubObject.GithubObject ):
class Gist(GithubObject.GithubObject):
@property
def comments( self ):
self._completeIfNotSet( self._comments )
return self._NoneIfNotSet( self._comments )
def comments(self):
self._completeIfNotSet(self._comments)
return self._NoneIfNotSet(self._comments)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def description( self ):
self._completeIfNotSet( self._description )
return self._NoneIfNotSet( self._description )
def description(self):
self._completeIfNotSet(self._description)
return self._NoneIfNotSet(self._description)
@property
def files( self ):
self._completeIfNotSet( self._files )
return self._NoneIfNotSet( self._files )
def files(self):
self._completeIfNotSet(self._files)
return self._NoneIfNotSet(self._files)
@property
def fork_of( self ):
self._completeIfNotSet( self._fork_of )
return self._NoneIfNotSet( self._fork_of )
def fork_of(self):
self._completeIfNotSet(self._fork_of)
return self._NoneIfNotSet(self._fork_of)
@property
def forks( self ):
self._completeIfNotSet( self._forks )
return self._NoneIfNotSet( self._forks )
def forks(self):
self._completeIfNotSet(self._forks)
return self._NoneIfNotSet(self._forks)
@property
def git_pull_url( self ):
self._completeIfNotSet( self._git_pull_url )
return self._NoneIfNotSet( self._git_pull_url )
def git_pull_url(self):
self._completeIfNotSet(self._git_pull_url)
return self._NoneIfNotSet(self._git_pull_url)
@property
def git_push_url( self ):
self._completeIfNotSet( self._git_push_url )
return self._NoneIfNotSet( self._git_push_url )
def git_push_url(self):
self._completeIfNotSet(self._git_push_url)
return self._NoneIfNotSet(self._git_push_url)
@property
def history( self ):
self._completeIfNotSet( self._history )
return self._NoneIfNotSet( self._history )
def history(self):
self._completeIfNotSet(self._history)
return self._NoneIfNotSet(self._history)
@property
def html_url( self ):
self._completeIfNotSet( self._html_url )
return self._NoneIfNotSet( self._html_url )
def html_url(self):
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def public( self ):
self._completeIfNotSet( self._public )
return self._NoneIfNotSet( self._public )
def public(self):
self._completeIfNotSet(self._public)
return self._NoneIfNotSet(self._public)
@property
def updated_at( self ):
self._completeIfNotSet( self._updated_at )
return self._NoneIfNotSet( self._updated_at )
def updated_at(self):
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
@property
def user( self ):
self._completeIfNotSet( self._user )
return self._NoneIfNotSet( self._user )
def user(self):
self._completeIfNotSet(self._user)
return self._NoneIfNotSet(self._user)
def create_comment( self, body ):
assert isinstance( body, ( str, unicode ) ), body
def create_comment(self, body):
assert isinstance(body, (str, unicode)), body
post_parameters = {
"body": body,
}
@@ -108,18 +109,18 @@ class Gist( GithubObject.GithubObject ):
None,
post_parameters
)
return GistComment.GistComment( self._requester, data, completed = True )
return GistComment.GistComment(self._requester, data, completed=True)
def create_fork( self ):
def create_fork(self):
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/fork",
None,
None
)
return Gist( self._requester, data, completed = True )
return Gist(self._requester, data, completed=True)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -127,33 +128,33 @@ class Gist( GithubObject.GithubObject ):
None
)
def edit( self, description = GithubObject.NotSet, files = GithubObject.NotSet ):
assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description
assert files is GithubObject.NotSet or all( isinstance( element, InputFileContent.InputFileContent ) for element in files.itervalues() ), files
def edit(self, description=GithubObject.NotSet, files=GithubObject.NotSet):
assert description is GithubObject.NotSet or isinstance(description, (str, unicode)), description
assert files is GithubObject.NotSet or all(isinstance(element, InputFileContent.InputFileContent) for element in files.itervalues()), files
post_parameters = dict()
if description is not GithubObject.NotSet:
post_parameters[ "description" ] = description
post_parameters["description"] = description
if files is not GithubObject.NotSet:
post_parameters[ "files" ] = dict( ( key, value._identity ) for key, value in files.iteritems() )
post_parameters["files"] = dict((key, value._identity) for key, value in files.iteritems())
headers, data = self._requester.requestAndCheck(
"PATCH",
self.url,
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def get_comment( self, id ):
assert isinstance( id, int ), id
def get_comment(self, id):
assert isinstance(id, int), id
headers, data = self._requester.requestAndCheck(
"GET",
"/gists/comments/" + str( id ),
"/gists/comments/" + str(id),
None,
None
)
return GistComment.GistComment( self._requester, data, completed = True )
return GistComment.GistComment(self._requester, data, completed=True)
def get_comments( self ):
def get_comments(self):
return PaginatedList.PaginatedList(
GistComment.GistComment,
self._requester,
@@ -161,7 +162,7 @@ class Gist( GithubObject.GithubObject ):
None
)
def is_starred( self ):
def is_starred(self):
status, headers, data = self._requester.requestRaw(
"GET",
self.url + "/star",
@@ -170,7 +171,7 @@ class Gist( GithubObject.GithubObject ):
)
return status == 204
def reset_starred( self ):
def reset_starred(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url + "/star",
@@ -178,7 +179,7 @@ class Gist( GithubObject.GithubObject ):
None
)
def set_starred( self ):
def set_starred(self):
headers, data = self._requester.requestAndCheck(
"PUT",
self.url + "/star",
@@ -186,7 +187,7 @@ class Gist( GithubObject.GithubObject ):
None
)
def _initAttributes( self ):
def _initAttributes(self):
self._comments = GithubObject.NotSet
self._created_at = GithubObject.NotSet
self._description = GithubObject.NotSet
@@ -203,58 +204,58 @@ class Gist( GithubObject.GithubObject ):
self._url = GithubObject.NotSet
self._user = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "comments" in attributes: # pragma no branch
assert attributes[ "comments" ] is None or isinstance( attributes[ "comments" ], int ), attributes[ "comments" ]
self._comments = attributes[ "comments" ]
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, GistFile.GistFile( self._requester, element, completed = False ) )
for key, element in attributes[ "files" ].iteritems()
def _useAttributes(self, attributes):
if "comments" in attributes: # pragma no branch
assert attributes["comments"] is None or isinstance(attributes["comments"], int), attributes["comments"]
self._comments = attributes["comments"]
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, GistFile.GistFile(self._requester, 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 )
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 )
for element in attributes[ "forks" ]
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)
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)
for element in attributes["forks"]
]
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.GistHistoryState( self._requester, element, completed = False )
for element in attributes[ "history" ]
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.GistHistoryState(self._requester, 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 NamedUser.NamedUser( self._requester, attributes[ "user" ], 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 "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 NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
+44 -43
View File
@@ -15,38 +15,39 @@ import GithubObject
import NamedUser
class GistComment( GithubObject.GithubObject ):
class GistComment(GithubObject.GithubObject):
@property
def body( self ):
self._completeIfNotSet( self._body )
return self._NoneIfNotSet( self._body )
def body(self):
self._completeIfNotSet(self._body)
return self._NoneIfNotSet(self._body)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def updated_at( self ):
self._completeIfNotSet( self._updated_at )
return self._NoneIfNotSet( self._updated_at )
def updated_at(self):
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
@property
def user( self ):
self._completeIfNotSet( self._user )
return self._NoneIfNotSet( self._user )
def user(self):
self._completeIfNotSet(self._user)
return self._NoneIfNotSet(self._user)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -54,8 +55,8 @@ class GistComment( GithubObject.GithubObject ):
None
)
def edit( self, body ):
assert isinstance( body, ( str, unicode ) ), body
def edit(self, body):
assert isinstance(body, (str, unicode)), body
post_parameters = {
"body": body,
}
@@ -65,9 +66,9 @@ class GistComment( GithubObject.GithubObject ):
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def _initAttributes( self ):
def _initAttributes(self):
self._body = GithubObject.NotSet
self._created_at = GithubObject.NotSet
self._id = GithubObject.NotSet
@@ -75,22 +76,22 @@ class GistComment( GithubObject.GithubObject ):
self._url = GithubObject.NotSet
self._user = 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 "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 "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
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 NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False )
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 "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 "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], int), attributes["id"]
self._id = attributes["id"]
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 NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
+29 -28
View File
@@ -13,47 +13,48 @@
import GithubObject
class GistFile( GithubObject.BasicGithubObject ):
class GistFile(GithubObject.BasicGithubObject):
@property
def content( self ):
return self._NoneIfNotSet( self._content )
def content(self):
return self._NoneIfNotSet(self._content)
@property
def filename( self ):
return self._NoneIfNotSet( self._filename )
def filename(self):
return self._NoneIfNotSet(self._filename)
@property
def language( self ):
return self._NoneIfNotSet( self._language )
def language(self):
return self._NoneIfNotSet(self._language)
@property
def raw_url( self ):
return self._NoneIfNotSet( self._raw_url )
def raw_url(self):
return self._NoneIfNotSet(self._raw_url)
@property
def size( self ):
return self._NoneIfNotSet( self._size )
def size(self):
return self._NoneIfNotSet(self._size)
def _initAttributes( self ):
def _initAttributes(self):
self._content = GithubObject.NotSet
self._filename = GithubObject.NotSet
self._language = GithubObject.NotSet
self._raw_url = GithubObject.NotSet
self._size = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "content" in attributes: # pragma no branch
assert attributes[ "content" ] is None or isinstance( attributes[ "content" ], ( str, unicode ) ), attributes[ "content" ]
self._content = attributes[ "content" ]
if "filename" in attributes: # pragma no branch
assert attributes[ "filename" ] is None or isinstance( attributes[ "filename" ], ( str, unicode ) ), attributes[ "filename" ]
self._filename = attributes[ "filename" ]
if "language" in attributes: # pragma no branch
assert attributes[ "language" ] is None or isinstance( attributes[ "language" ], ( str, unicode ) ), attributes[ "language" ]
self._language = attributes[ "language" ]
if "raw_url" in attributes: # pragma no branch
assert attributes[ "raw_url" ] is None or isinstance( attributes[ "raw_url" ], ( str, unicode ) ), attributes[ "raw_url" ]
self._raw_url = attributes[ "raw_url" ]
if "size" in attributes: # pragma no branch
assert attributes[ "size" ] is None or isinstance( attributes[ "size" ], int ), attributes[ "size" ]
self._size = attributes[ "size" ]
def _useAttributes(self, attributes):
if "content" in attributes: # pragma no branch
assert attributes["content"] is None or isinstance(attributes["content"], (str, unicode)), attributes["content"]
self._content = attributes["content"]
if "filename" in attributes: # pragma no branch
assert attributes["filename"] is None or isinstance(attributes["filename"], (str, unicode)), attributes["filename"]
self._filename = attributes["filename"]
if "language" in attributes: # pragma no branch
assert attributes["language"] is None or isinstance(attributes["language"], (str, unicode)), attributes["language"]
self._language = attributes["language"]
if "raw_url" in attributes: # pragma no branch
assert attributes["raw_url"] is None or isinstance(attributes["raw_url"], (str, unicode)), attributes["raw_url"]
self._raw_url = attributes["raw_url"]
if "size" in attributes: # pragma no branch
assert attributes["size"] is None or isinstance(attributes["size"], int), attributes["size"]
self._size = attributes["size"]
+34 -33
View File
@@ -16,52 +16,53 @@ import GithubObject
import NamedUser
import CommitStats
class GistHistoryState( GithubObject.GithubObject ):
class GistHistoryState(GithubObject.GithubObject):
@property
def change_status( self ):
self._completeIfNotSet( self._change_status )
return self._NoneIfNotSet( self._change_status )
def change_status(self):
self._completeIfNotSet(self._change_status)
return self._NoneIfNotSet(self._change_status)
@property
def committed_at( self ):
self._completeIfNotSet( self._committed_at )
return self._NoneIfNotSet( self._committed_at )
def committed_at(self):
self._completeIfNotSet(self._committed_at)
return self._NoneIfNotSet(self._committed_at)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
@property
def user( self ):
self._completeIfNotSet( self._user )
return self._NoneIfNotSet( self._user )
def user(self):
self._completeIfNotSet(self._user)
return self._NoneIfNotSet(self._user)
@property
def version( self ):
self._completeIfNotSet( self._version )
return self._NoneIfNotSet( self._version )
def version(self):
self._completeIfNotSet(self._version)
return self._NoneIfNotSet(self._version)
def _initAttributes( self ):
def _initAttributes(self):
self._change_status = GithubObject.NotSet
self._committed_at = GithubObject.NotSet
self._url = GithubObject.NotSet
self._user = GithubObject.NotSet
self._version = GithubObject.NotSet
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 CommitStats.CommitStats( self._requester, attributes[ "change_status" ], completed = False )
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 "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 NamedUser.NamedUser( self._requester, 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" ]
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 CommitStats.CommitStats(self._requester, attributes["change_status"], completed=False)
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 "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 NamedUser.NamedUser(self._requester, 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"]
+19 -18
View File
@@ -13,31 +13,32 @@
import GithubObject
class GitAuthor( GithubObject.BasicGithubObject ):
class GitAuthor(GithubObject.BasicGithubObject):
@property
def date( self ):
return self._NoneIfNotSet( self._date )
def date(self):
return self._NoneIfNotSet(self._date)
@property
def email( self ):
return self._NoneIfNotSet( self._email )
def email(self):
return self._NoneIfNotSet(self._email)
@property
def name( self ):
return self._NoneIfNotSet( self._name )
def name(self):
return self._NoneIfNotSet(self._name)
def _initAttributes( self ):
def _initAttributes(self):
self._date = GithubObject.NotSet
self._email = GithubObject.NotSet
self._name = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "date" in attributes: # pragma no branch
assert attributes[ "date" ] is None or isinstance( attributes[ "date" ], ( str, unicode ) ), attributes[ "date" ]
self._date = self._parseDatetime( attributes[ "date" ] )
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 "name" in attributes: # pragma no branch
assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ]
self._name = attributes[ "name" ]
def _useAttributes(self, attributes):
if "date" in attributes: # pragma no branch
assert attributes["date"] is None or isinstance(attributes["date"], (str, unicode)), attributes["date"]
self._date = self._parseDatetime(attributes["date"])
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 "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
+34 -33
View File
@@ -13,52 +13,53 @@
import GithubObject
class GitBlob( GithubObject.GithubObject ):
class GitBlob(GithubObject.GithubObject):
@property
def content( self ):
self._completeIfNotSet( self._content )
return self._NoneIfNotSet( self._content )
def content(self):
self._completeIfNotSet(self._content)
return self._NoneIfNotSet(self._content)
@property
def encoding( self ):
self._completeIfNotSet( self._encoding )
return self._NoneIfNotSet( self._encoding )
def encoding(self):
self._completeIfNotSet(self._encoding)
return self._NoneIfNotSet(self._encoding)
@property
def sha( self ):
self._completeIfNotSet( self._sha )
return self._NoneIfNotSet( self._sha )
def sha(self):
self._completeIfNotSet(self._sha)
return self._NoneIfNotSet(self._sha)
@property
def size( self ):
self._completeIfNotSet( self._size )
return self._NoneIfNotSet( self._size )
def size(self):
self._completeIfNotSet(self._size)
return self._NoneIfNotSet(self._size)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def _initAttributes( self ):
def _initAttributes(self):
self._content = GithubObject.NotSet
self._encoding = GithubObject.NotSet
self._sha = GithubObject.NotSet
self._size = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "content" in attributes: # pragma no branch
assert attributes[ "content" ] is None or isinstance( attributes[ "content" ], ( str, unicode ) ), attributes[ "content" ]
self._content = attributes[ "content" ]
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 "sha" in attributes: # pragma no branch
assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ]
self._sha = attributes[ "sha" ]
if "size" in attributes: # pragma no branch
assert attributes[ "size" ] is None or isinstance( attributes[ "size" ], int ), attributes[ "size" ]
self._size = attributes[ "size" ]
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
def _useAttributes(self, attributes):
if "content" in attributes: # pragma no branch
assert attributes["content"] is None or isinstance(attributes["content"], (str, unicode)), attributes["content"]
self._content = attributes["content"]
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 "sha" in attributes: # pragma no branch
assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"]
self._sha = attributes["sha"]
if "size" in attributes: # pragma no branch
assert attributes["size"] is None or isinstance(attributes["size"], int), attributes["size"]
self._size = attributes["size"]
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+49 -48
View File
@@ -17,47 +17,48 @@ import GitAuthor
import GitCommit
import GitTree
class GitCommit( GithubObject.GithubObject ):
class GitCommit(GithubObject.GithubObject):
@property
def author( self ):
self._completeIfNotSet( self._author )
return self._NoneIfNotSet( self._author )
def author(self):
self._completeIfNotSet(self._author)
return self._NoneIfNotSet(self._author)
@property
def committer( self ):
self._completeIfNotSet( self._committer )
return self._NoneIfNotSet( self._committer )
def committer(self):
self._completeIfNotSet(self._committer)
return self._NoneIfNotSet(self._committer)
@property
def message( self ):
self._completeIfNotSet( self._message )
return self._NoneIfNotSet( self._message )
def message(self):
self._completeIfNotSet(self._message)
return self._NoneIfNotSet(self._message)
@property
def parents( self ):
self._completeIfNotSet( self._parents )
return self._NoneIfNotSet( self._parents )
def parents(self):
self._completeIfNotSet(self._parents)
return self._NoneIfNotSet(self._parents)
@property
def sha( self ):
self._completeIfNotSet( self._sha )
return self._NoneIfNotSet( self._sha )
def sha(self):
self._completeIfNotSet(self._sha)
return self._NoneIfNotSet(self._sha)
@property
def tree( self ):
self._completeIfNotSet( self._tree )
return self._NoneIfNotSet( self._tree )
def tree(self):
self._completeIfNotSet(self._tree)
return self._NoneIfNotSet(self._tree)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
@property
def _identity( self ):
def _identity(self):
return self.sha
def _initAttributes( self ):
def _initAttributes(self):
self._author = GithubObject.NotSet
self._committer = GithubObject.NotSet
self._message = GithubObject.NotSet
@@ -66,28 +67,28 @@ class GitCommit( GithubObject.GithubObject ):
self._tree = GithubObject.NotSet
self._url = GithubObject.NotSet
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 GitAuthor.GitAuthor( self._requester, 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 GitAuthor.GitAuthor( self._requester, attributes[ "committer" ], completed = False )
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 )
for element in attributes[ "parents" ]
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 GitAuthor.GitAuthor(self._requester, 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 GitAuthor.GitAuthor(self._requester, attributes["committer"], completed=False)
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)
for element in attributes["parents"]
]
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 "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 GitTree.GitTree( self._requester, 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" ]
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 "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 GitTree.GitTree(self._requester, 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"]
+19 -18
View File
@@ -13,31 +13,32 @@
import GithubObject
class GitObject( GithubObject.BasicGithubObject ):
class GitObject(GithubObject.BasicGithubObject):
@property
def sha( self ):
return self._NoneIfNotSet( self._sha )
def sha(self):
return self._NoneIfNotSet(self._sha)
@property
def type( self ):
return self._NoneIfNotSet( self._type )
def type(self):
return self._NoneIfNotSet(self._type)
@property
def url( self ):
return self._NoneIfNotSet( self._url )
def url(self):
return self._NoneIfNotSet(self._url)
def _initAttributes( self ):
def _initAttributes(self):
self._sha = GithubObject.NotSet
self._type = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
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 "type" in attributes: # pragma no branch
assert attributes[ "type" ] is None or isinstance( attributes[ "type" ], ( str, unicode ) ), attributes[ "type" ]
self._type = attributes[ "type" ]
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
def _useAttributes(self, attributes):
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 "type" in attributes: # pragma no branch
assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"]
self._type = attributes["type"]
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+28 -27
View File
@@ -15,23 +15,24 @@ import GithubObject
import GitObject
class GitRef( GithubObject.GithubObject ):
class GitRef(GithubObject.GithubObject):
@property
def object( self ):
self._completeIfNotSet( self._object )
return self._NoneIfNotSet( self._object )
def object(self):
self._completeIfNotSet(self._object)
return self._NoneIfNotSet(self._object)
@property
def ref( self ):
self._completeIfNotSet( self._ref )
return self._NoneIfNotSet( self._ref )
def ref(self):
self._completeIfNotSet(self._ref)
return self._NoneIfNotSet(self._ref)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -39,34 +40,34 @@ class GitRef( GithubObject.GithubObject ):
None
)
def edit( self, sha, force = GithubObject.NotSet ):
assert isinstance( sha, ( str, unicode ) ), sha
assert force is GithubObject.NotSet or isinstance( force, bool ), force
def edit(self, sha, force=GithubObject.NotSet):
assert isinstance(sha, (str, unicode)), sha
assert force is GithubObject.NotSet or isinstance(force, bool), force
post_parameters = {
"sha": sha,
}
if force is not GithubObject.NotSet:
post_parameters[ "force" ] = force
post_parameters["force"] = force
headers, data = self._requester.requestAndCheck(
"PATCH",
self.url,
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def _initAttributes( self ):
def _initAttributes(self):
self._object = GithubObject.NotSet
self._ref = GithubObject.NotSet
self._url = GithubObject.NotSet
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 GitObject.GitObject( self._requester, 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" ]
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
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 GitObject.GitObject(self._requester, 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"]
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+40 -39
View File
@@ -16,38 +16,39 @@ import GithubObject
import GitAuthor
import GitObject
class GitTag( GithubObject.GithubObject ):
class GitTag(GithubObject.GithubObject):
@property
def message( self ):
self._completeIfNotSet( self._message )
return self._NoneIfNotSet( self._message )
def message(self):
self._completeIfNotSet(self._message)
return self._NoneIfNotSet(self._message)
@property
def object( self ):
self._completeIfNotSet( self._object )
return self._NoneIfNotSet( self._object )
def object(self):
self._completeIfNotSet(self._object)
return self._NoneIfNotSet(self._object)
@property
def sha( self ):
self._completeIfNotSet( self._sha )
return self._NoneIfNotSet( self._sha )
def sha(self):
self._completeIfNotSet(self._sha)
return self._NoneIfNotSet(self._sha)
@property
def tag( self ):
self._completeIfNotSet( self._tag )
return self._NoneIfNotSet( self._tag )
def tag(self):
self._completeIfNotSet(self._tag)
return self._NoneIfNotSet(self._tag)
@property
def tagger( self ):
self._completeIfNotSet( self._tagger )
return self._NoneIfNotSet( self._tagger )
def tagger(self):
self._completeIfNotSet(self._tagger)
return self._NoneIfNotSet(self._tagger)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def _initAttributes( self ):
def _initAttributes(self):
self._message = GithubObject.NotSet
self._object = GithubObject.NotSet
self._sha = GithubObject.NotSet
@@ -55,22 +56,22 @@ class GitTag( GithubObject.GithubObject ):
self._tagger = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
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 "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 GitObject.GitObject( self._requester, 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" ]
if "tag" in attributes: # pragma no branch
assert attributes[ "tag" ] is None or isinstance( attributes[ "tag" ], ( str, unicode ) ), attributes[ "tag" ]
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 GitAuthor.GitAuthor( self._requester, 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" ]
def _useAttributes(self, attributes):
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 "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 GitObject.GitObject(self._requester, 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"]
if "tag" in attributes: # pragma no branch
assert attributes["tag"] is None or isinstance(attributes["tag"], (str, unicode)), attributes["tag"]
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 GitAuthor.GitAuthor(self._requester, 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"]
+25 -24
View File
@@ -15,41 +15,42 @@ import GithubObject
import GitTreeElement
class GitTree( GithubObject.GithubObject ):
class GitTree(GithubObject.GithubObject):
@property
def sha( self ):
self._completeIfNotSet( self._sha )
return self._NoneIfNotSet( self._sha )
def sha(self):
self._completeIfNotSet(self._sha)
return self._NoneIfNotSet(self._sha)
@property
def tree( self ):
self._completeIfNotSet( self._tree )
return self._NoneIfNotSet( self._tree )
def tree(self):
self._completeIfNotSet(self._tree)
return self._NoneIfNotSet(self._tree)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
@property
def _identity( self ):
def _identity(self):
return self.sha
def _initAttributes( self ):
def _initAttributes(self):
self._sha = GithubObject.NotSet
self._tree = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
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 "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 [
GitTreeElement.GitTreeElement( self._requester, element, completed = False )
for element in attributes[ "tree" ]
def _useAttributes(self, attributes):
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 "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 [
GitTreeElement.GitTreeElement(self._requester, element, completed=False)
for element in attributes["tree"]
]
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 "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+34 -33
View File
@@ -13,32 +13,33 @@
import GithubObject
class GitTreeElement( GithubObject.BasicGithubObject ):
class GitTreeElement(GithubObject.BasicGithubObject):
@property
def mode( self ):
return self._NoneIfNotSet( self._mode )
def mode(self):
return self._NoneIfNotSet(self._mode)
@property
def path( self ):
return self._NoneIfNotSet( self._path )
def path(self):
return self._NoneIfNotSet(self._path)
@property
def sha( self ):
return self._NoneIfNotSet( self._sha )
def sha(self):
return self._NoneIfNotSet(self._sha)
@property
def size( self ):
return self._NoneIfNotSet( self._size )
def size(self):
return self._NoneIfNotSet(self._size)
@property
def type( self ):
return self._NoneIfNotSet( self._type )
def type(self):
return self._NoneIfNotSet(self._type)
@property
def url( self ):
return self._NoneIfNotSet( self._url )
def url(self):
return self._NoneIfNotSet(self._url)
def _initAttributes( self ):
def _initAttributes(self):
self._mode = GithubObject.NotSet
self._path = GithubObject.NotSet
self._sha = GithubObject.NotSet
@@ -46,22 +47,22 @@ class GitTreeElement( GithubObject.BasicGithubObject ):
self._type = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "mode" in attributes: # pragma no branch
assert attributes[ "mode" ] is None or isinstance( attributes[ "mode" ], ( str, unicode ) ), attributes[ "mode" ]
self._mode = attributes[ "mode" ]
if "path" in attributes: # pragma no branch
assert attributes[ "path" ] is None or isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ]
self._path = attributes[ "path" ]
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 "size" in attributes: # pragma no branch
assert attributes[ "size" ] is None or isinstance( attributes[ "size" ], int ), 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" ]
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
def _useAttributes(self, attributes):
if "mode" in attributes: # pragma no branch
assert attributes["mode"] is None or isinstance(attributes["mode"], (str, unicode)), attributes["mode"]
self._mode = attributes["mode"]
if "path" in attributes: # pragma no branch
assert attributes["path"] is None or isinstance(attributes["path"], (str, unicode)), attributes["path"]
self._path = attributes["path"]
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 "size" in attributes: # pragma no branch
assert attributes["size"] is None or isinstance(attributes["size"], int), 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"]
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+35 -33
View File
@@ -24,21 +24,23 @@ import Legacy
import GithubObject
import HookDescription
DEFAULT_BASE_URL = "https://api.github.com"
DEFAULT_TIMEOUT = 10
class Github( object ):
def __init__( self, login_or_token = None, password = None, base_url = DEFAULT_BASE_URL, timeout = DEFAULT_TIMEOUT):
self.__requester = Requester( login_or_token, password, base_url, timeout )
class Github(object):
def __init__(self, login_or_token=None, password=None, base_url=DEFAULT_BASE_URL, timeout=DEFAULT_TIMEOUT):
self.__requester = Requester(login_or_token, password, base_url, timeout)
@property
def rate_limiting( self ):
def rate_limiting(self):
return self.__requester.rate_limiting
def get_user( self, login = GithubObject.NotSet ):
assert login is GithubObject.NotSet or isinstance( login, ( str, unicode ) ), login
def get_user(self, login=GithubObject.NotSet):
assert login is GithubObject.NotSet or isinstance(login, (str, unicode)), login
if login is 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.requestAndCheck(
"GET",
@@ -46,29 +48,29 @@ class Github( object ):
None,
None
)
return NamedUser.NamedUser( self.__requester, data, completed = True )
return NamedUser.NamedUser(self.__requester, data, completed=True)
def get_organization( self, login ):
assert isinstance( login, ( str, unicode ) ), login
def get_organization(self, login):
assert isinstance(login, (str, unicode)), login
headers, data = self.__requester.requestAndCheck(
"GET",
"/orgs/" + login,
None,
None
)
return Organization.Organization( self.__requester, data, completed = True )
return Organization.Organization(self.__requester, data, completed=True)
def get_gist( self, id ):
assert isinstance( id, ( str, unicode ) ), id
def get_gist(self, id):
assert isinstance(id, (str, unicode)), id
headers, data = self.__requester.requestAndCheck(
"GET",
"/gists/" + id,
None,
None
)
return Gist.Gist( self.__requester, data, completed = True )
return Gist.Gist(self.__requester, data, completed=True)
def get_gists( self ):
def get_gists(self):
return PaginatedList.PaginatedList(
Gist.Gist,
self.__requester,
@@ -76,12 +78,12 @@ class Github( object ):
None
)
def legacy_search_repos( self, keyword, language = GithubObject.NotSet ):
assert isinstance( keyword, ( str, unicode ) ), keyword
assert language is GithubObject.NotSet or isinstance( language, ( str, unicode ) ), language
args = {} if language is GithubObject.NotSet else { "language": language }
def legacy_search_repos(self, keyword, language=GithubObject.NotSet):
assert isinstance(keyword, (str, unicode)), keyword
assert language is GithubObject.NotSet or isinstance(language, (str, unicode)), language
args = {} if language is GithubObject.NotSet else {"language": language}
return Legacy.PaginatedList(
"/legacy/repos/search/" + urllib.quote( keyword ),
"/legacy/repos/search/" + urllib.quote(keyword),
args,
self.__requester,
"repositories",
@@ -89,10 +91,10 @@ class Github( object ):
Repository.Repository,
)
def legacy_search_users( self, keyword ):
assert isinstance( keyword, ( str, unicode ) ), keyword
def legacy_search_users(self, keyword):
assert isinstance(keyword, (str, unicode)), keyword
return Legacy.PaginatedList(
"/legacy/user/search/" + urllib.quote( keyword ),
"/legacy/user/search/" + urllib.quote(keyword),
{},
self.__requester,
"users",
@@ -100,25 +102,25 @@ class Github( object ):
NamedUser.NamedUser,
)
def legacy_search_user_by_email( self, email ):
assert isinstance( email, ( str, unicode ) ), email
def legacy_search_user_by_email(self, email):
assert isinstance(email, (str, unicode)), email
headers, data = self.__requester.requestAndCheck(
"GET",
"/legacy/user/email/" + email,
None,
None
)
return NamedUser.NamedUser( self.__requester, Legacy.convertUser( data[ "user" ] ), completed = False )
return NamedUser.NamedUser(self.__requester, Legacy.convertUser(data["user"]), completed=False)
def render_markdown( self, text, context = GithubObject.NotSet ):
assert isinstance( text, ( str, unicode ) ), text
assert context is GithubObject.NotSet or isinstance( context, Repository.Repository ), context
def render_markdown(self, text, context=GithubObject.NotSet):
assert isinstance(text, (str, unicode)), text
assert context is GithubObject.NotSet or isinstance(context, Repository.Repository), context
post_parameters = {
"text": text
}
if context is not GithubObject.NotSet:
post_parameters[ "mode" ] = "gfm"
post_parameters[ "context" ] = context._identity
post_parameters["mode"] = "gfm"
post_parameters["context"] = context._identity
status, headers, data = self.__requester.requestRaw(
"POST",
"/markdown",
@@ -127,11 +129,11 @@ class Github( object ):
)
return data
def get_hooks( self ):
def get_hooks(self):
headers, data = self.__requester.requestAndCheck(
"GET",
"/hooks",
None,
None
)
return [ HookDescription.HookDescription( self.__requester, attributes, completed = True ) for attributes in data ]
return [HookDescription.HookDescription(self.__requester, attributes, completed=True) for attributes in data]
+6 -5
View File
@@ -11,11 +11,12 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
class GithubException( Exception ):
def __init__( self, status, data ):
Exception.__init__( self )
class GithubException(Exception):
def __init__(self, status, data):
Exception.__init__(self)
self.status = status
self.data = data
def __str__( self ):
return str( self.status ) + " " + str( self.data )
def __str__(self):
return str(self.status) + " " + str(self.data)
+21 -18
View File
@@ -15,53 +15,56 @@ import datetime
import GithubException
class _NotSetType:
pass
NotSet = _NotSetType()
class BasicGithubObject( object ):
def __init__( self, requester, attributes, completed ): ### 'completed' may be removed if I find a way
class BasicGithubObject(object):
def __init__(self, requester, attributes, completed): # 'completed' may be removed if I find a way
self._requester = requester
self._initAttributes()
self._useAttributes( attributes )
self._useAttributes(attributes)
@staticmethod
def _parentUrl( url ):
return "/".join( url.split( "/" )[ : -1 ] )
def _parentUrl(url):
return "/".join(url.split("/")[: -1])
@staticmethod
def _NoneIfNotSet( value ):
def _NoneIfNotSet(value):
if value is NotSet:
return None
else:
return value
@staticmethod
def _parseDatetime( s ):
def _parseDatetime(s):
if s is None:
return None
elif len( s ) == 24:
return datetime.datetime.strptime( s, "%Y-%m-%dT%H:%M:%S.000Z" )
elif len( s ) == 25:
return datetime.datetime.strptime( s[ : 19 ], "%Y-%m-%dT%H:%M:%S" ) + ( 1 if s[ 19 ] == '-' else -1 ) * datetime.timedelta( hours = int( s[ 20 : 22 ] ), minutes = int( s[ 23 : 25 ] ) )
elif len(s) == 24:
return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%S.000Z")
elif len(s) == 25:
return datetime.datetime.strptime(s[:19], "%Y-%m-%dT%H:%M:%S") + (1 if s[19] == '-' else -1) * datetime.timedelta(hours=int(s[20:22]), minutes=int(s[23:25]))
else:
return datetime.datetime.strptime( s, "%Y-%m-%dT%H:%M:%SZ" )
return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%SZ")
class GithubObject( BasicGithubObject ):
def __init__( self, requester, attributes, completed ):
BasicGithubObject.__init__( self, requester, attributes, completed )
class GithubObject(BasicGithubObject):
def __init__(self, requester, attributes, completed):
BasicGithubObject.__init__(self, requester, attributes, completed)
self.__completed = completed
def _completeIfNotSet( self, value ):
def _completeIfNotSet(self, value):
if not self.__completed and value is NotSet:
self.__complete()
def __complete( self ):
def __complete(self):
headers, data = self._requester.requestAndCheck(
"GET",
self._url,
None,
None
)
self._useAttributes( data )
self._useAttributes(data)
self._completed = True
+72 -71
View File
@@ -15,53 +15,54 @@ import GithubObject
import HookResponse
class Hook( GithubObject.GithubObject ):
class Hook(GithubObject.GithubObject):
@property
def active( self ):
self._completeIfNotSet( self._active )
return self._NoneIfNotSet( self._active )
def active(self):
self._completeIfNotSet(self._active)
return self._NoneIfNotSet(self._active)
@property
def config( self ):
self._completeIfNotSet( self._config )
return self._NoneIfNotSet( self._config )
def config(self):
self._completeIfNotSet(self._config)
return self._NoneIfNotSet(self._config)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def events( self ):
self._completeIfNotSet( self._events )
return self._NoneIfNotSet( self._events )
def events(self):
self._completeIfNotSet(self._events)
return self._NoneIfNotSet(self._events)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def last_response( self ):
self._completeIfNotSet( self._last_response )
return self._NoneIfNotSet( self._last_response )
def last_response(self):
self._completeIfNotSet(self._last_response)
return self._NoneIfNotSet(self._last_response)
@property
def name( self ):
self._completeIfNotSet( self._name )
return self._NoneIfNotSet( self._name )
def name(self):
self._completeIfNotSet(self._name)
return self._NoneIfNotSet(self._name)
@property
def updated_at( self ):
self._completeIfNotSet( self._updated_at )
return self._NoneIfNotSet( self._updated_at )
def updated_at(self):
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -69,34 +70,34 @@ class Hook( GithubObject.GithubObject ):
None
)
def edit( self, name, config, events = GithubObject.NotSet, add_events = GithubObject.NotSet, remove_events = GithubObject.NotSet, active = GithubObject.NotSet ):
assert isinstance( name, ( str, unicode ) ), name
assert isinstance( config, dict ), config
assert events is GithubObject.NotSet or all( isinstance( element, ( str, unicode ) ) for element in events ), events
assert add_events is GithubObject.NotSet or all( isinstance( element, ( str, unicode ) ) for element in add_events ), add_events
assert remove_events is GithubObject.NotSet or all( isinstance( element, ( str, unicode ) ) for element in remove_events ), remove_events
assert active is GithubObject.NotSet or isinstance( active, bool ), active
def edit(self, name, config, events=GithubObject.NotSet, add_events=GithubObject.NotSet, remove_events=GithubObject.NotSet, active=GithubObject.NotSet):
assert isinstance(name, (str, unicode)), name
assert isinstance(config, dict), config
assert events is GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in events), events
assert add_events is GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in add_events), add_events
assert remove_events is GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in remove_events), remove_events
assert active is GithubObject.NotSet or isinstance(active, bool), active
post_parameters = {
"name": name,
"config": config,
}
if events is not GithubObject.NotSet:
post_parameters[ "events" ] = events
post_parameters["events"] = events
if add_events is not GithubObject.NotSet:
post_parameters[ "add_events" ] = add_events
post_parameters["add_events"] = add_events
if remove_events is not GithubObject.NotSet:
post_parameters[ "remove_events" ] = remove_events
post_parameters["remove_events"] = remove_events
if active is not GithubObject.NotSet:
post_parameters[ "active" ] = active
post_parameters["active"] = active
headers, data = self._requester.requestAndCheck(
"PATCH",
self.url,
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def test( self ):
def test(self):
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/test",
@@ -104,7 +105,7 @@ class Hook( GithubObject.GithubObject ):
None
)
def _initAttributes( self ):
def _initAttributes(self):
self._active = GithubObject.NotSet
self._config = GithubObject.NotSet
self._created_at = GithubObject.NotSet
@@ -115,31 +116,31 @@ class Hook( GithubObject.GithubObject ):
self._updated_at = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "active" in attributes: # pragma no branch
assert attributes[ "active" ] is None or isinstance( attributes[ "active" ], bool ), attributes[ "active" ]
self._active = attributes[ "active" ]
if "config" in attributes: # pragma no branch
assert attributes[ "config" ] is None or isinstance( attributes[ "config" ], dict ), attributes[ "config" ]
self._config = attributes[ "config" ]
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" in attributes: # pragma no branch
assert attributes[ "events" ] is None or all( isinstance( element, ( str, unicode ) ) for element in attributes[ "events" ] ), attributes[ "events" ]
self._events = attributes[ "events" ]
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
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 HookResponse.HookResponse( self._requester, 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 "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" ]
def _useAttributes(self, attributes):
if "active" in attributes: # pragma no branch
assert attributes["active"] is None or isinstance(attributes["active"], bool), attributes["active"]
self._active = attributes["active"]
if "config" in attributes: # pragma no branch
assert attributes["config"] is None or isinstance(attributes["config"], dict), attributes["config"]
self._config = attributes["config"]
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" in attributes: # pragma no branch
assert attributes["events"] is None or all(isinstance(element, (str, unicode)) for element in attributes["events"]), attributes["events"]
self._events = attributes["events"]
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], int), attributes["id"]
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 HookResponse.HookResponse(self._requester, 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 "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"]
+24 -23
View File
@@ -13,39 +13,40 @@
import GithubObject
class HookDescription( GithubObject.BasicGithubObject ):
class HookDescription(GithubObject.BasicGithubObject):
@property
def events( self ):
return self._NoneIfNotSet( self._events )
def events(self):
return self._NoneIfNotSet(self._events)
@property
def name( self ):
return self._NoneIfNotSet( self._name )
def name(self):
return self._NoneIfNotSet(self._name)
@property
def schema( self ):
return self._NoneIfNotSet( self._schema )
def schema(self):
return self._NoneIfNotSet(self._schema)
@property
def supported_events( self ):
return self._NoneIfNotSet( self._supported_events )
def supported_events(self):
return self._NoneIfNotSet(self._supported_events)
def _initAttributes( self ):
def _initAttributes(self):
self._events = GithubObject.NotSet
self._name = GithubObject.NotSet
self._schema = GithubObject.NotSet
self._supported_events = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "events" in attributes: # pragma no branch
assert attributes[ "events" ] is None or all( isinstance( element, ( str, unicode ) ) for element in attributes[ "events" ] ), attributes[ "events" ]
self._events = attributes[ "events" ]
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 "schema" in attributes: # pragma no branch
assert attributes[ "schema" ] is None or all( isinstance( element, list ) for element in attributes[ "schema" ] ), attributes[ "schema" ]
self._schema = attributes[ "schema" ]
if "supported_events" in attributes: # pragma no branch
assert attributes[ "supported_events" ] is None or all( isinstance( element, ( str, unicode ) ) for element in attributes[ "supported_events" ] ), attributes[ "supported_events" ]
self._supported_events = attributes[ "supported_events" ]
def _useAttributes(self, attributes):
if "events" in attributes: # pragma no branch
assert attributes["events"] is None or all(isinstance(element, (str, unicode)) for element in attributes["events"]), attributes["events"]
self._events = attributes["events"]
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 "schema" in attributes: # pragma no branch
assert attributes["schema"] is None or all(isinstance(element, list) for element in attributes["schema"]), attributes["schema"]
self._schema = attributes["schema"]
if "supported_events" in attributes: # pragma no branch
assert attributes["supported_events"] is None or all(isinstance(element, (str, unicode)) for element in attributes["supported_events"]), attributes["supported_events"]
self._supported_events = attributes["supported_events"]
+19 -18
View File
@@ -13,31 +13,32 @@
import GithubObject
class HookResponse( GithubObject.BasicGithubObject ):
class HookResponse(GithubObject.BasicGithubObject):
@property
def code( self ):
return self._NoneIfNotSet( self._code )
def code(self):
return self._NoneIfNotSet(self._code)
@property
def message( self ):
return self._NoneIfNotSet( self._message )
def message(self):
return self._NoneIfNotSet(self._message)
@property
def status( self ):
return self._NoneIfNotSet( self._status )
def status(self):
return self._NoneIfNotSet(self._status)
def _initAttributes( self ):
def _initAttributes(self):
self._code = GithubObject.NotSet
self._message = GithubObject.NotSet
self._status = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "code" in attributes: # pragma no branch
assert attributes[ "code" ] is None or isinstance( attributes[ "code" ], int ), attributes[ "code" ]
self._code = attributes[ "code" ]
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 "status" in attributes: # pragma no branch
assert attributes[ "status" ] is None or isinstance( attributes[ "status" ], ( str, unicode ) ), attributes[ "status" ]
self._status = attributes[ "status" ]
def _useAttributes(self, attributes):
if "code" in attributes: # pragma no branch
assert attributes["code"] is None or isinstance(attributes["code"], int), attributes["code"]
self._code = attributes["code"]
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 "status" in attributes: # pragma no branch
assert attributes["status"] is None or isinstance(attributes["status"], (str, unicode)), attributes["status"]
self._status = attributes["status"]
+4 -3
View File
@@ -11,12 +11,13 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
class InputFileContent( object ):
def __init__( self, content ):
class InputFileContent(object):
def __init__(self, content):
self.__content = content
@property
def _identity( self ):
def _identity(self):
return {
"content": self.__content,
}
+4 -3
View File
@@ -11,14 +11,15 @@
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
class InputGitAuthor( object ):
def __init__( self, name, email, date ):
class InputGitAuthor(object):
def __init__(self, name, email, date):
self.__name = name
self.__email = email
self.__date = date
@property
def _identity( self ):
def _identity(self):
return {
"name": self.__name,
"email": self.__email,
+6 -5
View File
@@ -13,8 +13,9 @@
import GithubObject
class InputGitTreeElement( object ):
def __init__( self, path, mode, type, content = GithubObject.NotSet, sha = GithubObject.NotSet ):
class InputGitTreeElement(object):
def __init__(self, path, mode, type, content=GithubObject.NotSet, sha=GithubObject.NotSet):
self.__path = path
self.__mode = mode
self.__type = type
@@ -22,14 +23,14 @@ class InputGitTreeElement( object ):
self.__sha = sha
@property
def _identity( self ):
def _identity(self):
identity = {
"path": self.__path,
"mode": self.__mode,
"type": self.__type,
}
if self.__sha is not GithubObject.NotSet:
identity[ "sha" ] = self.__sha
identity["sha"] = self.__sha
if self.__content is not GithubObject.NotSet:
identity[ "content" ] = self.__content
identity["content"] = self.__content
return identity
+148 -147
View File
@@ -22,100 +22,101 @@ import Milestone
import IssueComment
import IssuePullRequest
class Issue( GithubObject.GithubObject ):
class Issue(GithubObject.GithubObject):
@property
def assignee( self ):
self._completeIfNotSet( self._assignee )
return self._NoneIfNotSet( self._assignee )
def assignee(self):
self._completeIfNotSet(self._assignee)
return self._NoneIfNotSet(self._assignee)
@property
def body( self ):
self._completeIfNotSet( self._body )
return self._NoneIfNotSet( self._body )
def body(self):
self._completeIfNotSet(self._body)
return self._NoneIfNotSet(self._body)
@property
def closed_at( self ):
self._completeIfNotSet( self._closed_at )
return self._NoneIfNotSet( self._closed_at )
def closed_at(self):
self._completeIfNotSet(self._closed_at)
return self._NoneIfNotSet(self._closed_at)
@property
def closed_by( self ):
self._completeIfNotSet( self._closed_by )
return self._NoneIfNotSet( self._closed_by )
def closed_by(self):
self._completeIfNotSet(self._closed_by)
return self._NoneIfNotSet(self._closed_by)
@property
def comments( self ):
self._completeIfNotSet( self._comments )
return self._NoneIfNotSet( self._comments )
def comments(self):
self._completeIfNotSet(self._comments)
return self._NoneIfNotSet(self._comments)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def html_url( self ):
self._completeIfNotSet( self._html_url )
return self._NoneIfNotSet( self._html_url )
def html_url(self):
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def labels( self ):
self._completeIfNotSet( self._labels )
return self._NoneIfNotSet( self._labels )
def labels(self):
self._completeIfNotSet(self._labels)
return self._NoneIfNotSet(self._labels)
@property
def milestone( self ):
self._completeIfNotSet( self._milestone )
return self._NoneIfNotSet( self._milestone )
def milestone(self):
self._completeIfNotSet(self._milestone)
return self._NoneIfNotSet(self._milestone)
@property
def number( self ):
self._completeIfNotSet( self._number )
return self._NoneIfNotSet( self._number )
def number(self):
self._completeIfNotSet(self._number)
return self._NoneIfNotSet(self._number)
@property
def pull_request( self ):
self._completeIfNotSet( self._pull_request )
return self._NoneIfNotSet( self._pull_request )
def pull_request(self):
self._completeIfNotSet(self._pull_request)
return self._NoneIfNotSet(self._pull_request)
@property
def repository( self ):
self._completeIfNotSet( self._repository )
return self._NoneIfNotSet( self._repository )
def repository(self):
self._completeIfNotSet(self._repository)
return self._NoneIfNotSet(self._repository)
@property
def state( self ):
self._completeIfNotSet( self._state )
return self._NoneIfNotSet( self._state )
def state(self):
self._completeIfNotSet(self._state)
return self._NoneIfNotSet(self._state)
@property
def title( self ):
self._completeIfNotSet( self._title )
return self._NoneIfNotSet( self._title )
def title(self):
self._completeIfNotSet(self._title)
return self._NoneIfNotSet(self._title)
@property
def updated_at( self ):
self._completeIfNotSet( self._updated_at )
return self._NoneIfNotSet( self._updated_at )
def updated_at(self):
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
@property
def user( self ):
self._completeIfNotSet( self._user )
return self._NoneIfNotSet( self._user )
def user(self):
self._completeIfNotSet(self._user)
return self._NoneIfNotSet(self._user)
def add_to_labels( self, *labels ):
assert all( isinstance( element, Label.Label ) for element in labels ), labels
post_parameters = [ label.name for label in labels ]
def add_to_labels(self, *labels):
assert all(isinstance(element, Label.Label) for element in labels), labels
post_parameters = [label.name for label in labels]
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/labels",
@@ -123,8 +124,8 @@ class Issue( GithubObject.GithubObject ):
post_parameters
)
def create_comment( self, body ):
assert isinstance( body, ( str, unicode ) ), body
def create_comment(self, body):
assert isinstance(body, (str, unicode)), body
post_parameters = {
"body": body,
}
@@ -134,9 +135,9 @@ class Issue( GithubObject.GithubObject ):
None,
post_parameters
)
return IssueComment.IssueComment( self._requester, data, completed = True )
return IssueComment.IssueComment(self._requester, data, completed=True)
def delete_labels( self ):
def delete_labels(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url + "/labels",
@@ -144,45 +145,45 @@ class Issue( GithubObject.GithubObject ):
None
)
def edit( self, title = GithubObject.NotSet, body = GithubObject.NotSet, assignee = GithubObject.NotSet, state = GithubObject.NotSet, milestone = GithubObject.NotSet, labels = GithubObject.NotSet ):
assert title is GithubObject.NotSet or isinstance( title, ( str, unicode ) ), title
assert body is GithubObject.NotSet or isinstance( body, ( str, unicode ) ), body
assert assignee is GithubObject.NotSet or assignee is None or isinstance( assignee, NamedUser.NamedUser ), assignee
assert state is GithubObject.NotSet or isinstance( state, ( str, unicode ) ), state
assert milestone is GithubObject.NotSet or milestone is None or isinstance( milestone, Milestone.Milestone ), milestone
assert labels is GithubObject.NotSet or all( isinstance( element, ( str, unicode ) ) for element in labels ), labels
def edit(self, title=GithubObject.NotSet, body=GithubObject.NotSet, assignee=GithubObject.NotSet, state=GithubObject.NotSet, milestone=GithubObject.NotSet, labels=GithubObject.NotSet):
assert title is GithubObject.NotSet or isinstance(title, (str, unicode)), title
assert body is GithubObject.NotSet or isinstance(body, (str, unicode)), body
assert assignee is GithubObject.NotSet or assignee is None or isinstance(assignee, NamedUser.NamedUser), assignee
assert state is GithubObject.NotSet or isinstance(state, (str, unicode)), state
assert milestone is GithubObject.NotSet or milestone is None or isinstance(milestone, Milestone.Milestone), milestone
assert labels is GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in labels), labels
post_parameters = dict()
if title is not GithubObject.NotSet:
post_parameters[ "title" ] = title
post_parameters["title"] = title
if body is not GithubObject.NotSet:
post_parameters[ "body" ] = body
post_parameters["body"] = body
if assignee is not GithubObject.NotSet:
post_parameters[ "assignee" ] = assignee._identity if assignee else ''
post_parameters["assignee"] = assignee._identity if assignee else ''
if state is not GithubObject.NotSet:
post_parameters[ "state" ] = state
post_parameters["state"] = state
if milestone is not GithubObject.NotSet:
post_parameters[ "milestone" ] = milestone._identity if milestone else ''
post_parameters["milestone"] = milestone._identity if milestone else ''
if labels is not GithubObject.NotSet:
post_parameters[ "labels" ] = labels
post_parameters["labels"] = labels
headers, data = self._requester.requestAndCheck(
"PATCH",
self.url,
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def get_comment( self, id ):
assert isinstance( id, int ), id
def get_comment(self, id):
assert isinstance(id, int), id
headers, data = self._requester.requestAndCheck(
"GET",
self._parentUrl( self.url ) + "/comments/" + str( id ),
self._parentUrl(self.url) + "/comments/" + str(id),
None,
None
)
return IssueComment.IssueComment( self._requester, data, completed = True )
return IssueComment.IssueComment(self._requester, data, completed=True)
def get_comments( self ):
def get_comments(self):
return PaginatedList.PaginatedList(
IssueComment.IssueComment,
self._requester,
@@ -190,7 +191,7 @@ class Issue( GithubObject.GithubObject ):
None
)
def get_events( self ):
def get_events(self):
return PaginatedList.PaginatedList(
IssueEvent.IssueEvent,
self._requester,
@@ -198,7 +199,7 @@ class Issue( GithubObject.GithubObject ):
None
)
def get_labels( self ):
def get_labels(self):
return PaginatedList.PaginatedList(
Label.Label,
self._requester,
@@ -206,8 +207,8 @@ class Issue( GithubObject.GithubObject ):
None
)
def remove_from_labels( self, label ):
assert isinstance( label, Label.Label ), label
def remove_from_labels(self, label):
assert isinstance(label, Label.Label), label
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url + "/labels/" + label._identity,
@@ -215,9 +216,9 @@ class Issue( GithubObject.GithubObject ):
None
)
def set_labels( self, *labels ):
assert all( isinstance( element, Label.Label ) for element in labels ), labels
post_parameters = [ label.name for label in labels ]
def set_labels(self, *labels):
assert all(isinstance(element, Label.Label) for element in labels), labels
post_parameters = [label.name for label in labels]
headers, data = self._requester.requestAndCheck(
"PUT",
self.url + "/labels",
@@ -226,10 +227,10 @@ class Issue( GithubObject.GithubObject ):
)
@property
def _identity( self ):
def _identity(self):
return self.number
def _initAttributes( self ):
def _initAttributes(self):
self._assignee = GithubObject.NotSet
self._body = GithubObject.NotSet
self._closed_at = GithubObject.NotSet
@@ -249,61 +250,61 @@ class Issue( GithubObject.GithubObject ):
self._url = GithubObject.NotSet
self._user = GithubObject.NotSet
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 NamedUser.NamedUser( self._requester, 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" ]
if "closed_at" in attributes: # pragma no branch
assert attributes[ "closed_at" ] is None or isinstance( attributes[ "closed_at" ], ( str, unicode ) ), attributes[ "closed_at" ]
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 NamedUser.NamedUser( self._requester, attributes[ "closed_by" ], completed = False )
if "comments" in attributes: # pragma no branch
assert attributes[ "comments" ] is None or isinstance( attributes[ "comments" ], int ), attributes[ "comments" ]
self._comments = attributes[ "comments" ]
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 "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" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
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 [
Label.Label( self._requester, element, completed = False )
for element in attributes[ "labels" ]
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 NamedUser.NamedUser(self._requester, 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"]
if "closed_at" in attributes: # pragma no branch
assert attributes["closed_at"] is None or isinstance(attributes["closed_at"], (str, unicode)), attributes["closed_at"]
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 NamedUser.NamedUser(self._requester, attributes["closed_by"], completed=False)
if "comments" in attributes: # pragma no branch
assert attributes["comments"] is None or isinstance(attributes["comments"], int), attributes["comments"]
self._comments = attributes["comments"]
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 "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"], int), attributes["id"]
self._id = attributes["id"]
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 [
Label.Label(self._requester, element, completed=False)
for element in attributes["labels"]
]
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 Milestone.Milestone( self._requester, attributes[ "milestone" ], completed = False )
if "number" in attributes: # pragma no branch
assert attributes[ "number" ] is None or isinstance( attributes[ "number" ], int ), 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 IssuePullRequest.IssuePullRequest( self._requester, 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 Repository.Repository( self._requester, 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" ]
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" ]
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 NamedUser.NamedUser( self._requester, attributes[ "user" ], 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 Milestone.Milestone(self._requester, attributes["milestone"], completed=False)
if "number" in attributes: # pragma no branch
assert attributes["number"] is None or isinstance(attributes["number"], int), 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 IssuePullRequest.IssuePullRequest(self._requester, 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 Repository.Repository(self._requester, 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"]
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"]
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 NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
+44 -43
View File
@@ -15,38 +15,39 @@ import GithubObject
import NamedUser
class IssueComment( GithubObject.GithubObject ):
class IssueComment(GithubObject.GithubObject):
@property
def body( self ):
self._completeIfNotSet( self._body )
return self._NoneIfNotSet( self._body )
def body(self):
self._completeIfNotSet(self._body)
return self._NoneIfNotSet(self._body)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def updated_at( self ):
self._completeIfNotSet( self._updated_at )
return self._NoneIfNotSet( self._updated_at )
def updated_at(self):
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
@property
def user( self ):
self._completeIfNotSet( self._user )
return self._NoneIfNotSet( self._user )
def user(self):
self._completeIfNotSet(self._user)
return self._NoneIfNotSet(self._user)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -54,8 +55,8 @@ class IssueComment( GithubObject.GithubObject ):
None
)
def edit( self, body ):
assert isinstance( body, ( str, unicode ) ), body
def edit(self, body):
assert isinstance(body, (str, unicode)), body
post_parameters = {
"body": body,
}
@@ -65,9 +66,9 @@ class IssueComment( GithubObject.GithubObject ):
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def _initAttributes( self ):
def _initAttributes(self):
self._body = GithubObject.NotSet
self._created_at = GithubObject.NotSet
self._id = GithubObject.NotSet
@@ -75,22 +76,22 @@ class IssueComment( GithubObject.GithubObject ):
self._url = GithubObject.NotSet
self._user = 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 "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 "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
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 NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False )
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 "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 "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], int), attributes["id"]
self._id = attributes["id"]
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 NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
+46 -45
View File
@@ -16,43 +16,44 @@ import GithubObject
import Issue
import NamedUser
class IssueEvent( GithubObject.GithubObject ):
class IssueEvent(GithubObject.GithubObject):
@property
def actor( self ):
self._completeIfNotSet( self._actor )
return self._NoneIfNotSet( self._actor )
def actor(self):
self._completeIfNotSet(self._actor)
return self._NoneIfNotSet(self._actor)
@property
def commit_id( self ):
self._completeIfNotSet( self._commit_id )
return self._NoneIfNotSet( self._commit_id )
def commit_id(self):
self._completeIfNotSet(self._commit_id)
return self._NoneIfNotSet(self._commit_id)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def event( self ):
self._completeIfNotSet( self._event )
return self._NoneIfNotSet( self._event )
def event(self):
self._completeIfNotSet(self._event)
return self._NoneIfNotSet(self._event)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def issue( self ):
self._completeIfNotSet( self._issue )
return self._NoneIfNotSet( self._issue )
def issue(self):
self._completeIfNotSet(self._issue)
return self._NoneIfNotSet(self._issue)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def _initAttributes( self ):
def _initAttributes(self):
self._actor = GithubObject.NotSet
self._commit_id = GithubObject.NotSet
self._created_at = GithubObject.NotSet
@@ -61,25 +62,25 @@ class IssueEvent( GithubObject.GithubObject ):
self._issue = GithubObject.NotSet
self._url = GithubObject.NotSet
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 NamedUser.NamedUser( self._requester, 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" ]
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 "event" in attributes: # pragma no branch
assert attributes[ "event" ] is None or isinstance( attributes[ "event" ], ( str, unicode ) ), attributes[ "event" ]
self._event = attributes[ "event" ]
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
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 Issue.Issue( self._requester, 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" ]
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 NamedUser.NamedUser(self._requester, 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"]
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 "event" in attributes: # pragma no branch
assert attributes["event"] is None or isinstance(attributes["event"], (str, unicode)), attributes["event"]
self._event = attributes["event"]
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], int), attributes["id"]
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 Issue.Issue(self._requester, 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"]
+19 -18
View File
@@ -13,31 +13,32 @@
import GithubObject
class IssuePullRequest( GithubObject.BasicGithubObject ):
class IssuePullRequest(GithubObject.BasicGithubObject):
@property
def diff_url( self ):
return self._NoneIfNotSet( self._diff_url )
def diff_url(self):
return self._NoneIfNotSet(self._diff_url)
@property
def html_url( self ):
return self._NoneIfNotSet( self._html_url )
def html_url(self):
return self._NoneIfNotSet(self._html_url)
@property
def patch_url( self ):
return self._NoneIfNotSet( self._patch_url )
def patch_url(self):
return self._NoneIfNotSet(self._patch_url)
def _initAttributes( self ):
def _initAttributes(self):
self._diff_url = GithubObject.NotSet
self._html_url = GithubObject.NotSet
self._patch_url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "diff_url" in attributes: # pragma no branch
assert attributes[ "diff_url" ] is None or isinstance( attributes[ "diff_url" ], ( str, unicode ) ), attributes[ "diff_url" ]
self._diff_url = attributes[ "diff_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 "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" ]
def _useAttributes(self, attributes):
if "diff_url" in attributes: # pragma no branch
assert attributes["diff_url"] is None or isinstance(attributes["diff_url"], (str, unicode)), attributes["diff_url"]
self._diff_url = attributes["diff_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 "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"]
+29 -28
View File
@@ -15,23 +15,24 @@ import urllib
import GithubObject
class Label( GithubObject.GithubObject ):
class Label(GithubObject.GithubObject):
@property
def color( self ):
self._completeIfNotSet( self._color )
return self._NoneIfNotSet( self._color )
def color(self):
self._completeIfNotSet(self._color)
return self._NoneIfNotSet(self._color)
@property
def name( self ):
self._completeIfNotSet( self._name )
return self._NoneIfNotSet( self._name )
def name(self):
self._completeIfNotSet(self._name)
return self._NoneIfNotSet(self._name)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -39,9 +40,9 @@ class Label( GithubObject.GithubObject ):
None
)
def edit( self, name, color ):
assert isinstance( name, ( str, unicode ) ), name
assert isinstance( color, ( str, unicode ) ), color
def edit(self, name, color):
assert isinstance(name, (str, unicode)), name
assert isinstance(color, (str, unicode)), color
post_parameters = {
"name": name,
"color": color,
@@ -52,24 +53,24 @@ class Label( GithubObject.GithubObject ):
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
@property
def _identity( self ):
return urllib.quote( self.name )
def _identity(self):
return urllib.quote(self.name)
def _initAttributes( self ):
def _initAttributes(self):
self._color = GithubObject.NotSet
self._name = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "color" in attributes: # pragma no branch
assert attributes[ "color" ] is None or isinstance( attributes[ "color" ], ( str, unicode ) ), attributes[ "color" ]
self._color = attributes[ "color" ]
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 "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
def _useAttributes(self, attributes):
if "color" in attributes: # pragma no branch
assert attributes["color"] is None or isinstance(attributes["color"], (str, unicode)), attributes["color"]
self._color = attributes["color"]
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 "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+83 -51
View File
@@ -15,9 +15,10 @@ import urlparse
from PaginatedList import PaginatedListBase
class PaginatedList( PaginatedListBase ):
def __init__( self, url, args, requester, key, convert, contentClass ):
PaginatedListBase.__init__( self )
class PaginatedList(PaginatedListBase):
def __init__(self, url, args, requester, key, convert, contentClass):
PaginatedListBase.__init__(self)
self.__url = url
self.__args = args
self.__requester = requester
@@ -27,77 +28,108 @@ class PaginatedList( PaginatedListBase ):
self.__nextPage = 0
self.__continue = True
def _couldGrow( self ):
def _couldGrow(self):
return self.__continue
def _fetchNextPage( self ):
def _fetchNextPage(self):
page = self.__nextPage
self.__nextPage += 1
return self.get_page( page )
return self.get_page(page)
def get_page( self, page ):
assert isinstance( page, int ), page
args = dict( self.__args )
def get_page(self, page):
assert isinstance(page, int), page
args = dict(self.__args)
if page != 0:
args[ "start_page" ] = page + 1
args["start_page"] = page + 1
headers, data = self.__requester.requestAndCheck(
"GET",
self.__url,
args,
None
)
self.__continue = len( data[ self.__key ] ) > 0
self.__continue = len(data[self.__key]) > 0
return [
self.__contentClass( self.__requester, self.__convert( element ), completed = False )
for element in data[ self.__key ]
self.__contentClass(self.__requester, self.__convert(element), completed=False)
for element in data[self.__key]
]
def convertUser( attributes ):
def convertUser(attributes):
convertedAttributes = {
"login": attributes[ "login" ],
"url": "/users/" + attributes[ "login" ],
"login": attributes["login"],
"url": "/users/" + attributes["login"],
}
if "gravatar_id" in attributes: convertedAttributes[ "gravatar_id" ] = attributes[ "gravatar_id" ]
if "followers" in attributes: convertedAttributes[ "followers" ] = attributes[ "followers" ]
if "repos" in attributes: convertedAttributes[ "public_repos" ] = attributes[ "repos" ]
if "name" in attributes: convertedAttributes[ "name" ] = attributes[ "name" ]
if "created_at" in attributes: convertedAttributes[ "created_at" ] = attributes[ "created_at" ]
if "location" in attributes: convertedAttributes[ "location" ] = attributes[ "location" ]
if "gravatar_id" in attributes:
convertedAttributes["gravatar_id"] = attributes["gravatar_id"]
if "followers" in attributes:
convertedAttributes["followers"] = attributes["followers"]
if "repos" in attributes:
convertedAttributes["public_repos"] = attributes["repos"]
if "name" in attributes:
convertedAttributes["name"] = attributes["name"]
if "created_at" in attributes:
convertedAttributes["created_at"] = attributes["created_at"]
if "location" in attributes:
convertedAttributes["location"] = attributes["location"]
return convertedAttributes
def convertRepo( attributes ):
def convertRepo(attributes):
convertedAttributes = {
"owner": { "login": attributes[ "owner" ], "url": "/users/" + attributes[ "owner" ] },
"url": "/repos/" + attributes[ "owner" ] + "/" + attributes[ "name" ],
"owner": {"login": attributes["owner"], "url": "/users/" + attributes["owner"]},
"url": "/repos/" + attributes["owner"] + "/" + attributes["name"],
}
if "pushed_at" in attributes: convertedAttributes[ "pushed_at" ] = attributes[ "pushed_at" ]
if "homepage" in attributes: convertedAttributes[ "homepage" ] = attributes[ "homepage" ]
if "created_at" in attributes: convertedAttributes[ "created_at" ] = attributes[ "created_at" ]
if "watchers" in attributes: convertedAttributes[ "watchers" ] = attributes[ "watchers" ]
if "has_downloads" in attributes: convertedAttributes[ "has_downloads" ] = attributes[ "has_downloads" ]
if "fork" in attributes: convertedAttributes[ "fork" ] = attributes[ "fork" ]
if "has_issues" in attributes: convertedAttributes[ "has_issues" ] = attributes[ "has_issues" ]
if "has_wiki" in attributes: convertedAttributes[ "has_wiki" ] = attributes[ "has_wiki" ]
if "forks" in attributes: convertedAttributes[ "forks" ] = attributes[ "forks" ]
if "size" in attributes: convertedAttributes[ "size" ] = attributes[ "size" ]
if "private" in attributes: convertedAttributes[ "private" ] = attributes[ "private" ]
if "open_issues" in attributes: convertedAttributes[ "open_issues" ] = attributes[ "open_issues" ]
if "description" in attributes: convertedAttributes[ "description" ] = attributes[ "description" ]
if "language" in attributes: convertedAttributes[ "language" ] = attributes[ "language" ]
if "name" in attributes: convertedAttributes[ "name" ] = attributes[ "name" ]
if "pushed_at" in attributes:
convertedAttributes["pushed_at"] = attributes["pushed_at"]
if "homepage" in attributes:
convertedAttributes["homepage"] = attributes["homepage"]
if "created_at" in attributes:
convertedAttributes["created_at"] = attributes["created_at"]
if "watchers" in attributes:
convertedAttributes["watchers"] = attributes["watchers"]
if "has_downloads" in attributes:
convertedAttributes["has_downloads"] = attributes["has_downloads"]
if "fork" in attributes:
convertedAttributes["fork"] = attributes["fork"]
if "has_issues" in attributes:
convertedAttributes["has_issues"] = attributes["has_issues"]
if "has_wiki" in attributes:
convertedAttributes["has_wiki"] = attributes["has_wiki"]
if "forks" in attributes:
convertedAttributes["forks"] = attributes["forks"]
if "size" in attributes:
convertedAttributes["size"] = attributes["size"]
if "private" in attributes:
convertedAttributes["private"] = attributes["private"]
if "open_issues" in attributes:
convertedAttributes["open_issues"] = attributes["open_issues"]
if "description" in attributes:
convertedAttributes["description"] = attributes["description"]
if "language" in attributes:
convertedAttributes["language"] = attributes["language"]
if "name" in attributes:
convertedAttributes["name"] = attributes["name"]
return convertedAttributes
def convertIssue( attributes ):
def convertIssue(attributes):
convertedAttributes = {
"number": attributes[ "number" ],
"url": "/repos" + urlparse.urlparse( attributes[ "html_url" ] ).path,
"user": { "login": attributes[ "user" ], "url": "/users/" + attributes[ "user" ] },
"number": attributes["number"],
"url": "/repos" + urlparse.urlparse(attributes["html_url"]).path,
"user": {"login": attributes["user"], "url": "/users/" + attributes["user"]},
}
if "labels" in attributes: convertedAttributes[ "labels" ] = [ { "name": label } for label in attributes[ "labels" ] ]
if "title" in attributes: convertedAttributes[ "title" ] = attributes[ "title" ]
if "created_at" in attributes: convertedAttributes[ "created_at" ] = attributes[ "created_at" ]
if "comments" in attributes: convertedAttributes[ "comments" ] = attributes[ "comments" ]
if "body" in attributes: convertedAttributes[ "body" ] = attributes[ "body" ]
if "updated_at" in attributes: convertedAttributes[ "updated_at" ] = attributes[ "updated_at" ]
if "state" in attributes: convertedAttributes[ "state" ] = attributes[ "state" ]
if "labels" in attributes:
convertedAttributes["labels"] = [{"name": label} for label in attributes["labels"]]
if "title" in attributes:
convertedAttributes["title"] = attributes["title"]
if "created_at" in attributes:
convertedAttributes["created_at"] = attributes["created_at"]
if "comments" in attributes:
convertedAttributes["comments"] = attributes["comments"]
if "body" in attributes:
convertedAttributes["body"] = attributes["body"]
if "updated_at" in attributes:
convertedAttributes["updated_at"] = attributes["updated_at"]
if "state" in attributes:
convertedAttributes["state"] = attributes["state"]
return convertedAttributes
+82 -81
View File
@@ -19,63 +19,64 @@ import PaginatedList
import NamedUser
import Label
class Milestone( GithubObject.GithubObject ):
class Milestone(GithubObject.GithubObject):
@property
def closed_issues( self ):
self._completeIfNotSet( self._closed_issues )
return self._NoneIfNotSet( self._closed_issues )
def closed_issues(self):
self._completeIfNotSet(self._closed_issues)
return self._NoneIfNotSet(self._closed_issues)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def creator( self ):
self._completeIfNotSet( self._creator )
return self._NoneIfNotSet( self._creator )
def creator(self):
self._completeIfNotSet(self._creator)
return self._NoneIfNotSet(self._creator)
@property
def description( self ):
self._completeIfNotSet( self._description )
return self._NoneIfNotSet( self._description )
def description(self):
self._completeIfNotSet(self._description)
return self._NoneIfNotSet(self._description)
@property
def due_on( self ):
self._completeIfNotSet( self._due_on )
return self._NoneIfNotSet( self._due_on )
def due_on(self):
self._completeIfNotSet(self._due_on)
return self._NoneIfNotSet(self._due_on)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def number( self ):
self._completeIfNotSet( self._number )
return self._NoneIfNotSet( self._number )
def number(self):
self._completeIfNotSet(self._number)
return self._NoneIfNotSet(self._number)
@property
def open_issues( self ):
self._completeIfNotSet( self._open_issues )
return self._NoneIfNotSet( self._open_issues )
def open_issues(self):
self._completeIfNotSet(self._open_issues)
return self._NoneIfNotSet(self._open_issues)
@property
def state( self ):
self._completeIfNotSet( self._state )
return self._NoneIfNotSet( self._state )
def state(self):
self._completeIfNotSet(self._state)
return self._NoneIfNotSet(self._state)
@property
def title( self ):
self._completeIfNotSet( self._title )
return self._NoneIfNotSet( self._title )
def title(self):
self._completeIfNotSet(self._title)
return self._NoneIfNotSet(self._title)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -83,29 +84,29 @@ class Milestone( GithubObject.GithubObject ):
None
)
def edit( self, title, state = GithubObject.NotSet, description = GithubObject.NotSet, due_on = GithubObject.NotSet ):
assert isinstance( title, ( str, unicode ) ), title
assert state is GithubObject.NotSet or isinstance( state, ( str, unicode ) ), state
assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description
assert due_on is GithubObject.NotSet or isinstance( due_on, datetime.date ), due_on
def edit(self, title, state=GithubObject.NotSet, description=GithubObject.NotSet, due_on=GithubObject.NotSet):
assert isinstance(title, (str, unicode)), title
assert state is GithubObject.NotSet or isinstance(state, (str, unicode)), state
assert description is GithubObject.NotSet or isinstance(description, (str, unicode)), description
assert due_on is GithubObject.NotSet or isinstance(due_on, datetime.date), due_on
post_parameters = {
"title": title,
}
if state is not GithubObject.NotSet:
post_parameters[ "state" ] = state
post_parameters["state"] = state
if description is not GithubObject.NotSet:
post_parameters[ "description" ] = description
post_parameters["description"] = description
if due_on is not GithubObject.NotSet:
post_parameters[ "due_on" ] = due_on.strftime( "%Y-%m-%d" )
post_parameters["due_on"] = due_on.strftime("%Y-%m-%d")
headers, data = self._requester.requestAndCheck(
"PATCH",
self.url,
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def get_labels( self ):
def get_labels(self):
return PaginatedList.PaginatedList(
Label.Label,
self._requester,
@@ -114,10 +115,10 @@ class Milestone( GithubObject.GithubObject ):
)
@property
def _identity( self ):
def _identity(self):
return self.number
def _initAttributes( self ):
def _initAttributes(self):
self._closed_issues = GithubObject.NotSet
self._created_at = GithubObject.NotSet
self._creator = GithubObject.NotSet
@@ -130,37 +131,37 @@ class Milestone( GithubObject.GithubObject ):
self._title = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "closed_issues" in attributes: # pragma no branch
assert attributes[ "closed_issues" ] is None or isinstance( attributes[ "closed_issues" ], int ), attributes[ "closed_issues" ]
self._closed_issues = attributes[ "closed_issues" ]
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 "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 NamedUser.NamedUser( self._requester, 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" ]
if "due_on" in attributes: # pragma no branch
assert attributes[ "due_on" ] is None or isinstance( attributes[ "due_on" ], ( str, unicode ) ), attributes[ "due_on" ]
self._due_on = self._parseDatetime( attributes[ "due_on" ] )
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "number" in attributes: # pragma no branch
assert attributes[ "number" ] is None or isinstance( attributes[ "number" ], int ), attributes[ "number" ]
self._number = attributes[ "number" ]
if "open_issues" in attributes: # pragma no branch
assert attributes[ "open_issues" ] is None or isinstance( attributes[ "open_issues" ], int ), attributes[ "open_issues" ]
self._open_issues = attributes[ "open_issues" ]
if "state" in attributes: # pragma no branch
assert attributes[ "state" ] is None or isinstance( attributes[ "state" ], ( str, unicode ) ), attributes[ "state" ]
self._state = attributes[ "state" ]
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 "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
def _useAttributes(self, attributes):
if "closed_issues" in attributes: # pragma no branch
assert attributes["closed_issues"] is None or isinstance(attributes["closed_issues"], int), attributes["closed_issues"]
self._closed_issues = attributes["closed_issues"]
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 "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 NamedUser.NamedUser(self._requester, 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"]
if "due_on" in attributes: # pragma no branch
assert attributes["due_on"] is None or isinstance(attributes["due_on"], (str, unicode)), attributes["due_on"]
self._due_on = self._parseDatetime(attributes["due_on"])
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], int), attributes["id"]
self._id = attributes["id"]
if "number" in attributes: # pragma no branch
assert attributes["number"] is None or isinstance(attributes["number"], int), attributes["number"]
self._number = attributes["number"]
if "open_issues" in attributes: # pragma no branch
assert attributes["open_issues"] is None or isinstance(attributes["open_issues"], int), attributes["open_issues"]
self._open_issues = attributes["open_issues"]
if "state" in attributes: # pragma no branch
assert attributes["state"] is None or isinstance(attributes["state"], (str, unicode)), attributes["state"]
self._state = attributes["state"]
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 "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+185 -184
View File
@@ -22,156 +22,157 @@ import Organization
import InputFileContent
import Event
class NamedUser( GithubObject.GithubObject ):
class NamedUser(GithubObject.GithubObject):
@property
def avatar_url( self ):
self._completeIfNotSet( self._avatar_url )
return self._NoneIfNotSet( self._avatar_url )
def avatar_url(self):
self._completeIfNotSet(self._avatar_url)
return self._NoneIfNotSet(self._avatar_url)
@property
def bio( self ):
self._completeIfNotSet( self._bio )
return self._NoneIfNotSet( self._bio )
def bio(self):
self._completeIfNotSet(self._bio)
return self._NoneIfNotSet(self._bio)
@property
def blog( self ):
self._completeIfNotSet( self._blog )
return self._NoneIfNotSet( self._blog )
def blog(self):
self._completeIfNotSet(self._blog)
return self._NoneIfNotSet(self._blog)
@property
def collaborators( self ):
self._completeIfNotSet( self._collaborators )
return self._NoneIfNotSet( self._collaborators )
def collaborators(self):
self._completeIfNotSet(self._collaborators)
return self._NoneIfNotSet(self._collaborators)
@property
def company( self ):
self._completeIfNotSet( self._company )
return self._NoneIfNotSet( self._company )
def company(self):
self._completeIfNotSet(self._company)
return self._NoneIfNotSet(self._company)
@property
def contributions( self ):
self._completeIfNotSet( self._contributions )
return self._NoneIfNotSet( self._contributions )
def contributions(self):
self._completeIfNotSet(self._contributions)
return self._NoneIfNotSet(self._contributions)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def disk_usage( self ):
self._completeIfNotSet( self._disk_usage )
return self._NoneIfNotSet( self._disk_usage )
def disk_usage(self):
self._completeIfNotSet(self._disk_usage)
return self._NoneIfNotSet(self._disk_usage)
@property
def email( self ):
self._completeIfNotSet( self._email )
return self._NoneIfNotSet( self._email )
def email(self):
self._completeIfNotSet(self._email)
return self._NoneIfNotSet(self._email)
@property
def followers( self ):
self._completeIfNotSet( self._followers )
return self._NoneIfNotSet( self._followers )
def followers(self):
self._completeIfNotSet(self._followers)
return self._NoneIfNotSet(self._followers)
@property
def following( self ):
self._completeIfNotSet( self._following )
return self._NoneIfNotSet( self._following )
def following(self):
self._completeIfNotSet(self._following)
return self._NoneIfNotSet(self._following)
@property
def gravatar_id( self ):
self._completeIfNotSet( self._gravatar_id )
return self._NoneIfNotSet( self._gravatar_id )
def gravatar_id(self):
self._completeIfNotSet(self._gravatar_id)
return self._NoneIfNotSet(self._gravatar_id)
@property
def hireable( self ):
self._completeIfNotSet( self._hireable )
return self._NoneIfNotSet( self._hireable )
def hireable(self):
self._completeIfNotSet(self._hireable)
return self._NoneIfNotSet(self._hireable)
@property
def html_url( self ):
self._completeIfNotSet( self._html_url )
return self._NoneIfNotSet( self._html_url )
def html_url(self):
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def location( self ):
self._completeIfNotSet( self._location )
return self._NoneIfNotSet( self._location )
def location(self):
self._completeIfNotSet(self._location)
return self._NoneIfNotSet(self._location)
@property
def login( self ):
self._completeIfNotSet( self._login )
return self._NoneIfNotSet( self._login )
def login(self):
self._completeIfNotSet(self._login)
return self._NoneIfNotSet(self._login)
@property
def name( self ):
self._completeIfNotSet( self._name )
return self._NoneIfNotSet( self._name )
def name(self):
self._completeIfNotSet(self._name)
return self._NoneIfNotSet(self._name)
@property
def owned_private_repos( self ):
self._completeIfNotSet( self._owned_private_repos )
return self._NoneIfNotSet( self._owned_private_repos )
def owned_private_repos(self):
self._completeIfNotSet(self._owned_private_repos)
return self._NoneIfNotSet(self._owned_private_repos)
@property
def plan( self ):
self._completeIfNotSet( self._plan )
return self._NoneIfNotSet( self._plan )
def plan(self):
self._completeIfNotSet(self._plan)
return self._NoneIfNotSet(self._plan)
@property
def private_gists( self ):
self._completeIfNotSet( self._private_gists )
return self._NoneIfNotSet( self._private_gists )
def private_gists(self):
self._completeIfNotSet(self._private_gists)
return self._NoneIfNotSet(self._private_gists)
@property
def public_gists( self ):
self._completeIfNotSet( self._public_gists )
return self._NoneIfNotSet( self._public_gists )
def public_gists(self):
self._completeIfNotSet(self._public_gists)
return self._NoneIfNotSet(self._public_gists)
@property
def public_repos( self ):
self._completeIfNotSet( self._public_repos )
return self._NoneIfNotSet( self._public_repos )
def public_repos(self):
self._completeIfNotSet(self._public_repos)
return self._NoneIfNotSet(self._public_repos)
@property
def total_private_repos( self ):
self._completeIfNotSet( self._total_private_repos )
return self._NoneIfNotSet( self._total_private_repos )
def total_private_repos(self):
self._completeIfNotSet(self._total_private_repos)
return self._NoneIfNotSet(self._total_private_repos)
@property
def type( self ):
self._completeIfNotSet( self._type )
return self._NoneIfNotSet( self._type )
def type(self):
self._completeIfNotSet(self._type)
return self._NoneIfNotSet(self._type)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def create_gist( self, public, files, description = GithubObject.NotSet ):
assert isinstance( public, bool ), public
assert all( isinstance( element, InputFileContent.InputFileContent ) for element in files.itervalues() ), files
assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description
def create_gist(self, public, files, description=GithubObject.NotSet):
assert isinstance(public, bool), public
assert all(isinstance(element, InputFileContent.InputFileContent) for element in files.itervalues()), files
assert description is GithubObject.NotSet or isinstance(description, (str, unicode)), description
post_parameters = {
"public": public,
"files": dict( ( key, value._identity ) for key, value in files.iteritems() ),
"files": dict((key, value._identity) for key, value in files.iteritems()),
}
if description is not GithubObject.NotSet:
post_parameters[ "description" ] = description
post_parameters["description"] = description
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/gists",
None,
post_parameters
)
return Gist.Gist( self._requester, data, completed = True )
return Gist.Gist(self._requester, data, completed=True)
def get_events( self ):
def get_events(self):
return PaginatedList.PaginatedList(
Event.Event,
self._requester,
@@ -179,7 +180,7 @@ class NamedUser( GithubObject.GithubObject ):
None
)
def get_followers( self ):
def get_followers(self):
return PaginatedList.PaginatedList(
NamedUser,
self._requester,
@@ -187,7 +188,7 @@ class NamedUser( GithubObject.GithubObject ):
None
)
def get_following( self ):
def get_following(self):
return PaginatedList.PaginatedList(
NamedUser,
self._requester,
@@ -195,7 +196,7 @@ class NamedUser( GithubObject.GithubObject ):
None
)
def get_gists( self ):
def get_gists(self):
return PaginatedList.PaginatedList(
Gist.Gist,
self._requester,
@@ -203,7 +204,7 @@ class NamedUser( GithubObject.GithubObject ):
None
)
def get_orgs( self ):
def get_orgs(self):
return PaginatedList.PaginatedList(
Organization.Organization,
self._requester,
@@ -211,7 +212,7 @@ class NamedUser( GithubObject.GithubObject ):
None
)
def get_public_events( self ):
def get_public_events(self):
return PaginatedList.PaginatedList(
Event.Event,
self._requester,
@@ -219,7 +220,7 @@ class NamedUser( GithubObject.GithubObject ):
None
)
def get_public_received_events( self ):
def get_public_received_events(self):
return PaginatedList.PaginatedList(
Event.Event,
self._requester,
@@ -227,7 +228,7 @@ class NamedUser( GithubObject.GithubObject ):
None
)
def get_received_events( self ):
def get_received_events(self):
return PaginatedList.PaginatedList(
Event.Event,
self._requester,
@@ -235,21 +236,21 @@ class NamedUser( GithubObject.GithubObject ):
None
)
def get_repo( self, name ):
assert isinstance( name, ( str, unicode ) ), name
def get_repo(self, name):
assert isinstance(name, (str, unicode)), name
headers, data = self._requester.requestAndCheck(
"GET",
"/repos/" + self.login + "/" + name,
None,
None
)
return Repository.Repository( self._requester, data, completed = True )
return Repository.Repository(self._requester, data, completed=True)
def get_repos( self, type = GithubObject.NotSet ):
assert type is GithubObject.NotSet or isinstance( type, ( str, unicode ) ), type
def get_repos(self, type=GithubObject.NotSet):
assert type is GithubObject.NotSet or isinstance(type, (str, unicode)), type
url_parameters = dict()
if type is not GithubObject.NotSet:
url_parameters[ "type" ] = type
url_parameters["type"] = type
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
@@ -257,7 +258,7 @@ class NamedUser( GithubObject.GithubObject ):
url_parameters
)
def get_starred( self ):
def get_starred(self):
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
@@ -265,7 +266,7 @@ class NamedUser( GithubObject.GithubObject ):
None
)
def get_subscriptions( self ):
def get_subscriptions(self):
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
@@ -273,7 +274,7 @@ class NamedUser( GithubObject.GithubObject ):
None
)
def get_watched( self ):
def get_watched(self):
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
@@ -282,10 +283,10 @@ class NamedUser( GithubObject.GithubObject ):
)
@property
def _identity( self ):
def _identity(self):
return self.login
def _initAttributes( self ):
def _initAttributes(self):
self._avatar_url = GithubObject.NotSet
self._bio = GithubObject.NotSet
self._blog = GithubObject.NotSet
@@ -313,82 +314,82 @@ class NamedUser( GithubObject.GithubObject ):
self._type = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "avatar_url" in attributes: # pragma no branch
assert attributes[ "avatar_url" ] is None or isinstance( attributes[ "avatar_url" ], ( str, unicode ) ), attributes[ "avatar_url" ]
self._avatar_url = attributes[ "avatar_url" ]
if "bio" in attributes: # pragma no branch
assert attributes[ "bio" ] is None or isinstance( attributes[ "bio" ], ( str, unicode ) ), attributes[ "bio" ]
self._bio = attributes[ "bio" ]
if "blog" in attributes: # pragma no branch
assert attributes[ "blog" ] is None or isinstance( attributes[ "blog" ], ( str, unicode ) ), attributes[ "blog" ]
self._blog = attributes[ "blog" ]
if "collaborators" in attributes: # pragma no branch
assert attributes[ "collaborators" ] is None or isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ]
self._collaborators = attributes[ "collaborators" ]
if "company" in attributes: # pragma no branch
assert attributes[ "company" ] is None or isinstance( attributes[ "company" ], ( str, unicode ) ), attributes[ "company" ]
self._company = attributes[ "company" ]
if "contributions" in attributes: # pragma no branch
assert attributes[ "contributions" ] is None or isinstance( attributes[ "contributions" ], int ), attributes[ "contributions" ]
self._contributions = attributes[ "contributions" ]
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 "disk_usage" in attributes: # pragma no branch
assert attributes[ "disk_usage" ] is None or isinstance( attributes[ "disk_usage" ], int ), attributes[ "disk_usage" ]
self._disk_usage = attributes[ "disk_usage" ]
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 "followers" in attributes: # pragma no branch
assert attributes[ "followers" ] is None or isinstance( attributes[ "followers" ], int ), attributes[ "followers" ]
self._followers = attributes[ "followers" ]
if "following" in attributes: # pragma no branch
assert attributes[ "following" ] is None or isinstance( attributes[ "following" ], int ), attributes[ "following" ]
self._following = attributes[ "following" ]
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" ]
if "hireable" in attributes: # pragma no branch
assert attributes[ "hireable" ] is None or isinstance( attributes[ "hireable" ], bool ), attributes[ "hireable" ]
self._hireable = attributes[ "hireable" ]
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" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "location" in attributes: # pragma no branch
assert attributes[ "location" ] is None or isinstance( attributes[ "location" ], ( str, unicode ) ), attributes[ "location" ]
self._location = attributes[ "location" ]
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 "name" in attributes: # pragma no branch
assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ]
self._name = attributes[ "name" ]
if "owned_private_repos" in attributes: # pragma no branch
assert attributes[ "owned_private_repos" ] is None or isinstance( attributes[ "owned_private_repos" ], int ), 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 Plan.Plan( self._requester, attributes[ "plan" ], completed = False )
if "private_gists" in attributes: # pragma no branch
assert attributes[ "private_gists" ] is None or isinstance( attributes[ "private_gists" ], int ), 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 ), attributes[ "public_gists" ]
self._public_gists = attributes[ "public_gists" ]
if "public_repos" in attributes: # pragma no branch
assert attributes[ "public_repos" ] is None or isinstance( attributes[ "public_repos" ], int ), attributes[ "public_repos" ]
self._public_repos = attributes[ "public_repos" ]
if "total_private_repos" in attributes: # pragma no branch
assert attributes[ "total_private_repos" ] is None or isinstance( attributes[ "total_private_repos" ], int ), 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 "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
def _useAttributes(self, attributes):
if "avatar_url" in attributes: # pragma no branch
assert attributes["avatar_url"] is None or isinstance(attributes["avatar_url"], (str, unicode)), attributes["avatar_url"]
self._avatar_url = attributes["avatar_url"]
if "bio" in attributes: # pragma no branch
assert attributes["bio"] is None or isinstance(attributes["bio"], (str, unicode)), attributes["bio"]
self._bio = attributes["bio"]
if "blog" in attributes: # pragma no branch
assert attributes["blog"] is None or isinstance(attributes["blog"], (str, unicode)), attributes["blog"]
self._blog = attributes["blog"]
if "collaborators" in attributes: # pragma no branch
assert attributes["collaborators"] is None or isinstance(attributes["collaborators"], int), attributes["collaborators"]
self._collaborators = attributes["collaborators"]
if "company" in attributes: # pragma no branch
assert attributes["company"] is None or isinstance(attributes["company"], (str, unicode)), attributes["company"]
self._company = attributes["company"]
if "contributions" in attributes: # pragma no branch
assert attributes["contributions"] is None or isinstance(attributes["contributions"], int), attributes["contributions"]
self._contributions = attributes["contributions"]
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 "disk_usage" in attributes: # pragma no branch
assert attributes["disk_usage"] is None or isinstance(attributes["disk_usage"], int), attributes["disk_usage"]
self._disk_usage = attributes["disk_usage"]
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 "followers" in attributes: # pragma no branch
assert attributes["followers"] is None or isinstance(attributes["followers"], int), attributes["followers"]
self._followers = attributes["followers"]
if "following" in attributes: # pragma no branch
assert attributes["following"] is None or isinstance(attributes["following"], int), attributes["following"]
self._following = attributes["following"]
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"]
if "hireable" in attributes: # pragma no branch
assert attributes["hireable"] is None or isinstance(attributes["hireable"], bool), attributes["hireable"]
self._hireable = attributes["hireable"]
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"], int), attributes["id"]
self._id = attributes["id"]
if "location" in attributes: # pragma no branch
assert attributes["location"] is None or isinstance(attributes["location"], (str, unicode)), attributes["location"]
self._location = attributes["location"]
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 "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
if "owned_private_repos" in attributes: # pragma no branch
assert attributes["owned_private_repos"] is None or isinstance(attributes["owned_private_repos"], int), 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 Plan.Plan(self._requester, attributes["plan"], completed=False)
if "private_gists" in attributes: # pragma no branch
assert attributes["private_gists"] is None or isinstance(attributes["private_gists"], int), 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), attributes["public_gists"]
self._public_gists = attributes["public_gists"]
if "public_repos" in attributes: # pragma no branch
assert attributes["public_repos"] is None or isinstance(attributes["public_repos"], int), attributes["public_repos"]
self._public_repos = attributes["public_repos"]
if "total_private_repos" in attributes: # pragma no branch
assert attributes["total_private_repos"] is None or isinstance(attributes["total_private_repos"], int), 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 "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+213 -212
View File
@@ -20,129 +20,130 @@ import Event
import Repository
import NamedUser
class Organization( GithubObject.GithubObject ):
class Organization(GithubObject.GithubObject):
@property
def avatar_url( self ):
self._completeIfNotSet( self._avatar_url )
return self._NoneIfNotSet( self._avatar_url )
def avatar_url(self):
self._completeIfNotSet(self._avatar_url)
return self._NoneIfNotSet(self._avatar_url)
@property
def billing_email( self ):
self._completeIfNotSet( self._billing_email )
return self._NoneIfNotSet( self._billing_email )
def billing_email(self):
self._completeIfNotSet(self._billing_email)
return self._NoneIfNotSet(self._billing_email)
@property
def blog( self ):
self._completeIfNotSet( self._blog )
return self._NoneIfNotSet( self._blog )
def blog(self):
self._completeIfNotSet(self._blog)
return self._NoneIfNotSet(self._blog)
@property
def collaborators( self ):
self._completeIfNotSet( self._collaborators )
return self._NoneIfNotSet( self._collaborators )
def collaborators(self):
self._completeIfNotSet(self._collaborators)
return self._NoneIfNotSet(self._collaborators)
@property
def company( self ):
self._completeIfNotSet( self._company )
return self._NoneIfNotSet( self._company )
def company(self):
self._completeIfNotSet(self._company)
return self._NoneIfNotSet(self._company)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def disk_usage( self ):
self._completeIfNotSet( self._disk_usage )
return self._NoneIfNotSet( self._disk_usage )
def disk_usage(self):
self._completeIfNotSet(self._disk_usage)
return self._NoneIfNotSet(self._disk_usage)
@property
def email( self ):
self._completeIfNotSet( self._email )
return self._NoneIfNotSet( self._email )
def email(self):
self._completeIfNotSet(self._email)
return self._NoneIfNotSet(self._email)
@property
def followers( self ):
self._completeIfNotSet( self._followers )
return self._NoneIfNotSet( self._followers )
def followers(self):
self._completeIfNotSet(self._followers)
return self._NoneIfNotSet(self._followers)
@property
def following( self ):
self._completeIfNotSet( self._following )
return self._NoneIfNotSet( self._following )
def following(self):
self._completeIfNotSet(self._following)
return self._NoneIfNotSet(self._following)
@property
def gravatar_id( self ):
self._completeIfNotSet( self._gravatar_id )
return self._NoneIfNotSet( self._gravatar_id )
def gravatar_id(self):
self._completeIfNotSet(self._gravatar_id)
return self._NoneIfNotSet(self._gravatar_id)
@property
def html_url( self ):
self._completeIfNotSet( self._html_url )
return self._NoneIfNotSet( self._html_url )
def html_url(self):
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def location( self ):
self._completeIfNotSet( self._location )
return self._NoneIfNotSet( self._location )
def location(self):
self._completeIfNotSet(self._location)
return self._NoneIfNotSet(self._location)
@property
def login( self ):
self._completeIfNotSet( self._login )
return self._NoneIfNotSet( self._login )
def login(self):
self._completeIfNotSet(self._login)
return self._NoneIfNotSet(self._login)
@property
def name( self ):
self._completeIfNotSet( self._name )
return self._NoneIfNotSet( self._name )
def name(self):
self._completeIfNotSet(self._name)
return self._NoneIfNotSet(self._name)
@property
def owned_private_repos( self ):
self._completeIfNotSet( self._owned_private_repos )
return self._NoneIfNotSet( self._owned_private_repos )
def owned_private_repos(self):
self._completeIfNotSet(self._owned_private_repos)
return self._NoneIfNotSet(self._owned_private_repos)
@property
def plan( self ):
self._completeIfNotSet( self._plan )
return self._NoneIfNotSet( self._plan )
def plan(self):
self._completeIfNotSet(self._plan)
return self._NoneIfNotSet(self._plan)
@property
def private_gists( self ):
self._completeIfNotSet( self._private_gists )
return self._NoneIfNotSet( self._private_gists )
def private_gists(self):
self._completeIfNotSet(self._private_gists)
return self._NoneIfNotSet(self._private_gists)
@property
def public_gists( self ):
self._completeIfNotSet( self._public_gists )
return self._NoneIfNotSet( self._public_gists )
def public_gists(self):
self._completeIfNotSet(self._public_gists)
return self._NoneIfNotSet(self._public_gists)
@property
def public_repos( self ):
self._completeIfNotSet( self._public_repos )
return self._NoneIfNotSet( self._public_repos )
def public_repos(self):
self._completeIfNotSet(self._public_repos)
return self._NoneIfNotSet(self._public_repos)
@property
def total_private_repos( self ):
self._completeIfNotSet( self._total_private_repos )
return self._NoneIfNotSet( self._total_private_repos )
def total_private_repos(self):
self._completeIfNotSet(self._total_private_repos)
return self._NoneIfNotSet(self._total_private_repos)
@property
def type( self ):
self._completeIfNotSet( self._type )
return self._NoneIfNotSet( self._type )
def type(self):
self._completeIfNotSet(self._type)
return self._NoneIfNotSet(self._type)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def add_to_public_members( self, public_member ):
assert isinstance( public_member, NamedUser.NamedUser ), public_member
def add_to_public_members(self, public_member):
assert isinstance(public_member, NamedUser.NamedUser), public_member
headers, data = self._requester.requestAndCheck(
"PUT",
self.url + "/public_members/" + public_member._identity,
@@ -150,8 +151,8 @@ class Organization( GithubObject.GithubObject ):
None
)
def create_fork( self, repo ):
assert isinstance( repo, Repository.Repository ), repo
def create_fork(self, repo):
assert isinstance(repo, Repository.Repository), repo
url_parameters = {
"org": self.login,
}
@@ -161,90 +162,90 @@ class Organization( GithubObject.GithubObject ):
url_parameters,
None
)
return Repository.Repository( self._requester, data, completed = True )
return Repository.Repository(self._requester, data, completed=True)
def create_repo( self, name, description = GithubObject.NotSet, homepage = GithubObject.NotSet, private = GithubObject.NotSet, has_issues = GithubObject.NotSet, has_wiki = GithubObject.NotSet, has_downloads = GithubObject.NotSet, team_id = GithubObject.NotSet ):
assert isinstance( name, ( str, unicode ) ), name
assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description
assert homepage is GithubObject.NotSet or isinstance( homepage, ( str, unicode ) ), homepage
assert private is GithubObject.NotSet or isinstance( private, bool ), private
assert has_issues is GithubObject.NotSet or isinstance( has_issues, bool ), has_issues
assert has_wiki is GithubObject.NotSet or isinstance( has_wiki, bool ), has_wiki
assert has_downloads is GithubObject.NotSet or isinstance( has_downloads, bool ), has_downloads
assert team_id is GithubObject.NotSet or isinstance( team_id, Team.Team ), team_id
def create_repo(self, name, description=GithubObject.NotSet, homepage=GithubObject.NotSet, private=GithubObject.NotSet, has_issues=GithubObject.NotSet, has_wiki=GithubObject.NotSet, has_downloads=GithubObject.NotSet, team_id=GithubObject.NotSet):
assert isinstance(name, (str, unicode)), name
assert description is GithubObject.NotSet or isinstance(description, (str, unicode)), description
assert homepage is GithubObject.NotSet or isinstance(homepage, (str, unicode)), homepage
assert private is GithubObject.NotSet or isinstance(private, bool), private
assert has_issues is GithubObject.NotSet or isinstance(has_issues, bool), has_issues
assert has_wiki is GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki
assert has_downloads is GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads
assert team_id is GithubObject.NotSet or isinstance(team_id, Team.Team), team_id
post_parameters = {
"name": name,
}
if description is not GithubObject.NotSet:
post_parameters[ "description" ] = description
post_parameters["description"] = description
if homepage is not GithubObject.NotSet:
post_parameters[ "homepage" ] = homepage
post_parameters["homepage"] = homepage
if private is not GithubObject.NotSet:
post_parameters[ "private" ] = private
post_parameters["private"] = private
if has_issues is not GithubObject.NotSet:
post_parameters[ "has_issues" ] = has_issues
post_parameters["has_issues"] = has_issues
if has_wiki is not GithubObject.NotSet:
post_parameters[ "has_wiki" ] = has_wiki
post_parameters["has_wiki"] = has_wiki
if has_downloads is not GithubObject.NotSet:
post_parameters[ "has_downloads" ] = has_downloads
post_parameters["has_downloads"] = has_downloads
if team_id is not GithubObject.NotSet:
post_parameters[ "team_id" ] = team_id._identity
post_parameters["team_id"] = team_id._identity
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/repos",
None,
post_parameters
)
return Repository.Repository( self._requester, data, completed = True )
return Repository.Repository(self._requester, data, completed=True)
def create_team( self, name, repo_names = GithubObject.NotSet, permission = GithubObject.NotSet ):
assert isinstance( name, ( str, unicode ) ), name
assert repo_names is GithubObject.NotSet or all( isinstance( element, Repository.Repository ) for element in repo_names ), repo_names
assert permission is GithubObject.NotSet or isinstance( permission, ( str, unicode ) ), permission
def create_team(self, name, repo_names=GithubObject.NotSet, permission=GithubObject.NotSet):
assert isinstance(name, (str, unicode)), name
assert repo_names is GithubObject.NotSet or all(isinstance(element, Repository.Repository) for element in repo_names), repo_names
assert permission is GithubObject.NotSet or isinstance(permission, (str, unicode)), permission
post_parameters = {
"name": name,
}
if repo_names is not GithubObject.NotSet:
post_parameters[ "repo_names" ] = [ element._identity for element in repo_names ]
post_parameters["repo_names"] = [element._identity for element in repo_names]
if permission is not GithubObject.NotSet:
post_parameters[ "permission" ] = permission
post_parameters["permission"] = permission
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/teams",
None,
post_parameters
)
return Team.Team( self._requester, data, completed = True )
return Team.Team(self._requester, data, completed=True)
def edit( self, billing_email = GithubObject.NotSet, blog = GithubObject.NotSet, company = GithubObject.NotSet, email = GithubObject.NotSet, location = GithubObject.NotSet, name = GithubObject.NotSet ):
assert billing_email is GithubObject.NotSet or isinstance( billing_email, ( str, unicode ) ), billing_email
assert blog is GithubObject.NotSet or isinstance( blog, ( str, unicode ) ), blog
assert company is GithubObject.NotSet or isinstance( company, ( str, unicode ) ), company
assert email is GithubObject.NotSet or isinstance( email, ( str, unicode ) ), email
assert location is GithubObject.NotSet or isinstance( location, ( str, unicode ) ), location
assert name is GithubObject.NotSet or isinstance( name, ( str, unicode ) ), name
def edit(self, billing_email=GithubObject.NotSet, blog=GithubObject.NotSet, company=GithubObject.NotSet, email=GithubObject.NotSet, location=GithubObject.NotSet, name=GithubObject.NotSet):
assert billing_email is GithubObject.NotSet or isinstance(billing_email, (str, unicode)), billing_email
assert blog is GithubObject.NotSet or isinstance(blog, (str, unicode)), blog
assert company is GithubObject.NotSet or isinstance(company, (str, unicode)), company
assert email is GithubObject.NotSet or isinstance(email, (str, unicode)), email
assert location is GithubObject.NotSet or isinstance(location, (str, unicode)), location
assert name is GithubObject.NotSet or isinstance(name, (str, unicode)), name
post_parameters = dict()
if billing_email is not GithubObject.NotSet:
post_parameters[ "billing_email" ] = billing_email
post_parameters["billing_email"] = billing_email
if blog is not GithubObject.NotSet:
post_parameters[ "blog" ] = blog
post_parameters["blog"] = blog
if company is not GithubObject.NotSet:
post_parameters[ "company" ] = company
post_parameters["company"] = company
if email is not GithubObject.NotSet:
post_parameters[ "email" ] = email
post_parameters["email"] = email
if location is not GithubObject.NotSet:
post_parameters[ "location" ] = location
post_parameters["location"] = location
if name is not GithubObject.NotSet:
post_parameters[ "name" ] = name
post_parameters["name"] = name
headers, data = self._requester.requestAndCheck(
"PATCH",
self.url,
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def get_events( self ):
def get_events(self):
return PaginatedList.PaginatedList(
Event.Event,
self._requester,
@@ -252,7 +253,7 @@ class Organization( GithubObject.GithubObject ):
None
)
def get_members( self ):
def get_members(self):
return PaginatedList.PaginatedList(
NamedUser.NamedUser,
self._requester,
@@ -260,7 +261,7 @@ class Organization( GithubObject.GithubObject ):
None
)
def get_public_members( self ):
def get_public_members(self):
return PaginatedList.PaginatedList(
NamedUser.NamedUser,
self._requester,
@@ -268,21 +269,21 @@ class Organization( GithubObject.GithubObject ):
None
)
def get_repo( self, name ):
assert isinstance( name, ( str, unicode ) ), name
def get_repo(self, name):
assert isinstance(name, (str, unicode)), name
headers, data = self._requester.requestAndCheck(
"GET",
"/repos/" + self.login + "/" + name,
None,
None
)
return Repository.Repository( self._requester, data, completed = True )
return Repository.Repository(self._requester, data, completed=True)
def get_repos( self, type = GithubObject.NotSet ):
assert type is GithubObject.NotSet or isinstance( type, ( str, unicode ) ), type
def get_repos(self, type=GithubObject.NotSet):
assert type is GithubObject.NotSet or isinstance(type, (str, unicode)), type
url_parameters = dict()
if type is not GithubObject.NotSet:
url_parameters[ "type" ] = type
url_parameters["type"] = type
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
@@ -290,17 +291,17 @@ class Organization( GithubObject.GithubObject ):
url_parameters
)
def get_team( self, id ):
assert isinstance( id, int ), id
def get_team(self, id):
assert isinstance(id, int), id
headers, data = self._requester.requestAndCheck(
"GET",
"/teams/" + str( id ),
"/teams/" + str(id),
None,
None
)
return Team.Team( self._requester, data, completed = True )
return Team.Team(self._requester, data, completed=True)
def get_teams( self ):
def get_teams(self):
return PaginatedList.PaginatedList(
Team.Team,
self._requester,
@@ -308,8 +309,8 @@ class Organization( GithubObject.GithubObject ):
None
)
def has_in_members( self, member ):
assert isinstance( member, NamedUser.NamedUser ), member
def has_in_members(self, member):
assert isinstance(member, NamedUser.NamedUser), member
status, headers, data = self._requester.requestRaw(
"GET",
self.url + "/members/" + member._identity,
@@ -318,8 +319,8 @@ class Organization( GithubObject.GithubObject ):
)
return status == 204
def has_in_public_members( self, public_member ):
assert isinstance( public_member, NamedUser.NamedUser ), public_member
def has_in_public_members(self, public_member):
assert isinstance(public_member, NamedUser.NamedUser), public_member
status, headers, data = self._requester.requestRaw(
"GET",
self.url + "/public_members/" + public_member._identity,
@@ -328,8 +329,8 @@ class Organization( GithubObject.GithubObject ):
)
return status == 204
def remove_from_members( self, member ):
assert isinstance( member, NamedUser.NamedUser ), member
def remove_from_members(self, member):
assert isinstance(member, NamedUser.NamedUser), member
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url + "/members/" + member._identity,
@@ -337,8 +338,8 @@ class Organization( GithubObject.GithubObject ):
None
)
def remove_from_public_members( self, public_member ):
assert isinstance( public_member, NamedUser.NamedUser ), public_member
def remove_from_public_members(self, public_member):
assert isinstance(public_member, NamedUser.NamedUser), public_member
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url + "/public_members/" + public_member._identity,
@@ -346,7 +347,7 @@ class Organization( GithubObject.GithubObject ):
None
)
def _initAttributes( self ):
def _initAttributes(self):
self._avatar_url = GithubObject.NotSet
self._billing_email = GithubObject.NotSet
self._blog = GithubObject.NotSet
@@ -372,76 +373,76 @@ class Organization( GithubObject.GithubObject ):
self._type = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "avatar_url" in attributes: # pragma no branch
assert attributes[ "avatar_url" ] is None or isinstance( attributes[ "avatar_url" ], ( str, unicode ) ), attributes[ "avatar_url" ]
self._avatar_url = attributes[ "avatar_url" ]
if "billing_email" in attributes: # pragma no branch
assert attributes[ "billing_email" ] is None or isinstance( attributes[ "billing_email" ], ( str, unicode ) ), attributes[ "billing_email" ]
self._billing_email = attributes[ "billing_email" ]
if "blog" in attributes: # pragma no branch
assert attributes[ "blog" ] is None or isinstance( attributes[ "blog" ], ( str, unicode ) ), attributes[ "blog" ]
self._blog = attributes[ "blog" ]
if "collaborators" in attributes: # pragma no branch
assert attributes[ "collaborators" ] is None or isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ]
self._collaborators = attributes[ "collaborators" ]
if "company" in attributes: # pragma no branch
assert attributes[ "company" ] is None or isinstance( attributes[ "company" ], ( str, unicode ) ), attributes[ "company" ]
self._company = attributes[ "company" ]
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 "disk_usage" in attributes: # pragma no branch
assert attributes[ "disk_usage" ] is None or isinstance( attributes[ "disk_usage" ], int ), attributes[ "disk_usage" ]
self._disk_usage = attributes[ "disk_usage" ]
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 "followers" in attributes: # pragma no branch
assert attributes[ "followers" ] is None or isinstance( attributes[ "followers" ], int ), attributes[ "followers" ]
self._followers = attributes[ "followers" ]
if "following" in attributes: # pragma no branch
assert attributes[ "following" ] is None or isinstance( attributes[ "following" ], int ), attributes[ "following" ]
self._following = attributes[ "following" ]
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" ]
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" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "location" in attributes: # pragma no branch
assert attributes[ "location" ] is None or isinstance( attributes[ "location" ], ( str, unicode ) ), attributes[ "location" ]
self._location = attributes[ "location" ]
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 "name" in attributes: # pragma no branch
assert attributes[ "name" ] is None or isinstance( attributes[ "name" ], ( str, unicode ) ), attributes[ "name" ]
self._name = attributes[ "name" ]
if "owned_private_repos" in attributes: # pragma no branch
assert attributes[ "owned_private_repos" ] is None or isinstance( attributes[ "owned_private_repos" ], int ), 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 Plan.Plan( self._requester, attributes[ "plan" ], completed = False )
if "private_gists" in attributes: # pragma no branch
assert attributes[ "private_gists" ] is None or isinstance( attributes[ "private_gists" ], int ), 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 ), attributes[ "public_gists" ]
self._public_gists = attributes[ "public_gists" ]
if "public_repos" in attributes: # pragma no branch
assert attributes[ "public_repos" ] is None or isinstance( attributes[ "public_repos" ], int ), attributes[ "public_repos" ]
self._public_repos = attributes[ "public_repos" ]
if "total_private_repos" in attributes: # pragma no branch
assert attributes[ "total_private_repos" ] is None or isinstance( attributes[ "total_private_repos" ], int ), 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 "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
def _useAttributes(self, attributes):
if "avatar_url" in attributes: # pragma no branch
assert attributes["avatar_url"] is None or isinstance(attributes["avatar_url"], (str, unicode)), attributes["avatar_url"]
self._avatar_url = attributes["avatar_url"]
if "billing_email" in attributes: # pragma no branch
assert attributes["billing_email"] is None or isinstance(attributes["billing_email"], (str, unicode)), attributes["billing_email"]
self._billing_email = attributes["billing_email"]
if "blog" in attributes: # pragma no branch
assert attributes["blog"] is None or isinstance(attributes["blog"], (str, unicode)), attributes["blog"]
self._blog = attributes["blog"]
if "collaborators" in attributes: # pragma no branch
assert attributes["collaborators"] is None or isinstance(attributes["collaborators"], int), attributes["collaborators"]
self._collaborators = attributes["collaborators"]
if "company" in attributes: # pragma no branch
assert attributes["company"] is None or isinstance(attributes["company"], (str, unicode)), attributes["company"]
self._company = attributes["company"]
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 "disk_usage" in attributes: # pragma no branch
assert attributes["disk_usage"] is None or isinstance(attributes["disk_usage"], int), attributes["disk_usage"]
self._disk_usage = attributes["disk_usage"]
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 "followers" in attributes: # pragma no branch
assert attributes["followers"] is None or isinstance(attributes["followers"], int), attributes["followers"]
self._followers = attributes["followers"]
if "following" in attributes: # pragma no branch
assert attributes["following"] is None or isinstance(attributes["following"], int), attributes["following"]
self._following = attributes["following"]
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"]
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"], int), attributes["id"]
self._id = attributes["id"]
if "location" in attributes: # pragma no branch
assert attributes["location"] is None or isinstance(attributes["location"], (str, unicode)), attributes["location"]
self._location = attributes["location"]
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 "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
if "owned_private_repos" in attributes: # pragma no branch
assert attributes["owned_private_repos"] is None or isinstance(attributes["owned_private_repos"], int), 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 Plan.Plan(self._requester, attributes["plan"], completed=False)
if "private_gists" in attributes: # pragma no branch
assert attributes["private_gists"] is None or isinstance(attributes["private_gists"], int), 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), attributes["public_gists"]
self._public_gists = attributes["public_gists"]
if "public_repos" in attributes: # pragma no branch
assert attributes["public_repos"] is None or isinstance(attributes["public_repos"], int), attributes["public_repos"]
self._public_repos = attributes["public_repos"]
if "total_private_repos" in attributes: # pragma no branch
assert attributes["total_private_repos"] is None or isinstance(attributes["total_private_repos"], int), 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 "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+42 -40
View File
@@ -13,19 +13,20 @@
import GithubObject
class PaginatedListBase:
def __init__( self ):
def __init__(self):
self.__elements = list()
def __getitem__( self, index ):
assert isinstance( index, ( int, slice ) )
if isinstance( index, int ):
self.__fetchToIndex( index )
return self.__elements[ index ]
def __getitem__(self, index):
assert isinstance(index, (int, slice))
if isinstance(index, int):
self.__fetchToIndex(index)
return self.__elements[index]
else:
return self._Slice( self, index )
return self._Slice(self, index)
def __iter__( self ):
def __iter__(self):
for element in self.__elements:
yield element
while self._couldGrow():
@@ -33,40 +34,41 @@ class PaginatedListBase:
for element in newElements:
yield element
def _isBiggerThan( self, index ):
return len( self.__elements ) > index or self._couldGrow()
def _isBiggerThan(self, index):
return len(self.__elements) > index or self._couldGrow()
def __fetchToIndex( self, index ):
while len( self.__elements ) <= index and self._couldGrow():
def __fetchToIndex(self, index):
while len(self.__elements) <= index and self._couldGrow():
self.__grow()
def __grow( self ):
def __grow(self):
newElements = self._fetchNextPage()
self.__elements += newElements
return newElements
class _Slice:
def __init__( self, theList, theSlice ):
def __init__(self, theList, theSlice):
self.__list = theList
self.__start = theSlice.start or 0
self.__stop = theSlice.stop
self.__step = theSlice.step or 1
def __iter__( self ):
def __iter__(self):
index = self.__start
while not self.__finished( index ) :
if self.__list._isBiggerThan( index ):
yield self.__list[ index ]
while not self.__finished(index):
if self.__list._isBiggerThan(index):
yield self.__list[index]
index += self.__step
else:
return
def __finished( self, index ):
def __finished(self, index):
return self.__stop is not None and index >= self.__stop
class PaginatedList( PaginatedListBase ):
def __init__( self, contentClass, requester, firstUrl, firstParams ):
PaginatedListBase.__init__( self )
class PaginatedList(PaginatedListBase):
def __init__(self, contentClass, requester, firstUrl, firstParams):
PaginatedListBase.__init__(self)
self.__requester = requester
self.__contentClass = contentClass
self.__firstUrl = firstUrl
@@ -74,42 +76,42 @@ class PaginatedList( PaginatedListBase ):
self.__nextUrl = firstUrl
self.__nextParams = firstParams
def _couldGrow( self ):
def _couldGrow(self):
return self.__nextUrl is not None
def _fetchNextPage( self ):
headers, data = self.__requester.requestAndCheck( "GET", self.__nextUrl, self.__nextParams, None )
def _fetchNextPage(self):
headers, data = self.__requester.requestAndCheck("GET", self.__nextUrl, self.__nextParams, None)
links = self.__parseLinkHeader( headers )
if len( data ) > 0 and "next" in links:
self.__nextUrl = links[ "next" ]
links = self.__parseLinkHeader(headers)
if len(data) > 0 and "next" in links:
self.__nextUrl = links["next"]
else:
self.__nextUrl = None
self.__nextParams = None
return [
self.__contentClass( self.__requester, element, completed = False )
self.__contentClass(self.__requester, element, completed=False)
for element in data
]
def __parseLinkHeader( self, headers ):
def __parseLinkHeader(self, headers):
links = {}
if "link" in headers:
linkHeaders = headers[ "link" ].split( "," )
linkHeaders = headers["link"].split(",")
for linkHeader in linkHeaders:
( url, rel ) = linkHeader.split( "; " )
url = url[ 1 : -1 ]
rel = rel[ 5 : -1 ]
links[ rel ] = url
(url, rel) = linkHeader.split("; ")
url = url[1:-1]
rel = rel[5:-1]
links[rel] = url
return links
def get_page( self, page ):
params = dict( self.__firstParams )
def get_page(self, page):
params = dict(self.__firstParams)
if page != 0:
params[ "page" ] = page + 1
headers, data = self.__requester.requestAndCheck( "GET", self.__firstUrl, params, None )
params["page"] = page + 1
headers, data = self.__requester.requestAndCheck("GET", self.__firstUrl, params, None)
return [
self.__contentClass( self.__requester, element, completed = False )
self.__contentClass(self.__requester, element, completed=False)
for element in data
]
+19 -18
View File
@@ -13,31 +13,32 @@
import GithubObject
class Permissions( GithubObject.BasicGithubObject ):
class Permissions(GithubObject.BasicGithubObject):
@property
def admin( self ):
return self._NoneIfNotSet( self._admin )
def admin(self):
return self._NoneIfNotSet(self._admin)
@property
def pull( self ):
return self._NoneIfNotSet( self._pull )
def pull(self):
return self._NoneIfNotSet(self._pull)
@property
def push( self ):
return self._NoneIfNotSet( self._push )
def push(self):
return self._NoneIfNotSet(self._push)
def _initAttributes( self ):
def _initAttributes(self):
self._admin = GithubObject.NotSet
self._pull = GithubObject.NotSet
self._push = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "admin" in attributes: # pragma no branch
assert attributes[ "admin" ] is None or isinstance( attributes[ "admin" ], bool ), attributes[ "admin" ]
self._admin = attributes[ "admin" ]
if "pull" in attributes: # pragma no branch
assert attributes[ "pull" ] is None or isinstance( attributes[ "pull" ], bool ), attributes[ "pull" ]
self._pull = attributes[ "pull" ]
if "push" in attributes: # pragma no branch
assert attributes[ "push" ] is None or isinstance( attributes[ "push" ], bool ), attributes[ "push" ]
self._push = attributes[ "push" ]
def _useAttributes(self, attributes):
if "admin" in attributes: # pragma no branch
assert attributes["admin"] is None or isinstance(attributes["admin"], bool), attributes["admin"]
self._admin = attributes["admin"]
if "pull" in attributes: # pragma no branch
assert attributes["pull"] is None or isinstance(attributes["pull"], bool), attributes["pull"]
self._pull = attributes["pull"]
if "push" in attributes: # pragma no branch
assert attributes["push"] is None or isinstance(attributes["push"], bool), attributes["push"]
self._push = attributes["push"]
+24 -23
View File
@@ -13,39 +13,40 @@
import GithubObject
class Plan( GithubObject.BasicGithubObject ):
class Plan(GithubObject.BasicGithubObject):
@property
def collaborators( self ):
return self._NoneIfNotSet( self._collaborators )
def collaborators(self):
return self._NoneIfNotSet(self._collaborators)
@property
def name( self ):
return self._NoneIfNotSet( self._name )
def name(self):
return self._NoneIfNotSet(self._name)
@property
def private_repos( self ):
return self._NoneIfNotSet( self._private_repos )
def private_repos(self):
return self._NoneIfNotSet(self._private_repos)
@property
def space( self ):
return self._NoneIfNotSet( self._space )
def space(self):
return self._NoneIfNotSet(self._space)
def _initAttributes( self ):
def _initAttributes(self):
self._collaborators = GithubObject.NotSet
self._name = GithubObject.NotSet
self._private_repos = GithubObject.NotSet
self._space = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "collaborators" in attributes: # pragma no branch
assert attributes[ "collaborators" ] is None or isinstance( attributes[ "collaborators" ], int ), attributes[ "collaborators" ]
self._collaborators = attributes[ "collaborators" ]
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 "private_repos" in attributes: # pragma no branch
assert attributes[ "private_repos" ] is None or isinstance( attributes[ "private_repos" ], int ), attributes[ "private_repos" ]
self._private_repos = attributes[ "private_repos" ]
if "space" in attributes: # pragma no branch
assert attributes[ "space" ] is None or isinstance( attributes[ "space" ], int ), attributes[ "space" ]
self._space = attributes[ "space" ]
def _useAttributes(self, attributes):
if "collaborators" in attributes: # pragma no branch
assert attributes["collaborators"] is None or isinstance(attributes["collaborators"], int), attributes["collaborators"]
self._collaborators = attributes["collaborators"]
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 "private_repos" in attributes: # pragma no branch
assert attributes["private_repos"] is None or isinstance(attributes["private_repos"], int), attributes["private_repos"]
self._private_repos = attributes["private_repos"]
if "space" in attributes: # pragma no branch
assert attributes["space"] is None or isinstance(attributes["space"], int), attributes["space"]
self._space = attributes["space"]
+201 -200
View File
@@ -22,145 +22,146 @@ import File
import IssueComment
import Commit
class PullRequest( GithubObject.GithubObject ):
class PullRequest(GithubObject.GithubObject):
@property
def additions( self ):
self._completeIfNotSet( self._additions )
return self._NoneIfNotSet( self._additions )
def additions(self):
self._completeIfNotSet(self._additions)
return self._NoneIfNotSet(self._additions)
@property
def base( self ):
self._completeIfNotSet( self._base )
return self._NoneIfNotSet( self._base )
def base(self):
self._completeIfNotSet(self._base)
return self._NoneIfNotSet(self._base)
@property
def body( self ):
self._completeIfNotSet( self._body )
return self._NoneIfNotSet( self._body )
def body(self):
self._completeIfNotSet(self._body)
return self._NoneIfNotSet(self._body)
@property
def changed_files( self ):
self._completeIfNotSet( self._changed_files )
return self._NoneIfNotSet( self._changed_files )
def changed_files(self):
self._completeIfNotSet(self._changed_files)
return self._NoneIfNotSet(self._changed_files)
@property
def closed_at( self ):
self._completeIfNotSet( self._closed_at )
return self._NoneIfNotSet( self._closed_at )
def closed_at(self):
self._completeIfNotSet(self._closed_at)
return self._NoneIfNotSet(self._closed_at)
@property
def comments( self ):
self._completeIfNotSet( self._comments )
return self._NoneIfNotSet( self._comments )
def comments(self):
self._completeIfNotSet(self._comments)
return self._NoneIfNotSet(self._comments)
@property
def commits( self ):
self._completeIfNotSet( self._commits )
return self._NoneIfNotSet( self._commits )
def commits(self):
self._completeIfNotSet(self._commits)
return self._NoneIfNotSet(self._commits)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def deletions( self ):
self._completeIfNotSet( self._deletions )
return self._NoneIfNotSet( self._deletions )
def deletions(self):
self._completeIfNotSet(self._deletions)
return self._NoneIfNotSet(self._deletions)
@property
def diff_url( self ):
self._completeIfNotSet( self._diff_url )
return self._NoneIfNotSet( self._diff_url )
def diff_url(self):
self._completeIfNotSet(self._diff_url)
return self._NoneIfNotSet(self._diff_url)
@property
def head( self ):
self._completeIfNotSet( self._head )
return self._NoneIfNotSet( self._head )
def head(self):
self._completeIfNotSet(self._head)
return self._NoneIfNotSet(self._head)
@property
def html_url( self ):
self._completeIfNotSet( self._html_url )
return self._NoneIfNotSet( self._html_url )
def html_url(self):
self._completeIfNotSet(self._html_url)
return self._NoneIfNotSet(self._html_url)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def issue_url( self ):
self._completeIfNotSet( self._issue_url )
return self._NoneIfNotSet( self._issue_url )
def issue_url(self):
self._completeIfNotSet(self._issue_url)
return self._NoneIfNotSet(self._issue_url)
@property
def mergeable( self ):
self._completeIfNotSet( self._mergeable )
return self._NoneIfNotSet( self._mergeable )
def mergeable(self):
self._completeIfNotSet(self._mergeable)
return self._NoneIfNotSet(self._mergeable)
@property
def merged( self ):
self._completeIfNotSet( self._merged )
return self._NoneIfNotSet( self._merged )
def merged(self):
self._completeIfNotSet(self._merged)
return self._NoneIfNotSet(self._merged)
@property
def merged_at( self ):
self._completeIfNotSet( self._merged_at )
return self._NoneIfNotSet( self._merged_at )
def merged_at(self):
self._completeIfNotSet(self._merged_at)
return self._NoneIfNotSet(self._merged_at)
@property
def merged_by( self ):
self._completeIfNotSet( self._merged_by )
return self._NoneIfNotSet( self._merged_by )
def merged_by(self):
self._completeIfNotSet(self._merged_by)
return self._NoneIfNotSet(self._merged_by)
@property
def number( self ):
self._completeIfNotSet( self._number )
return self._NoneIfNotSet( self._number )
def number(self):
self._completeIfNotSet(self._number)
return self._NoneIfNotSet(self._number)
@property
def patch_url( self ):
self._completeIfNotSet( self._patch_url )
return self._NoneIfNotSet( self._patch_url )
def patch_url(self):
self._completeIfNotSet(self._patch_url)
return self._NoneIfNotSet(self._patch_url)
@property
def review_comments( self ):
self._completeIfNotSet( self._review_comments )
return self._NoneIfNotSet( self._review_comments )
def review_comments(self):
self._completeIfNotSet(self._review_comments)
return self._NoneIfNotSet(self._review_comments)
@property
def state( self ):
self._completeIfNotSet( self._state )
return self._NoneIfNotSet( self._state )
def state(self):
self._completeIfNotSet(self._state)
return self._NoneIfNotSet(self._state)
@property
def title( self ):
self._completeIfNotSet( self._title )
return self._NoneIfNotSet( self._title )
def title(self):
self._completeIfNotSet(self._title)
return self._NoneIfNotSet(self._title)
@property
def updated_at( self ):
self._completeIfNotSet( self._updated_at )
return self._NoneIfNotSet( self._updated_at )
def updated_at(self):
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
@property
def user( self ):
self._completeIfNotSet( self._user )
return self._NoneIfNotSet( self._user )
def user(self):
self._completeIfNotSet(self._user)
return self._NoneIfNotSet(self._user)
def create_comment( self, body, commit_id, path, position ):
return self.create_review_comment( body, commit_id, path, position )
def create_comment(self, body, commit_id, path, position):
return self.create_review_comment(body, commit_id, path, position)
def create_review_comment( self, body, commit_id, path, position ):
assert isinstance( body, ( str, unicode ) ), body
assert isinstance( commit_id, Commit.Commit ), commit_id
assert isinstance( path, ( str, unicode ) ), path
assert isinstance( position, int ), position
def create_review_comment(self, body, commit_id, path, position):
assert isinstance(body, (str, unicode)), body
assert isinstance(commit_id, Commit.Commit), commit_id
assert isinstance(path, (str, unicode)), path
assert isinstance(position, int), position
post_parameters = {
"body": body,
"commit_id": commit_id._identity,
@@ -173,57 +174,57 @@ class PullRequest( GithubObject.GithubObject ):
None,
post_parameters
)
return PullRequestComment.PullRequestComment( self._requester, data, completed = True )
return PullRequestComment.PullRequestComment(self._requester, data, completed=True)
def create_issue_comment( self, body ):
assert isinstance( body, ( str, unicode ) ), body
def create_issue_comment(self, body):
assert isinstance(body, (str, unicode)), body
post_parameters = {
"body": body,
}
headers, data = self._requester.requestAndCheck(
"POST",
self._parentUrl( self._parentUrl( self.url ) ) + "/issues/" + str( self.number ) + "/comments",
self._parentUrl(self._parentUrl(self.url)) + "/issues/" + str(self.number) + "/comments",
None,
post_parameters
)
return IssueComment.IssueComment( self._requester, data, completed = True )
return IssueComment.IssueComment(self._requester, data, completed=True)
def edit( self, title = GithubObject.NotSet, body = GithubObject.NotSet, state = GithubObject.NotSet ):
assert title is GithubObject.NotSet or isinstance( title, ( str, unicode ) ), title
assert body is GithubObject.NotSet or isinstance( body, ( str, unicode ) ), body
assert state is GithubObject.NotSet or isinstance( state, ( str, unicode ) ), state
def edit(self, title=GithubObject.NotSet, body=GithubObject.NotSet, state=GithubObject.NotSet):
assert title is GithubObject.NotSet or isinstance(title, (str, unicode)), title
assert body is GithubObject.NotSet or isinstance(body, (str, unicode)), body
assert state is GithubObject.NotSet or isinstance(state, (str, unicode)), state
post_parameters = dict()
if title is not GithubObject.NotSet:
post_parameters[ "title" ] = title
post_parameters["title"] = title
if body is not GithubObject.NotSet:
post_parameters[ "body" ] = body
post_parameters["body"] = body
if state is not GithubObject.NotSet:
post_parameters[ "state" ] = state
post_parameters["state"] = state
headers, data = self._requester.requestAndCheck(
"PATCH",
self.url,
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def get_comment( self, id ):
return self.get_review_comment( id )
def get_comment(self, id):
return self.get_review_comment(id)
def get_review_comment( self, id ):
assert isinstance( id, int ), id
def get_review_comment(self, id):
assert isinstance(id, int), id
headers, data = self._requester.requestAndCheck(
"GET",
self._parentUrl( self.url ) + "/comments/" + str( id ),
self._parentUrl(self.url) + "/comments/" + str(id),
None,
None
)
return PullRequestComment.PullRequestComment( self._requester, data, completed = True )
return PullRequestComment.PullRequestComment(self._requester, data, completed=True)
def get_comments( self ):
def get_comments(self):
return self.get_review_comments()
def get_review_comments( self ):
def get_review_comments(self):
return PaginatedList.PaginatedList(
PullRequestComment.PullRequestComment,
self._requester,
@@ -231,7 +232,7 @@ class PullRequest( GithubObject.GithubObject ):
None
)
def get_commits( self ):
def get_commits(self):
return PaginatedList.PaginatedList(
Commit.Commit,
self._requester,
@@ -239,7 +240,7 @@ class PullRequest( GithubObject.GithubObject ):
None
)
def get_files( self ):
def get_files(self):
return PaginatedList.PaginatedList(
File.File,
self._requester,
@@ -247,25 +248,25 @@ class PullRequest( GithubObject.GithubObject ):
None
)
def get_issue_comment( self, id ):
assert isinstance( id, int ), id
def get_issue_comment(self, id):
assert isinstance(id, int), id
headers, data = self._requester.requestAndCheck(
"GET",
self._parentUrl( self._parentUrl( self.url ) ) + "/issues/comments/" + str( id ),
self._parentUrl(self._parentUrl(self.url)) + "/issues/comments/" + str(id),
None,
None
)
return IssueComment.IssueComment( self._requester, data, completed = True )
return IssueComment.IssueComment(self._requester, data, completed=True)
def get_issue_comments( self ):
def get_issue_comments(self):
return PaginatedList.PaginatedList(
IssueComment.IssueComment,
self._requester,
self._parentUrl( self._parentUrl( self.url ) ) + "/issues/" + str( self.number ) + "/comments",
self._parentUrl(self._parentUrl(self.url)) + "/issues/" + str(self.number) + "/comments",
None
)
def is_merged( self ):
def is_merged(self):
status, headers, data = self._requester.requestRaw(
"GET",
self.url + "/merge",
@@ -274,20 +275,20 @@ class PullRequest( GithubObject.GithubObject ):
)
return status == 204
def merge( self, commit_message = GithubObject.NotSet ):
assert commit_message is GithubObject.NotSet or isinstance( commit_message, ( str, unicode ) ), commit_message
def merge(self, commit_message=GithubObject.NotSet):
assert commit_message is GithubObject.NotSet or isinstance(commit_message, (str, unicode)), commit_message
post_parameters = dict()
if commit_message is not GithubObject.NotSet:
post_parameters[ "commit_message" ] = commit_message
post_parameters["commit_message"] = commit_message
headers, data = self._requester.requestAndCheck(
"PUT",
self.url + "/merge",
None,
post_parameters
)
return PullRequestMergeStatus.PullRequestMergeStatus( self._requester, data, completed = True )
return PullRequestMergeStatus.PullRequestMergeStatus(self._requester, data, completed=True)
def _initAttributes( self ):
def _initAttributes(self):
self._additions = GithubObject.NotSet
self._base = GithubObject.NotSet
self._body = GithubObject.NotSet
@@ -315,82 +316,82 @@ class PullRequest( GithubObject.GithubObject ):
self._url = GithubObject.NotSet
self._user = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "additions" in attributes: # pragma no branch
assert attributes[ "additions" ] is None or isinstance( attributes[ "additions" ], int ), attributes[ "additions" ]
self._additions = attributes[ "additions" ]
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 PullRequestPart.PullRequestPart( self._requester, 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" ]
if "changed_files" in attributes: # pragma no branch
assert attributes[ "changed_files" ] is None or isinstance( attributes[ "changed_files" ], int ), attributes[ "changed_files" ]
self._changed_files = attributes[ "changed_files" ]
if "closed_at" in attributes: # pragma no branch
assert attributes[ "closed_at" ] is None or isinstance( attributes[ "closed_at" ], ( str, unicode ) ), attributes[ "closed_at" ]
self._closed_at = self._parseDatetime( attributes[ "closed_at" ] )
if "comments" in attributes: # pragma no branch
assert attributes[ "comments" ] is None or isinstance( attributes[ "comments" ], int ), attributes[ "comments" ]
self._comments = attributes[ "comments" ]
if "commits" in attributes: # pragma no branch
assert attributes[ "commits" ] is None or isinstance( attributes[ "commits" ], int ), attributes[ "commits" ]
self._commits = attributes[ "commits" ]
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 "deletions" in attributes: # pragma no branch
assert attributes[ "deletions" ] is None or isinstance( attributes[ "deletions" ], int ), attributes[ "deletions" ]
self._deletions = attributes[ "deletions" ]
if "diff_url" in attributes: # pragma no branch
assert attributes[ "diff_url" ] is None or isinstance( attributes[ "diff_url" ], ( str, unicode ) ), attributes[ "diff_url" ]
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 PullRequestPart.PullRequestPart( self._requester, 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" ]
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), 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 "mergeable" in attributes: # pragma no branch
assert attributes[ "mergeable" ] is None or isinstance( attributes[ "mergeable" ], bool ), attributes[ "mergeable" ]
self._mergeable = attributes[ "mergeable" ]
if "merged" in attributes: # pragma no branch
assert attributes[ "merged" ] is None or isinstance( attributes[ "merged" ], bool ), attributes[ "merged" ]
self._merged = attributes[ "merged" ]
if "merged_at" in attributes: # pragma no branch
assert attributes[ "merged_at" ] is None or isinstance( attributes[ "merged_at" ], ( str, unicode ) ), attributes[ "merged_at" ]
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 NamedUser.NamedUser( self._requester, attributes[ "merged_by" ], completed = False )
if "number" in attributes: # pragma no branch
assert attributes[ "number" ] is None or isinstance( attributes[ "number" ], int ), 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_comments" in attributes: # pragma no branch
assert attributes[ "review_comments" ] is None or isinstance( attributes[ "review_comments" ], int ), attributes[ "review_comments" ]
self._review_comments = attributes[ "review_comments" ]
if "state" in attributes: # pragma no branch
assert attributes[ "state" ] is None or isinstance( attributes[ "state" ], ( str, unicode ) ), attributes[ "state" ]
self._state = attributes[ "state" ]
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" ]
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 NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False )
def _useAttributes(self, attributes):
if "additions" in attributes: # pragma no branch
assert attributes["additions"] is None or isinstance(attributes["additions"], int), attributes["additions"]
self._additions = attributes["additions"]
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 PullRequestPart.PullRequestPart(self._requester, 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"]
if "changed_files" in attributes: # pragma no branch
assert attributes["changed_files"] is None or isinstance(attributes["changed_files"], int), attributes["changed_files"]
self._changed_files = attributes["changed_files"]
if "closed_at" in attributes: # pragma no branch
assert attributes["closed_at"] is None or isinstance(attributes["closed_at"], (str, unicode)), attributes["closed_at"]
self._closed_at = self._parseDatetime(attributes["closed_at"])
if "comments" in attributes: # pragma no branch
assert attributes["comments"] is None or isinstance(attributes["comments"], int), attributes["comments"]
self._comments = attributes["comments"]
if "commits" in attributes: # pragma no branch
assert attributes["commits"] is None or isinstance(attributes["commits"], int), attributes["commits"]
self._commits = attributes["commits"]
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 "deletions" in attributes: # pragma no branch
assert attributes["deletions"] is None or isinstance(attributes["deletions"], int), attributes["deletions"]
self._deletions = attributes["deletions"]
if "diff_url" in attributes: # pragma no branch
assert attributes["diff_url"] is None or isinstance(attributes["diff_url"], (str, unicode)), attributes["diff_url"]
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 PullRequestPart.PullRequestPart(self._requester, 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"]
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], int), 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 "mergeable" in attributes: # pragma no branch
assert attributes["mergeable"] is None or isinstance(attributes["mergeable"], bool), attributes["mergeable"]
self._mergeable = attributes["mergeable"]
if "merged" in attributes: # pragma no branch
assert attributes["merged"] is None or isinstance(attributes["merged"], bool), attributes["merged"]
self._merged = attributes["merged"]
if "merged_at" in attributes: # pragma no branch
assert attributes["merged_at"] is None or isinstance(attributes["merged_at"], (str, unicode)), attributes["merged_at"]
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 NamedUser.NamedUser(self._requester, attributes["merged_by"], completed=False)
if "number" in attributes: # pragma no branch
assert attributes["number"] is None or isinstance(attributes["number"], int), 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_comments" in attributes: # pragma no branch
assert attributes["review_comments"] is None or isinstance(attributes["review_comments"], int), attributes["review_comments"]
self._review_comments = attributes["review_comments"]
if "state" in attributes: # pragma no branch
assert attributes["state"] is None or isinstance(attributes["state"], (str, unicode)), attributes["state"]
self._state = attributes["state"]
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"]
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 NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
+74 -73
View File
@@ -15,63 +15,64 @@ import GithubObject
import NamedUser
class PullRequestComment( GithubObject.GithubObject ):
class PullRequestComment(GithubObject.GithubObject):
@property
def body( self ):
self._completeIfNotSet( self._body )
return self._NoneIfNotSet( self._body )
def body(self):
self._completeIfNotSet(self._body)
return self._NoneIfNotSet(self._body)
@property
def commit_id( self ):
self._completeIfNotSet( self._commit_id )
return self._NoneIfNotSet( self._commit_id )
def commit_id(self):
self._completeIfNotSet(self._commit_id)
return self._NoneIfNotSet(self._commit_id)
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
def created_at(self):
self._completeIfNotSet(self._created_at)
return self._NoneIfNotSet(self._created_at)
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def original_commit_id( self ):
self._completeIfNotSet( self._original_commit_id )
return self._NoneIfNotSet( self._original_commit_id )
def original_commit_id(self):
self._completeIfNotSet(self._original_commit_id)
return self._NoneIfNotSet(self._original_commit_id)
@property
def original_position( self ):
self._completeIfNotSet( self._original_position )
return self._NoneIfNotSet( self._original_position )
def original_position(self):
self._completeIfNotSet(self._original_position)
return self._NoneIfNotSet(self._original_position)
@property
def path( self ):
self._completeIfNotSet( self._path )
return self._NoneIfNotSet( self._path )
def path(self):
self._completeIfNotSet(self._path)
return self._NoneIfNotSet(self._path)
@property
def position( self ):
self._completeIfNotSet( self._position )
return self._NoneIfNotSet( self._position )
def position(self):
self._completeIfNotSet(self._position)
return self._NoneIfNotSet(self._position)
@property
def updated_at( self ):
self._completeIfNotSet( self._updated_at )
return self._NoneIfNotSet( self._updated_at )
def updated_at(self):
self._completeIfNotSet(self._updated_at)
return self._NoneIfNotSet(self._updated_at)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
@property
def user( self ):
self._completeIfNotSet( self._user )
return self._NoneIfNotSet( self._user )
def user(self):
self._completeIfNotSet(self._user)
return self._NoneIfNotSet(self._user)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -79,8 +80,8 @@ class PullRequestComment( GithubObject.GithubObject ):
None
)
def edit( self, body ):
assert isinstance( body, ( str, unicode ) ), body
def edit(self, body):
assert isinstance(body, (str, unicode)), body
post_parameters = {
"body": body,
}
@@ -90,9 +91,9 @@ class PullRequestComment( GithubObject.GithubObject ):
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def _initAttributes( self ):
def _initAttributes(self):
self._body = GithubObject.NotSet
self._commit_id = GithubObject.NotSet
self._created_at = GithubObject.NotSet
@@ -105,37 +106,37 @@ class PullRequestComment( GithubObject.GithubObject ):
self._url = GithubObject.NotSet
self._user = 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 "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" ]
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 "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "original_commit_id" in attributes: # pragma no branch
assert attributes[ "original_commit_id" ] is None or isinstance( attributes[ "original_commit_id" ], ( str, unicode ) ), attributes[ "original_commit_id" ]
self._original_commit_id = attributes[ "original_commit_id" ]
if "original_position" in attributes: # pragma no branch
assert attributes[ "original_position" ] is None or isinstance( attributes[ "original_position" ], int ), attributes[ "original_position" ]
self._original_position = attributes[ "original_position" ]
if "path" in attributes: # pragma no branch
assert attributes[ "path" ] is None or isinstance( attributes[ "path" ], ( str, unicode ) ), attributes[ "path" ]
self._path = attributes[ "path" ]
if "position" in attributes: # pragma no branch
assert attributes[ "position" ] is None or isinstance( attributes[ "position" ], int ), attributes[ "position" ]
self._position = attributes[ "position" ]
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 NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False )
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 "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"]
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 "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], int), attributes["id"]
self._id = attributes["id"]
if "original_commit_id" in attributes: # pragma no branch
assert attributes["original_commit_id"] is None or isinstance(attributes["original_commit_id"], (str, unicode)), attributes["original_commit_id"]
self._original_commit_id = attributes["original_commit_id"]
if "original_position" in attributes: # pragma no branch
assert attributes["original_position"] is None or isinstance(attributes["original_position"], int), attributes["original_position"]
self._original_position = attributes["original_position"]
if "path" in attributes: # pragma no branch
assert attributes["path"] is None or isinstance(attributes["path"], (str, unicode)), attributes["path"]
self._path = attributes["path"]
if "position" in attributes: # pragma no branch
assert attributes["position"] is None or isinstance(attributes["position"], int), attributes["position"]
self._position = attributes["position"]
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 NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
+19 -18
View File
@@ -13,31 +13,32 @@
import GithubObject
class PullRequestMergeStatus( GithubObject.BasicGithubObject ):
class PullRequestMergeStatus(GithubObject.BasicGithubObject):
@property
def merged( self ):
return self._NoneIfNotSet( self._merged )
def merged(self):
return self._NoneIfNotSet(self._merged)
@property
def message( self ):
return self._NoneIfNotSet( self._message )
def message(self):
return self._NoneIfNotSet(self._message)
@property
def sha( self ):
return self._NoneIfNotSet( self._sha )
def sha(self):
return self._NoneIfNotSet(self._sha)
def _initAttributes( self ):
def _initAttributes(self):
self._merged = GithubObject.NotSet
self._message = GithubObject.NotSet
self._sha = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "merged" in attributes: # pragma no branch
assert attributes[ "merged" ] is None or isinstance( attributes[ "merged" ], bool ), attributes[ "merged" ]
self._merged = attributes[ "merged" ]
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 "sha" in attributes: # pragma no branch
assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ]
self._sha = attributes[ "sha" ]
def _useAttributes(self, attributes):
if "merged" in attributes: # pragma no branch
assert attributes["merged"] is None or isinstance(attributes["merged"], bool), attributes["merged"]
self._merged = attributes["merged"]
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 "sha" in attributes: # pragma no branch
assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"]
self._sha = attributes["sha"]
+29 -28
View File
@@ -16,47 +16,48 @@ import GithubObject
import Repository
import NamedUser
class PullRequestPart( GithubObject.BasicGithubObject ):
class PullRequestPart(GithubObject.BasicGithubObject):
@property
def label( self ):
return self._NoneIfNotSet( self._label )
def label(self):
return self._NoneIfNotSet(self._label)
@property
def ref( self ):
return self._NoneIfNotSet( self._ref )
def ref(self):
return self._NoneIfNotSet(self._ref)
@property
def repo( self ):
return self._NoneIfNotSet( self._repo )
def repo(self):
return self._NoneIfNotSet(self._repo)
@property
def sha( self ):
return self._NoneIfNotSet( self._sha )
def sha(self):
return self._NoneIfNotSet(self._sha)
@property
def user( self ):
return self._NoneIfNotSet( self._user )
def user(self):
return self._NoneIfNotSet(self._user)
def _initAttributes( self ):
def _initAttributes(self):
self._label = GithubObject.NotSet
self._ref = GithubObject.NotSet
self._repo = GithubObject.NotSet
self._sha = GithubObject.NotSet
self._user = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "label" in attributes: # pragma no branch
assert attributes[ "label" ] is None or isinstance( attributes[ "label" ], ( str, unicode ) ), attributes[ "label" ]
self._label = attributes[ "label" ]
if "ref" in attributes: # pragma no branch
assert attributes[ "ref" ] is None or isinstance( attributes[ "ref" ], ( str, unicode ) ), attributes[ "ref" ]
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 Repository.Repository( self._requester, 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 NamedUser.NamedUser( self._requester, attributes[ "user" ], completed = False )
def _useAttributes(self, attributes):
if "label" in attributes: # pragma no branch
assert attributes["label"] is None or isinstance(attributes["label"], (str, unicode)), attributes["label"]
self._label = attributes["label"]
if "ref" in attributes: # pragma no branch
assert attributes["ref"] is None or isinstance(attributes["ref"], (str, unicode)), attributes["ref"]
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 Repository.Repository(self._requester, 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 NamedUser.NamedUser(self._requester, attributes["user"], completed=False)
+443 -442
View File
File diff suppressed because it is too large Load Diff
+47 -45
View File
@@ -13,40 +13,42 @@
import GithubObject
class RepositoryKey( GithubObject.GithubObject ):
def __init__( self, requester, attributes, completed, repoUrl ):
GithubObject.GithubObject.__init__( self, requester, attributes, completed )
class RepositoryKey(GithubObject.GithubObject):
def __init__(self, requester, attributes, completed, repoUrl):
GithubObject.GithubObject.__init__(self, requester, attributes, completed)
self.__repoUrl = repoUrl
@property
def __customUrl( self ):
return self.__repoUrl + "/keys/" + str( self.id )
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def __customUrl(self):
return self.__repoUrl + "/keys/" + str(self.id)
@property
def key( self ):
self._completeIfNotSet( self._key )
return self._NoneIfNotSet( self._key )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def title( self ):
self._completeIfNotSet( self._title )
return self._NoneIfNotSet( self._title )
def key(self):
self._completeIfNotSet(self._key)
return self._NoneIfNotSet(self._key)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def title(self):
self._completeIfNotSet(self._title)
return self._NoneIfNotSet(self._title)
@property
def verified( self ):
self._completeIfNotSet( self._verified )
return self._NoneIfNotSet( self._verified )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def delete( self ):
@property
def verified(self):
self._completeIfNotSet(self._verified)
return self._NoneIfNotSet(self._verified)
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.__customUrl,
@@ -54,42 +56,42 @@ class RepositoryKey( GithubObject.GithubObject ):
None
)
def edit( self, title = GithubObject.NotSet, key = GithubObject.NotSet ):
assert title is GithubObject.NotSet or isinstance( title, ( str, unicode ) ), title
assert key is GithubObject.NotSet or isinstance( key, ( str, unicode ) ), key
def edit(self, title=GithubObject.NotSet, key=GithubObject.NotSet):
assert title is GithubObject.NotSet or isinstance(title, (str, unicode)), title
assert key is GithubObject.NotSet or isinstance(key, (str, unicode)), key
post_parameters = dict()
if title is not GithubObject.NotSet:
post_parameters[ "title" ] = title
post_parameters["title"] = title
if key is not GithubObject.NotSet:
post_parameters[ "key" ] = key
post_parameters["key"] = key
headers, data = self._requester.requestAndCheck(
"PATCH",
self.__customUrl,
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def _initAttributes( self ):
def _initAttributes(self):
self._id = GithubObject.NotSet
self._key = GithubObject.NotSet
self._title = GithubObject.NotSet
self._url = GithubObject.NotSet
self._verified = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "key" in attributes: # pragma no branch
assert attributes[ "key" ] is None or isinstance( attributes[ "key" ], ( str, unicode ) ), attributes[ "key" ]
self._key = attributes[ "key" ]
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 "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
if "verified" in attributes: # pragma no branch
assert attributes[ "verified" ] is None or isinstance( attributes[ "verified" ], bool ), attributes[ "verified" ]
self._verified = attributes[ "verified" ]
def _useAttributes(self, attributes):
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], int), attributes["id"]
self._id = attributes["id"]
if "key" in attributes: # pragma no branch
assert attributes["key"] is None or isinstance(attributes["key"], (str, unicode)), attributes["key"]
self._key = attributes["key"]
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 "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
if "verified" in attributes: # pragma no branch
assert attributes["verified"] is None or isinstance(attributes["verified"], bool), attributes["verified"]
self._verified = attributes["verified"]
+54 -39
View File
@@ -11,6 +11,7 @@
# 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 logging
import httplib
import base64
import urllib
@@ -21,24 +22,25 @@ atLeastPython26 = sys.hexversion >= 0x02060000
if atLeastPython26:
import json
else: #pragma no cover
import simplejson as json #pragma no cover
else: # pragma no cover
import simplejson as json # pragma no cover
import GithubException
class Requester:
__httpConnectionClass = httplib.HTTPConnection
__httpsConnectionClass = httplib.HTTPSConnection
@classmethod
def injectConnectionClasses( cls, httpConnectionClass, httpsConnectionClass ):
def injectConnectionClasses(cls, httpConnectionClass, httpsConnectionClass):
cls.__httpConnectionClass = httpConnectionClass
cls.__httpsConnectionClass = httpsConnectionClass
def __init__( self, login_or_token, password, base_url, timeout ):
def __init__(self, login_or_token, password, base_url, timeout):
if password is not None:
login = login_or_token
self.__authorizationHeader = "Basic " + base64.b64encode( login + ":" + password ).replace( '\n', '' )
self.__authorizationHeader = "Basic " + base64.b64encode(login + ":" + password).replace('\n', '')
elif login_or_token is not None:
token = login_or_token
self.__authorizationHeader = "token " + token
@@ -46,7 +48,7 @@ class Requester:
self.__authorizationHeader = None
self.__base_url = base_url
o = urlparse.urlparse( base_url )
o = urlparse.urlparse(base_url)
self.__hostname = o.hostname
self.__port = o.port
self.__prefix = o.path
@@ -57,69 +59,82 @@ class Requester:
elif o.scheme == "http":
self.__connectionClass = self.__httpConnectionClass
else:
assert( False ) #pragma no cover
self.rate_limiting = ( 5000, 5000 )
assert(False) # pragma no cover
self.rate_limiting = (5000, 5000)
def requestAndCheck( self, verb, url, parameters, input ):
status, headers, output = self.requestRaw( verb, url, parameters, input )
output = self.__structuredFromJson( output )
def requestAndCheck(self, verb, url, parameters, input):
status, headers, output = self.requestRaw(verb, url, parameters, input)
output = self.__structuredFromJson(output)
if status >= 400:
raise GithubException.GithubException( status, output )
raise GithubException.GithubException(status, output)
return headers, output
def requestRaw( self, verb, url, parameters, input ):
assert verb in [ "HEAD", "GET", "POST", "PATCH", "PUT", "DELETE" ]
def requestRaw(self, verb, url, parameters, input):
assert verb in ["HEAD", "GET", "POST", "PATCH", "PUT", "DELETE"]
#URLs generated locally will be relative to __base_url
#URLs returned from the server will start with __base_url
if url.startswith( "/" ):
# URLs generated locally will be relative to __base_url
# URLs returned from the server will start with __base_url
if url.startswith("/"):
url = self.__prefix + url
else:
o = urlparse.urlparse( url )
assert o.scheme == self.__scheme or o.scheme == "https" and self.__scheme == "http" # Issue #80
o = urlparse.urlparse(url)
assert o.scheme == self.__scheme or o.scheme == "https" and self.__scheme == "http" # Issue #80
assert o.hostname == self.__hostname
assert o.path.startswith( self.__prefix )
assert o.path.startswith(self.__prefix)
assert o.port == self.__port
url = o.path
if o.query != "":
url += "?" + o.query
url = self.__completeUrl(url, parameters)
headers = dict()
requestHeaders = dict()
if input is not None:
requestHeaders["Content-Type"] = "application/json"
if self.__authorizationHeader is not None:
headers[ "Authorization" ] = self.__authorizationHeader
requestHeaders["Authorization"] = self.__authorizationHeader
if atLeastPython26:
cnx = self.__connectionClass( host = self.__hostname, port = self.__port, strict = True, timeout = self.__timeout )
else: #pragma no cover
cnx = self.__connectionClass( host = self.__hostname, port = self.__port, strict = True ) #pragma no cover
cnx = self.__connectionClass(host=self.__hostname, port=self.__port, strict=True, timeout=self.__timeout)
else: # pragma no cover
cnx = self.__connectionClass(host=self.__hostname, port=self.__port, strict=True) # pragma no cover
cnx.request(
verb,
self.__completeUrl( url, parameters ),
json.dumps( input ),
headers
url,
json.dumps(input),
requestHeaders
)
response = cnx.getresponse()
status = response.status
headers = dict( response.getheaders() )
responseHeaders = dict(response.getheaders())
output = response.read()
cnx.close()
if "x-ratelimit-remaining" in headers and "x-ratelimit-limit" in headers:
self.rate_limiting = ( int( headers[ "x-ratelimit-remaining" ] ), int( headers[ "x-ratelimit-limit" ] ) )
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"]))
# print verb, self.__base_url + url, parameters, input, "==>", status, str( headers ), str( output )
return status, headers, output
logger = logging.getLogger(__name__)
if logger.isEnabledFor(logging.DEBUG):
if "Authorization" in requestHeaders:
if requestHeaders["Authorization"].startswith("Basic"):
requestHeaders["Authorization"] = "Basic (login and password removed)"
elif requestHeaders["Authorization"].startswith("token"):
requestHeaders["Authorization"] = "token (oauth token removed)"
else:
requestHeaders["Authorization"] = "Unknown authorization removed"
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))
def __completeUrl( self, url, parameters ):
if parameters is None or len( parameters ) == 0:
return status, responseHeaders, output
def __completeUrl(self, url, parameters):
if parameters is None or len(parameters) == 0:
return url
else:
return url + "?" + urllib.urlencode( parameters )
return url + "?" + urllib.urlencode(parameters)
def __structuredFromJson( self, data ):
if len( data ) == 0:
def __structuredFromJson(self, data):
if len(data) == 0:
return None
else:
return json.loads( data )
return json.loads(data)
+24 -23
View File
@@ -15,39 +15,40 @@ import GithubObject
import Commit
class Tag( GithubObject.BasicGithubObject ):
class Tag(GithubObject.BasicGithubObject):
@property
def commit( self ):
return self._NoneIfNotSet( self._commit )
def commit(self):
return self._NoneIfNotSet(self._commit)
@property
def name( self ):
return self._NoneIfNotSet( self._name )
def name(self):
return self._NoneIfNotSet(self._name)
@property
def tarball_url( self ):
return self._NoneIfNotSet( self._tarball_url )
def tarball_url(self):
return self._NoneIfNotSet(self._tarball_url)
@property
def zipball_url( self ):
return self._NoneIfNotSet( self._zipball_url )
def zipball_url(self):
return self._NoneIfNotSet(self._zipball_url)
def _initAttributes( self ):
def _initAttributes(self):
self._commit = GithubObject.NotSet
self._name = GithubObject.NotSet
self._tarball_url = GithubObject.NotSet
self._zipball_url = GithubObject.NotSet
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 Commit.Commit( self._requester, 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" ]
if "tarball_url" in attributes: # pragma no branch
assert attributes[ "tarball_url" ] is None or isinstance( attributes[ "tarball_url" ], ( str, unicode ) ), attributes[ "tarball_url" ]
self._tarball_url = attributes[ "tarball_url" ]
if "zipball_url" in attributes: # pragma no branch
assert attributes[ "zipball_url" ] is None or isinstance( attributes[ "zipball_url" ], ( str, unicode ) ), attributes[ "zipball_url" ]
self._zipball_url = attributes[ "zipball_url" ]
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 Commit.Commit(self._requester, 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"]
if "tarball_url" in attributes: # pragma no branch
assert attributes["tarball_url"] is None or isinstance(attributes["tarball_url"], (str, unicode)), attributes["tarball_url"]
self._tarball_url = attributes["tarball_url"]
if "zipball_url" in attributes: # pragma no branch
assert attributes["zipball_url"] is None or isinstance(attributes["zipball_url"], (str, unicode)), attributes["zipball_url"]
self._zipball_url = attributes["zipball_url"]
+61 -60
View File
@@ -17,39 +17,40 @@ import PaginatedList
import Repository
import NamedUser
class Team( GithubObject.GithubObject ):
class Team(GithubObject.GithubObject):
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def members_count( self ):
self._completeIfNotSet( self._members_count )
return self._NoneIfNotSet( self._members_count )
def members_count(self):
self._completeIfNotSet(self._members_count)
return self._NoneIfNotSet(self._members_count)
@property
def name( self ):
self._completeIfNotSet( self._name )
return self._NoneIfNotSet( self._name )
def name(self):
self._completeIfNotSet(self._name)
return self._NoneIfNotSet(self._name)
@property
def permission( self ):
self._completeIfNotSet( self._permission )
return self._NoneIfNotSet( self._permission )
def permission(self):
self._completeIfNotSet(self._permission)
return self._NoneIfNotSet(self._permission)
@property
def repos_count( self ):
self._completeIfNotSet( self._repos_count )
return self._NoneIfNotSet( self._repos_count )
def repos_count(self):
self._completeIfNotSet(self._repos_count)
return self._NoneIfNotSet(self._repos_count)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
def add_to_members( self, member ):
assert isinstance( member, NamedUser.NamedUser ), member
def add_to_members(self, member):
assert isinstance(member, NamedUser.NamedUser), member
headers, data = self._requester.requestAndCheck(
"PUT",
self.url + "/members/" + member._identity,
@@ -57,8 +58,8 @@ class Team( GithubObject.GithubObject ):
None
)
def add_to_repos( self, repo ):
assert isinstance( repo, Repository.Repository ), repo
def add_to_repos(self, repo):
assert isinstance(repo, Repository.Repository), repo
headers, data = self._requester.requestAndCheck(
"PUT",
self.url + "/repos/" + repo._identity,
@@ -66,7 +67,7 @@ class Team( GithubObject.GithubObject ):
None
)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -74,23 +75,23 @@ class Team( GithubObject.GithubObject ):
None
)
def edit( self, name, permission = GithubObject.NotSet ):
assert isinstance( name, ( str, unicode ) ), name
assert permission is GithubObject.NotSet or isinstance( permission, ( str, unicode ) ), permission
def edit(self, name, permission=GithubObject.NotSet):
assert isinstance(name, (str, unicode)), name
assert permission is GithubObject.NotSet or isinstance(permission, (str, unicode)), permission
post_parameters = {
"name": name,
}
if permission is not GithubObject.NotSet:
post_parameters[ "permission" ] = permission
post_parameters["permission"] = permission
headers, data = self._requester.requestAndCheck(
"PATCH",
self.url,
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def get_members( self ):
def get_members(self):
return PaginatedList.PaginatedList(
NamedUser.NamedUser,
self._requester,
@@ -98,7 +99,7 @@ class Team( GithubObject.GithubObject ):
None
)
def get_repos( self ):
def get_repos(self):
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
@@ -106,8 +107,8 @@ class Team( GithubObject.GithubObject ):
None
)
def has_in_members( self, member ):
assert isinstance( member, NamedUser.NamedUser ), member
def has_in_members(self, member):
assert isinstance(member, NamedUser.NamedUser), member
status, headers, data = self._requester.requestRaw(
"GET",
self.url + "/members/" + member._identity,
@@ -116,8 +117,8 @@ class Team( GithubObject.GithubObject ):
)
return status == 204
def has_in_repos( self, repo ):
assert isinstance( repo, Repository.Repository ), repo
def has_in_repos(self, repo):
assert isinstance(repo, Repository.Repository), repo
status, headers, data = self._requester.requestRaw(
"GET",
self.url + "/repos/" + repo._identity,
@@ -126,8 +127,8 @@ class Team( GithubObject.GithubObject ):
)
return status == 204
def remove_from_members( self, member ):
assert isinstance( member, NamedUser.NamedUser ), member
def remove_from_members(self, member):
assert isinstance(member, NamedUser.NamedUser), member
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url + "/members/" + member._identity,
@@ -135,8 +136,8 @@ class Team( GithubObject.GithubObject ):
None
)
def remove_from_repos( self, repo ):
assert isinstance( repo, Repository.Repository ), repo
def remove_from_repos(self, repo):
assert isinstance(repo, Repository.Repository), repo
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url + "/repos/" + repo._identity,
@@ -145,10 +146,10 @@ class Team( GithubObject.GithubObject ):
)
@property
def _identity( self ):
def _identity(self):
return self.id
def _initAttributes( self ):
def _initAttributes(self):
self._id = GithubObject.NotSet
self._members_count = GithubObject.NotSet
self._name = GithubObject.NotSet
@@ -156,22 +157,22 @@ class Team( GithubObject.GithubObject ):
self._repos_count = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "members_count" in attributes: # pragma no branch
assert attributes[ "members_count" ] is None or isinstance( attributes[ "members_count" ], int ), attributes[ "members_count" ]
self._members_count = attributes[ "members_count" ]
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 "permission" in attributes: # pragma no branch
assert attributes[ "permission" ] is None or isinstance( attributes[ "permission" ], ( str, unicode ) ), attributes[ "permission" ]
self._permission = attributes[ "permission" ]
if "repos_count" in attributes: # pragma no branch
assert attributes[ "repos_count" ] is None or isinstance( attributes[ "repos_count" ], int ), attributes[ "repos_count" ]
self._repos_count = attributes[ "repos_count" ]
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
def _useAttributes(self, attributes):
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], int), attributes["id"]
self._id = attributes["id"]
if "members_count" in attributes: # pragma no branch
assert attributes["members_count"] is None or isinstance(attributes["members_count"], int), attributes["members_count"]
self._members_count = attributes["members_count"]
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 "permission" in attributes: # pragma no branch
assert attributes["permission"] is None or isinstance(attributes["permission"], (str, unicode)), attributes["permission"]
self._permission = attributes["permission"]
if "repos_count" in attributes: # pragma no branch
assert attributes["repos_count"] is None or isinstance(attributes["repos_count"], int), attributes["repos_count"]
self._repos_count = attributes["repos_count"]
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+41 -40
View File
@@ -13,33 +13,34 @@
import GithubObject
class UserKey( GithubObject.GithubObject ):
class UserKey(GithubObject.GithubObject):
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
def id(self):
self._completeIfNotSet(self._id)
return self._NoneIfNotSet(self._id)
@property
def key( self ):
self._completeIfNotSet( self._key )
return self._NoneIfNotSet( self._key )
def key(self):
self._completeIfNotSet(self._key)
return self._NoneIfNotSet(self._key)
@property
def title( self ):
self._completeIfNotSet( self._title )
return self._NoneIfNotSet( self._title )
def title(self):
self._completeIfNotSet(self._title)
return self._NoneIfNotSet(self._title)
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def url(self):
self._completeIfNotSet(self._url)
return self._NoneIfNotSet(self._url)
@property
def verified( self ):
self._completeIfNotSet( self._verified )
return self._NoneIfNotSet( self._verified )
def verified(self):
self._completeIfNotSet(self._verified)
return self._NoneIfNotSet(self._verified)
def delete( self ):
def delete(self):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
@@ -47,42 +48,42 @@ class UserKey( GithubObject.GithubObject ):
None
)
def edit( self, title = GithubObject.NotSet, key = GithubObject.NotSet ):
assert title is GithubObject.NotSet or isinstance( title, ( str, unicode ) ), title
assert key is GithubObject.NotSet or isinstance( key, ( str, unicode ) ), key
def edit(self, title=GithubObject.NotSet, key=GithubObject.NotSet):
assert title is GithubObject.NotSet or isinstance(title, (str, unicode)), title
assert key is GithubObject.NotSet or isinstance(key, (str, unicode)), key
post_parameters = dict()
if title is not GithubObject.NotSet:
post_parameters[ "title" ] = title
post_parameters["title"] = title
if key is not GithubObject.NotSet:
post_parameters[ "key" ] = key
post_parameters["key"] = key
headers, data = self._requester.requestAndCheck(
"PATCH",
self.url,
None,
post_parameters
)
self._useAttributes( data )
self._useAttributes(data)
def _initAttributes( self ):
def _initAttributes(self):
self._id = GithubObject.NotSet
self._key = GithubObject.NotSet
self._title = GithubObject.NotSet
self._url = GithubObject.NotSet
self._verified = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "key" in attributes: # pragma no branch
assert attributes[ "key" ] is None or isinstance( attributes[ "key" ], ( str, unicode ) ), attributes[ "key" ]
self._key = attributes[ "key" ]
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 "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]
if "verified" in attributes: # pragma no branch
assert attributes[ "verified" ] is None or isinstance( attributes[ "verified" ], bool ), attributes[ "verified" ]
self._verified = attributes[ "verified" ]
def _useAttributes(self, attributes):
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], int), attributes["id"]
self._id = attributes["id"]
if "key" in attributes: # pragma no branch
assert attributes["key"] is None or isinstance(attributes["key"], (str, unicode)), attributes["key"]
self._key = attributes["key"]
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 "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
if "verified" in attributes: # pragma no branch
assert attributes["verified"] is None or isinstance(attributes["verified"], bool), attributes["verified"]
self._verified = attributes["verified"]
+8
View File
@@ -11,8 +11,16 @@
# 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 logging
from Github import Github
from GithubException import GithubException
from InputFileContent import InputFileContent
from InputGitAuthor import InputGitAuthor
from InputGitTreeElement import InputGitTreeElement
def enable_console_debug_logging():
logger = logging.getLogger("github")
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())
+60
View File
@@ -0,0 +1,60 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
from AuthenticatedUser import *
from Authentication import *
from Authorization import *
from Branch import *
from Commit import *
from CommitComment import *
from CommitStatus import *
from ContentFile import *
from Download import *
from Event import *
from Gist import *
from GistComment import *
from GitBlob import *
from GitCommit import *
from Github import *
from GitRef import *
from GitTag import *
from GitTree import *
from Hook import *
from Issue import *
from IssueComment import *
from IssueEvent import *
from Label import *
from Milestone import *
from NamedUser import *
from Markdown import *
from Organization import *
from PullRequest import *
from PullRequestComment import *
from PullRequestFile import *
from RateLimiting import *
from Repository import *
from RepositoryKey import *
from Tag import *
from Team import *
from UserKey import *
from PaginatedList import *
from Exceptions import *
from Enterprise import *
from Logging import *
from Issue33 import *
from Issue50 import *
from Issue54 import *
from Issue80 import *
from Issue87 import *
+176
View File
@@ -0,0 +1,176 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import github
import datetime
class AuthenticatedUser(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.user = self.g.get_user()
def testAttributes(self):
self.assertEqual(self.user.avatar_url, "https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png")
self.assertEqual(self.user.bio, "")
self.assertEqual(self.user.blog, "http://vincent-jacques.net")
self.assertEqual(self.user.collaborators, 0)
self.assertEqual(self.user.company, "Criteo")
self.assertEqual(self.user.created_at, datetime.datetime(2010, 7, 9, 6, 10, 6))
self.assertEqual(self.user.disk_usage, 16692)
self.assertEqual(self.user.email, "vincent@vincent-jacques.net")
self.assertEqual(self.user.followers, 13)
self.assertEqual(self.user.following, 24)
self.assertEqual(self.user.gravatar_id, "b68de5ae38616c296fa345d2b9df2225")
self.assertEqual(self.user.hireable, False)
self.assertEqual(self.user.html_url, "https://github.com/jacquev6")
self.assertEqual(self.user.id, 327146)
self.assertEqual(self.user.location, "Paris, France")
self.assertEqual(self.user.login, "jacquev6")
self.assertEqual(self.user.name, "Vincent Jacques")
self.assertEqual(self.user.owned_private_repos, 5)
self.assertEqual(self.user.plan.name, "micro")
self.assertEqual(self.user.plan.collaborators, 1)
self.assertEqual(self.user.plan.space, 614400)
self.assertEqual(self.user.plan.private_repos, 5)
self.assertEqual(self.user.private_gists, 5)
self.assertEqual(self.user.public_gists, 1)
self.assertEqual(self.user.public_repos, 10)
self.assertEqual(self.user.total_private_repos, 5)
self.assertEqual(self.user.type, "User")
self.assertEqual(self.user.url, "https://api.github.com/users/jacquev6")
def testEditWithoutArguments(self):
self.user.edit()
def testEditWithAllArguments(self):
self.user.edit("Name edited by PyGithub", "Email edited by PyGithub", "Blog edited by PyGithub", "Company edited by PyGithub", "Location edited by PyGithub", True, "Bio edited by PyGithub")
self.assertEqual(self.user.name, "Name edited by PyGithub")
self.assertEqual(self.user.email, "Email edited by PyGithub")
self.assertEqual(self.user.blog, "Blog edited by PyGithub")
self.assertEqual(self.user.company, "Company edited by PyGithub")
self.assertEqual(self.user.location, "Location edited by PyGithub")
self.assertEqual(self.user.hireable, True)
self.assertEqual(self.user.bio, "Bio edited by PyGithub")
def testEmails(self):
self.assertEqual(self.user.get_emails(), ["vincent@vincent-jacques.net", "github.com@vincent-jacques.net"])
self.user.add_to_emails("1@foobar.com", "2@foobar.com")
self.assertEqual(self.user.get_emails(), ["vincent@vincent-jacques.net", "1@foobar.com", "2@foobar.com", "github.com@vincent-jacques.net"])
self.user.remove_from_emails("1@foobar.com", "2@foobar.com")
self.assertEqual(self.user.get_emails(), ["vincent@vincent-jacques.net", "github.com@vincent-jacques.net"])
def testFollowing(self):
nvie = self.g.get_user("nvie")
self.assertListKeyEqual(self.user.get_following(), lambda u: u.login, ["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", "nvie"])
self.assertEqual(self.user.has_in_following(nvie), True)
self.user.remove_from_following(nvie)
self.assertEqual(self.user.has_in_following(nvie), False)
self.user.add_to_following(nvie)
self.assertEqual(self.user.has_in_following(nvie), True)
self.assertListKeyEqual(self.user.get_followers(), lambda u: u.login, ["jnorthrup", "brugidou", "regisb", "walidk", "afzalkhan", "sdanzan", "vineus", "gturri", "fjardon", "cjuniet", "jardon-u", "kamaradclimber", "L42y"])
def testWatching(self):
gitflow = self.g.get_user("nvie").get_repo("gitflow")
self.assertListKeyEqual(self.user.get_watched(), lambda r: r.name, ["git", "boost.php", "capistrano", "boost.perl", "git-subtree", "git-hg", "homebrew", "celtic_knot", "twisted-intro", "markup", "hub", "gitflow", "murder", "boto", "agit", "d3", "pygit2", "git-pulls", "django_mathlatex", "scrumblr", "developer.github.com", "python-github3", "PlantUML", "bootstrap", "drawnby", "django-socketio", "django-realtime", "playground", "BozoCrack", "FatherBeaver", "PyGithub", "django", "django", "TestPyGithub"])
self.assertEqual(self.user.has_in_watched(gitflow), True)
self.user.remove_from_watched(gitflow)
self.assertEqual(self.user.has_in_watched(gitflow), False)
self.user.add_to_watched(gitflow)
self.assertEqual(self.user.has_in_watched(gitflow), True)
def testStarring(self):
gitflow = self.g.get_user("nvie").get_repo("gitflow")
self.assertListKeyEqual(self.user.get_starred(), lambda r: r.name, ["git", "boost.php", "capistrano", "boost.perl", "git-subtree", "git-hg", "homebrew", "celtic_knot", "twisted-intro", "markup", "hub", "gitflow", "murder", "boto", "agit", "d3", "pygit2", "git-pulls", "django_mathlatex", "scrumblr", "developer.github.com", "python-github3", "PlantUML", "bootstrap", "drawnby", "django-socketio", "django-realtime", "playground", "BozoCrack", "FatherBeaver", "amaunet", "django", "django", "moviePlanning", "folly"])
self.assertEqual(self.user.has_in_starred(gitflow), True)
self.user.remove_from_starred(gitflow)
self.assertEqual(self.user.has_in_starred(gitflow), False)
self.user.add_to_starred(gitflow)
self.assertEqual(self.user.has_in_starred(gitflow), True)
def testSubscriptions(self):
gitflow = self.g.get_user("nvie").get_repo("gitflow")
self.assertListKeyEqual(self.user.get_subscriptions(), lambda r: r.name, ["gitflow", "ViDE", "Boost.HierarchicalEnum", "QuadProgMm", "DrawSyntax", "DrawTurksHead", "PrivateStuff", "vincent-jacques.net", "Hacking", "C4Planner", "developer.github.com", "PyGithub", "PyGithub", "django", "CinePlanning", "PyGithub", "PyGithub", "PyGithub", "IpMap", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub"])
self.assertEqual(self.user.has_in_subscriptions(gitflow), True)
self.user.remove_from_subscriptions(gitflow)
self.assertEqual(self.user.has_in_subscriptions(gitflow), False)
self.user.add_to_subscriptions(gitflow)
self.assertEqual(self.user.has_in_subscriptions(gitflow), True)
def testGetAuthorizations(self):
self.assertListKeyEqual(self.user.get_authorizations(), lambda a: a.id, [372294])
def testCreateRepository(self):
repo = self.user.create_repo("TestPyGithub")
self.assertEqual(repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub")
def testCreateRepositoryWithAllArguments(self):
repo = self.user.create_repo("TestPyGithub", "Repo created by PyGithub", "http://foobar.com", private=False, has_issues=False, has_wiki=False, has_downloads=False)
self.assertEqual(repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub")
def testCreateAuthorizationWithoutArguments(self):
authorization = self.user.create_authorization()
self.assertEqual(authorization.id, 372259)
def testCreateAuthorizationWithAllArguments(self):
authorization = self.user.create_authorization(["repo"], "Note created by PyGithub", "http://vincent-jacques.net/PyGithub")
self.assertEqual(authorization.id, 372294)
def testCreateGist(self):
gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")}, "Gist created by PyGithub")
self.assertEqual(gist.description, "Gist created by PyGithub")
self.assertEqual(gist.files.keys(), ["foobar.txt"])
self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
def testCreateGistWithoutDescription(self):
gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")})
self.assertEqual(gist.description, None)
self.assertEqual(gist.files.keys(), ["foobar.txt"])
self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
def testCreateKey(self):
key = self.user.create_key("Key added through PyGithub", "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Mm0RjTNAYFfSCtUpO54usdseroUSIYg5KX4JoseTpqyiB/hqewjYLAdUq/tNIQzrkoEJWSyZrQt0ma7/YCyMYuNGd3DU6q6ZAyBeY3E9RyCiKjO3aTL2VKQGFvBVVmGdxGVSCITRphAcsKc/PF35/fg9XP9S0anMXcEFtdfMHz41SSw+XtE+Vc+6cX9FuI5qUfLGbkv8L1v3g4uw9VXlzq4GfTA+1S7D6mcoGHopAIXFlVr+2RfDKdSURMcB22z41fljO1MW4+zUS/4FyUTpL991es5fcwKXYoiE+x06VJeJJ1Krwx+DZj45uweV6cHXt2JwJEI9fWB6WyBlDejWw== vincent@IDEE")
self.assertEqual(key.id, 2626650)
def testGetEvents(self):
self.assertListKeyBegin(self.user.get_events(), lambda e: e.type, ["PushEvent", "IssuesEvent", "IssueCommentEvent", "PushEvent"])
def testGetOrganizationEvents(self):
self.assertListKeyBegin(self.user.get_organization_events(self.g.get_organization("BeaverSoftware")), lambda e: e.type, ["CreateEvent", "CreateEvent", "PushEvent", "PushEvent"])
def testGetGists(self):
self.assertListKeyEqual(self.user.get_gists(), lambda g: g.id, ["2793505", "2793179", "11cb445f8197e17d303d", "1942384", "dcb7de17e8a52b74541d"])
def testGetStarredGists(self):
self.assertListKeyEqual(self.user.get_starred_gists(), lambda g: g.id, ["1942384", "dcb7de17e8a52b74541d"])
def testGetIssues(self):
self.assertListKeyEqual(self.user.get_issues(), lambda i: (i.id, i.repository.name), [(4639931, "PyGithub"), (4452000, "PyGithub"), (4356743, "PyGithub"), (3716033, "PyGithub"), (3715946, "PyGithub"), (3643837, "PyGithub"), (3628022, "PyGithub"), (3624595, "PyGithub"), (3624570, "PyGithub"), (3624561, "PyGithub"), (3624556, "PyGithub"), (3619973, "PyGithub"), (3527266, "PyGithub"), (3527245, "PyGithub"), (3527231, "PyGithub")])
def testGetKeys(self):
self.assertListKeyEqual(self.user.get_keys(), lambda k: k.title, ["vincent@home", "vincent@gandi", "vincent@aws", "vincent@macbook"])
def testGetOrgs(self):
self.assertListKeyEqual(self.user.get_orgs(), lambda o: o.login, ["BeaverSoftware"])
def testGetRepos(self):
self.assertListKeyEqual(self.user.get_repos(), lambda r: r.name, ["TestPyGithub", "django", "PyGithub", "developer.github.com", "acme-public-website", "C4Planner", "Hacking", "vincent-jacques.net", "Contests", "Candidates", "Tests", "DrawTurksHead", "DrawSyntax", "QuadProgMm", "Boost.HierarchicalEnum", "ViDE"])
def testGetReposWithArguments(self):
self.assertListKeyEqual(self.user.get_repos("public", "full_name", "desc"), lambda r: r.name, ["ViDE", "QuadProgMm", "PyGithub", "DrawTurksHead", "DrawSyntax", "django", "developer.github.com", "C4Planner", "Boost.HierarchicalEnum", "acme-public-website"])
def testCreateFork(self):
repo = self.user.create_fork(self.g.get_user("nvie").get_repo("gitflow"))
self.assertEqual(repo.source.full_name, "nvie/gitflow")
@@ -14,15 +14,16 @@
import Framework
import github
class Authentication( Framework.BasicTestCase ):
def testNoAuthentication( self ):
class Authentication(Framework.BasicTestCase):
def testNoAuthentication(self):
g = github.Github()
self.assertEqual( g.get_user( "jacquev6" ).name, "Vincent Jacques" )
self.assertEqual(g.get_user("jacquev6").name, "Vincent Jacques")
def testBasicAuthentication( self ):
g = github.Github( self.login, self.password )
self.assertEqual( g.get_user( "jacquev6" ).name, "Vincent Jacques" )
def testBasicAuthentication(self):
g = github.Github(self.login, self.password)
self.assertEqual(g.get_user("jacquev6").name, "Vincent Jacques")
def testOAuthAuthentication( self ):
g = github.Github( self.oauth_token )
self.assertEqual( g.get_user( "jacquev6" ).name, "Vincent Jacques" )
def testOAuthAuthentication(self):
g = github.Github(self.oauth_token)
self.assertEqual(g.get_user("jacquev6").name, "Vincent Jacques")
+52
View File
@@ -0,0 +1,52 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import datetime
class Authorization(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.authorization = self.g.get_user().get_authorization(372259)
def testAttributes(self):
self.assertEqual(self.authorization.app.url, "http://developer.github.com/v3/oauth/#oauth-authorizations-api")
self.assertEqual(self.authorization.app.name, "GitHub API")
self.assertEqual(self.authorization.created_at, datetime.datetime(2012, 5, 22, 18, 3, 17))
self.assertEqual(self.authorization.id, 372259)
self.assertEqual(self.authorization.note, None)
self.assertEqual(self.authorization.note_url, None)
self.assertEqual(self.authorization.scopes, [])
self.assertEqual(self.authorization.token, "82459c4500086f8f0cc67d2936c17d1e27ad1c33")
self.assertEqual(self.authorization.updated_at, datetime.datetime(2012, 5, 22, 18, 3, 17))
self.assertEqual(self.authorization.url, "https://api.github.com/authorizations/372259")
def testEdit(self):
self.authorization.edit()
self.assertEqual(self.authorization.scopes, [])
self.authorization.edit(scopes=["user"])
self.assertEqual(self.authorization.scopes, ["user"])
self.authorization.edit(add_scopes=["repo"])
self.assertEqual(self.authorization.scopes, ["user", "repo"])
self.authorization.edit(remove_scopes=["repo"])
self.assertEqual(self.authorization.scopes, ["user"])
self.assertEqual(self.authorization.note, None)
self.assertEqual(self.authorization.note_url, None)
self.authorization.edit(note="Note created by PyGithub", note_url="http://vincent-jacques.net/PyGithub")
self.assertEqual(self.authorization.note, "Note created by PyGithub")
self.assertEqual(self.authorization.note_url, "http://vincent-jacques.net/PyGithub")
def testDelete(self):
self.authorization.delete()
+8 -7
View File
@@ -13,11 +13,12 @@
import Framework
class Branch( Framework.TestCase ):
def setUp( self ):
Framework.TestCase.setUp( self )
self.branch = self.g.get_user().get_repo( "PyGithub" ).get_branches()[ 0 ]
def testAttributes( self ):
self.assertEqual( self.branch.name, "topic/RewriteWithGeneratedCode" )
self.assertEqual( self.branch.commit.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a" )
class Branch(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.branch = self.g.get_user().get_repo("PyGithub").get_branches()[0]
def testAttributes(self):
self.assertEqual(self.branch.name, "topic/RewriteWithGeneratedCode")
self.assertEqual(self.branch.commit.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a")
+81
View File
@@ -0,0 +1,81 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
class Commit(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.commit = self.g.get_user().get_repo("PyGithub").get_commit("1292bf0e22c796e91cc3d6e24b544aece8c21f2a")
self.commit.author.login # to force lazy completion
def testAttributes(self):
self.assertEqual(self.commit.author.login, "jacquev6")
self.assertEqual(self.commit.commit.url, "https://api.github.com/repos/jacquev6/PyGithub/git/commits/1292bf0e22c796e91cc3d6e24b544aece8c21f2a")
self.assertEqual(self.commit.committer.login, "jacquev6")
self.assertEqual(len(self.commit.files), 1)
self.assertEqual(self.commit.files[0].additions, 0)
self.assertEqual(self.commit.files[0].blob_url, "https://github.com/jacquev6/PyGithub/blob/1292bf0e22c796e91cc3d6e24b544aece8c21f2a/github/GithubObjects/GitAuthor.py")
self.assertEqual(self.commit.files[0].changes, 20)
self.assertEqual(self.commit.files[0].deletions, 20)
self.assertEqual(self.commit.files[0].filename, "github/GithubObjects/GitAuthor.py")
self.assertTrue(isinstance(self.commit.files[0].patch, (str, unicode)))
self.assertEqual(self.commit.files[0].raw_url, "https://github.com/jacquev6/PyGithub/raw/1292bf0e22c796e91cc3d6e24b544aece8c21f2a/github/GithubObjects/GitAuthor.py")
self.assertEqual(self.commit.files[0].sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a")
self.assertEqual(self.commit.files[0].status, "modified")
self.assertEqual(len(self.commit.parents), 1)
self.assertEqual(self.commit.parents[0].sha, "b46ed0dfde5ad02d3b91eb54a41c5ed960710eae")
self.assertEqual(self.commit.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a")
self.assertEqual(self.commit.stats.deletions, 20)
self.assertEqual(self.commit.stats.additions, 0)
self.assertEqual(self.commit.stats.total, 20)
self.assertEqual(self.commit.url, "https://api.github.com/repos/jacquev6/PyGithub/commits/1292bf0e22c796e91cc3d6e24b544aece8c21f2a")
def testGetComments(self):
self.assertListKeyEqual(self.commit.get_comments(), lambda c: c.id, [1347033, 1347083, 1347397, 1349654])
def testCreateComment(self):
comment = self.commit.create_comment("Comment created by PyGithub")
self.assertEqual(comment.id, 1361949)
self.assertEqual(comment.line, None)
self.assertEqual(comment.path, None)
self.assertEqual(comment.position, None)
def testCreateCommentOnFileLine(self):
comment = self.commit.create_comment("Comment created by PyGithub", path="codegen/templates/GithubObject.MethodBody.UseResult.py", line=26)
self.assertEqual(comment.id, 1362000)
self.assertEqual(comment.line, 26)
self.assertEqual(comment.path, "codegen/templates/GithubObject.MethodBody.UseResult.py")
self.assertEqual(comment.position, None)
def testCreateCommentOnFilePosition(self):
comment = self.commit.create_comment("Comment also created by PyGithub", path="codegen/templates/GithubObject.MethodBody.UseResult.py", position=3)
self.assertEqual(comment.id, 1362001)
self.assertEqual(comment.line, None)
self.assertEqual(comment.path, "codegen/templates/GithubObject.MethodBody.UseResult.py")
self.assertEqual(comment.position, 3)
def testCreateStatusWithoutOptionalParameters(self):
status = self.commit.create_status("pending")
self.assertEqual(status.id, 277031)
self.assertEqual(status.state, "pending")
self.assertEqual(status.target_url, None)
self.assertEqual(status.description, None)
def testCreateStatusWithAllParameters(self):
status = self.commit.create_status("success", "https://github.com/jacquev6/PyGithub/issues/67", "Status successfuly created by PyGithub")
self.assertEqual(status.id, 277040)
self.assertEqual(status.state, "success")
self.assertEqual(status.target_url, "https://github.com/jacquev6/PyGithub/issues/67")
self.assertEqual(status.description, "Status successfuly created by PyGithub")
+41
View File
@@ -0,0 +1,41 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import datetime
class CommitComment(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.comment = self.g.get_user().get_repo("PyGithub").get_comment(1361949)
def testAttributes(self):
self.assertEqual(self.comment.body, "Comment created by PyGithub")
self.assertEqual(self.comment.commit_id, "6945921c529be14c3a8f566dd1e483674516d46d")
self.assertEqual(self.comment.created_at, datetime.datetime(2012, 5, 22, 18, 40, 18))
self.assertEqual(self.comment.html_url, "https://github.com/jacquev6/PyGithub/commit/6945921c529be14c3a8f566dd1e483674516d46d#commitcomment-1361949")
self.assertEqual(self.comment.id, 1361949)
self.assertEqual(self.comment.line, None)
self.assertEqual(self.comment.path, None)
self.assertEqual(self.comment.position, None)
self.assertEqual(self.comment.updated_at, datetime.datetime(2012, 5, 22, 18, 40, 18))
self.assertEqual(self.comment.url, "https://api.github.com/repos/jacquev6/PyGithub/comments/1361949")
self.assertEqual(self.comment.user.login, "jacquev6")
def testEdit(self):
self.comment.edit("Comment edited by PyGithub")
def testDelete(self):
self.comment.delete()
+35
View File
@@ -0,0 +1,35 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import github
import datetime
class CommitStatus(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.statuses = list(self.g.get_user().get_repo("PyGithub").get_commit("1292bf0e22c796e91cc3d6e24b544aece8c21f2a").get_statuses())
def testAttributes(self):
self.assertEqual(self.statuses[0].created_at, datetime.datetime(2012, 9, 8, 11, 30, 56))
self.assertEqual(self.statuses[0].updated_at, datetime.datetime(2012, 9, 8, 11, 30, 56))
self.assertEqual(self.statuses[0].creator.login, "jacquev6")
self.assertEqual(self.statuses[0].description, "Status successfuly created by PyGithub")
self.assertEqual(self.statuses[1].description, None)
self.assertEqual(self.statuses[0].id, 277040)
self.assertEqual(self.statuses[0].state, "success")
self.assertEqual(self.statuses[1].state, "pending")
self.assertEqual(self.statuses[0].target_url, "https://github.com/jacquev6/PyGithub/issues/67")
self.assertEqual(self.statuses[1].target_url, None)
@@ -1,33 +1,34 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import base64
import Framework
import github
import datetime
class ContentFile( Framework.TestCase ):
def setUp( self ):
Framework.TestCase.setUp( self )
self.file = self.g.get_user().get_repo( "PyGithub" ).get_readme()
def testAttributes( self ):
self.assertEqual( self.file.type, "file" )
self.assertEqual( self.file.encoding, "base64" )
self.assertEqual( self.file.size, 7531 )
self.assertEqual( self.file.name, "ReadMe.md" )
self.assertEqual( self.file.path, "ReadMe.md" )
self.assertEqual( len( base64.b64decode( self.file.content ) ), 7531 )
self.assertEqual( self.file.sha, "5628799a7d517a4aaa0c1a7004d07569cd154df0" )
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import base64
import Framework
import github
import datetime
class ContentFile(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.file = self.g.get_user().get_repo("PyGithub").get_readme()
def testAttributes(self):
self.assertEqual(self.file.type, "file")
self.assertEqual(self.file.encoding, "base64")
self.assertEqual(self.file.size, 7531)
self.assertEqual(self.file.name, "ReadMe.md")
self.assertEqual(self.file.path, "ReadMe.md")
self.assertEqual(len(base64.b64decode(self.file.content)), 7531)
self.assertEqual(self.file.sha, "5628799a7d517a4aaa0c1a7004d07569cd154df0")
+47
View File
@@ -0,0 +1,47 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import datetime
class Download(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.download = self.g.get_user().get_repo("PyGithub").get_download(242550)
def testAttributes(self):
self.assertEqual(self.download.accesskeyid, None)
self.assertEqual(self.download.acl, None)
self.assertEqual(self.download.bucket, None)
self.assertEqual(self.download.content_type, "text/plain")
self.assertEqual(self.download.created_at, datetime.datetime(2012, 5, 22, 18, 58, 32))
self.assertEqual(self.download.description, None)
self.assertEqual(self.download.download_count, 0)
self.assertEqual(self.download.expirationdate, None)
self.assertEqual(self.download.html_url, "https://github.com/downloads/jacquev6/PyGithub/Foobar.txt")
self.assertEqual(self.download.id, 242550)
self.assertEqual(self.download.mime_type, None)
self.assertEqual(self.download.name, "Foobar.txt")
self.assertEqual(self.download.path, None)
self.assertEqual(self.download.policy, None)
self.assertEqual(self.download.prefix, None)
self.assertEqual(self.download.redirect, None)
self.assertEqual(self.download.s3_url, None)
self.assertEqual(self.download.signature, None)
self.assertEqual(self.download.size, 1024)
self.assertEqual(self.download.url, "https://api.github.com/repos/jacquev6/PyGithub/downloads/242550")
def testDelete(self):
self.download.delete()
+37
View File
@@ -0,0 +1,37 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import github
import Framework
# Replay data for this test case is forged, because I don't have access to a real Github Enterprise install
class Enterprise(Framework.BasicTestCase):
def testHttps(self):
g = github.Github(self.login, self.password, base_url="https://my.enterprise.com")
self.assertListKeyEqual(g.get_user().get_repos(), lambda r: r.name, ["TestPyGithub", "django", "PyGithub", "developer.github.com", "acme-public-website", "C4Planner", "Hacking", "vincent-jacques.net", "Contests", "Candidates", "Tests", "DrawTurksHead", "DrawSyntax", "QuadProgMm", "Boost.HierarchicalEnum", "ViDE"])
def testHttp(self):
g = github.Github(self.login, self.password, base_url="http://my.enterprise.com")
self.assertListKeyEqual(g.get_user().get_repos(), lambda r: r.name, ["TestPyGithub", "django", "PyGithub", "developer.github.com", "acme-public-website", "C4Planner", "Hacking", "vincent-jacques.net", "Contests", "Candidates", "Tests", "DrawTurksHead", "DrawSyntax", "QuadProgMm", "Boost.HierarchicalEnum", "ViDE"])
def testLongUrl(self):
g = github.Github(self.login, self.password, base_url="http://my.enterprise.com/path/to/github")
repos = g.get_user().get_repos()
self.assertListKeyEqual(repos, lambda r: r.name, ["TestPyGithub", "django", "PyGithub", "developer.github.com", "acme-public-website", "C4Planner", "Hacking", "vincent-jacques.net", "Contests", "Candidates", "Tests", "DrawTurksHead", "DrawSyntax", "QuadProgMm", "Boost.HierarchicalEnum", "ViDE"])
self.assertEqual(repos[0].owner.name, "Vincent Jacques")
def testSpecificPort(self):
g = github.Github(self.login, self.password, base_url="http://my.enterprise.com:8080")
self.assertListKeyEqual(g.get_user().get_repos(), lambda r: r.name, ["TestPyGithub", "django", "PyGithub", "developer.github.com", "acme-public-website", "C4Planner", "Hacking", "vincent-jacques.net", "Contests", "Candidates", "Tests", "DrawTurksHead", "DrawSyntax", "QuadProgMm", "Boost.HierarchicalEnum", "ViDE"])
+32
View File
@@ -0,0 +1,32 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import datetime
class Event(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.event = self.g.get_user("jacquev6").get_events()[0]
def testAttributes(self):
self.assertEqual(self.event.actor.login, "jacquev6")
self.assertEqual(self.event.created_at, datetime.datetime(2012, 5, 26, 10, 1, 39))
self.assertEqual(self.event.id, "1556114751")
self.assertEqual(self.event.org, None)
self.assertEqual(self.event.payload, {u'commits': [{u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/5bb654d26dd014d36794acd1e6ecf3736f12aad7', u'sha': u'5bb654d26dd014d36794acd1e6ecf3736f12aad7', u'message': u'Implement the three authentication schemes', u'distinct': False, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/cb0313157bf904f2d364377d35d9397b269547a5', u'sha': u'cb0313157bf904f2d364377d35d9397b269547a5', u'message': u"Merge branch 'topic/Authentication' into develop", u'distinct': False, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/0cec0d25e606c023a62a4fc7cdc815309ebf6d16', u'sha': u'0cec0d25e606c023a62a4fc7cdc815309ebf6d16', u'message': u'Publish version 0.7', u'distinct': False, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/ecda065e01876209d2bdf5fe4e91cee8ffaa9ff7', u'sha': u'ecda065e01876209d2bdf5fe4e91cee8ffaa9ff7', u'message': u"Merge branch 'develop'", u'distinct': False, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/3a3bf4763192ee1234eb0557628133e06f3dfc76', u'sha': u'3a3bf4763192ee1234eb0557628133e06f3dfc76', u'message': u"Merge branch 'master' into topic/RewriteWithGeneratedCode\n\nConflicts:\n\tgithub/Github.py\n\tgithub/Requester.py", u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/608f17794664f61693a3dc05e6056fea8fbef0ff', u'sha': u'608f17794664f61693a3dc05e6056fea8fbef0ff', u'message': u'Restore some form of Authorization header in replay data', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/2c04b8adbd91d38eef4f0767337ab7a12b2f684b', u'sha': u'2c04b8adbd91d38eef4f0767337ab7a12b2f684b', u'message': u'Allow test without pre-set-up Github', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/5b97389988b6fe43e15a079702f6f1671257fb28', u'sha': u'5b97389988b6fe43e15a079702f6f1671257fb28', u'message': u'Test three authentication schemes', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/12747613c5ec00deccf296b8619ad507f7050475', u'sha': u'12747613c5ec00deccf296b8619ad507f7050475', u'message': u'Test Issue.getComments', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/2982fa96c5ca75abe717d974d83f9135d664232e', u'sha': u'2982fa96c5ca75abe717d974d83f9135d664232e', u'message': u'Test the new Repository.full_name attribute', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/619eae8d51c5988f0d2889fc767fa677438ba95d', u'sha': u'619eae8d51c5988f0d2889fc767fa677438ba95d', u'message': u'Improve coverage of AuthenticatedUser', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}], u'head': u'619eae8d51c5988f0d2889fc767fa677438ba95d', u'push_id': 80673538, u'ref': u'refs/heads/topic/RewriteWithGeneratedCode', u'size': 11})
self.assertEqual(self.event.public, True)
self.assertEqual(self.event.repo.name, "jacquev6/PyGithub")
self.assertEqual(self.event.type, "PushEvent")
+82
View File
@@ -0,0 +1,82 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import github
import sys
import Framework
atLeastPython26 = sys.hexversion >= 0x02060000
class Exceptions(Framework.TestCase): # To stay compatible with Python 2.6, we do not use self.assertRaises with only one argument
def testInvalidInput(self):
try:
self.g.get_user().create_key("Bad key", "xxx")
self.fail("Should have raised")
except github.GithubException, exception:
self.assertEqual(exception.status, 422)
self.assertEqual(
exception.data,
{
"errors": [
{
"code": "custom",
"field": "key",
"message": "key is invalid. It must begin with 'ssh-rsa' or 'ssh-dss'. Check that you're copying the public half of the key",
"resource": "PublicKey"
}
],
"message": "Validation Failed"
}
)
if atLeastPython26:
self.assertEqual(str(exception), "422 {u\'message\': u\'Validation Failed\', u\'errors\': [{u\'field\': u\'key\', u\'message\': u\"key is invalid. It must begin with \'ssh-rsa\' or \'ssh-dss\'. Check that you\'re copying the public half of the key\", u\'code\': u\'custom\', u\'resource\': u\'PublicKey\'}]}")
else:
self.assertEqual(str(exception), "422 {\'message\': \'Validation Failed\', \'errors\': [{\'field\': \'key\', \'message\': \"key is invalid. It must begin with \'ssh-rsa\' or \'ssh-dss\'. Check that you\'re copying the public half of the key\", \'code\': \'custom\', \'resource\': \'PublicKey\'}]}")
def testUnknownObject(self):
try:
self.g.get_user().get_repo("Xxx")
self.fail("Should have raised")
except github.GithubException, exception:
self.assertEqual(exception.status, 404)
self.assertEqual(exception.data, {"message": "Not Found"})
if atLeastPython26:
self.assertEqual(str(exception), "404 {u'message': u'Not Found'}")
else:
self.assertEqual(str(exception), "404 {'message': 'Not Found'}")
def testUnknownUser(self):
try:
self.g.get_user("ThisUserShouldReallyNotExist")
self.fail("Should have raised")
except github.GithubException, exception:
self.assertEqual(exception.status, 404)
self.assertEqual(exception.data, {"message": "Not Found"})
if atLeastPython26:
self.assertEqual(str(exception), "404 {u'message': u'Not Found'}")
else:
self.assertEqual(str(exception), "404 {'message': 'Not Found'}")
def testBadAuthentication(self):
try:
github.Github("BadUser", "BadPassword").get_user().login
self.fail("Should have raised")
except github.GithubException, exception:
self.assertEqual(exception.status, 401)
self.assertEqual(exception.data, {"message": "Bad credentials"})
if atLeastPython26:
self.assertEqual(str(exception), "401 {u'message': u'Bad credentials'}")
else:
self.assertEqual(str(exception), "401 {'message': 'Bad credentials'}")
+188
View File
@@ -0,0 +1,188 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
import unittest
import httplib
import traceback
import github
class FakeHttpResponse:
def __init__(self, status, headers, output):
self.status = status
self.__headers = headers
self.__output = output
def getheaders(self):
return self.__headers
def read(self):
return self.__output
def fixAuthorizationHeader(headers):
if "Authorization" in headers:
if headers["Authorization"].startswith("token "):
headers["Authorization"] = "token private_token_removed"
elif headers["Authorization"].startswith("Basic "):
headers["Authorization"] = "Basic login_and_password_removed"
else:
assert False
class RecordingConnection:
def __init__(self, file, protocol, host, port, *args, **kwds):
self.__file = file
self.__protocol = protocol
self.__host = host
self.__port = str(port)
self.__cnx = self._realConnection(host, port, *args, **kwds)
def request(self, verb, url, input, headers):
print verb, url, input, headers,
self.__cnx.request(verb, url, input, headers)
fixAuthorizationHeader(headers)
self.__file.write(self.__protocol + " " + verb + " " + self.__host + " " + self.__port + " " + url + " " + str(headers) + " " + input + "\n")
def getresponse(self):
res = self.__cnx.getresponse()
status = res.status
print "=>", status
headers = res.getheaders()
output = res.read()
self.__file.write(str(status) + "\n")
self.__file.write(str(headers) + "\n")
self.__file.write(str(output) + "\n")
return FakeHttpResponse(status, headers, output)
def close(self):
self.__file.write("\n")
return self.__cnx.close()
class RecordingHttpConnection(RecordingConnection):
_realConnection = httplib.HTTPConnection
def __init__(self, file, *args, **kwds):
RecordingConnection.__init__(self, file, "http", *args, **kwds)
class RecordingHttpsConnection(RecordingConnection):
_realConnection = httplib.HTTPSConnection
def __init__(self, file, *args, **kwds):
print args, kwds
RecordingConnection.__init__(self, file, "https", *args, **kwds)
class ReplayingConnection:
def __init__(self, testCase, file, protocol, host, port, *args, **kwds):
self.__testCase = testCase
self.__file = file
self.__protocol = protocol
self.__host = host
self.__port = str(port)
def request(self, verb, url, input, headers):
fixAuthorizationHeader(headers)
expectation = self.__file.readline().strip()
self.__testCase.assertEqual(self.__protocol + " " + verb + " " + self.__host + " " + self.__port + " " + url + " " + str(headers) + " " + input, expectation)
def getresponse(self):
status = int(self.__file.readline().strip())
headers = eval(self.__file.readline().strip())
output = self.__file.readline().strip()
return FakeHttpResponse(status, headers, output)
def close(self):
self.__file.readline()
def ReplayingHttpConnection(testCase, file, *args, **kwds):
return ReplayingConnection(testCase, file, "http", *args, **kwds)
def ReplayingHttpsConnection(testCase, file, *args, **kwds):
return ReplayingConnection(testCase, file, "https", *args, **kwds)
class BasicTestCase(unittest.TestCase):
recordMode = False
def setUp(self):
unittest.TestCase.setUp(self)
self.__fileName = ""
self.__file = None
if self.recordMode:
github.Requester.Requester.injectConnectionClasses(
lambda ignored, *args, **kwds: RecordingHttpConnection(self.__openFile("wb"), *args, **kwds),
lambda ignored, *args, **kwds: RecordingHttpsConnection(self.__openFile("wb"), *args, **kwds)
)
import GithubCredentials
self.login = GithubCredentials.login
self.password = GithubCredentials.password
self.oauth_token = GithubCredentials.oauth_token
else:
github.Requester.Requester.injectConnectionClasses(
lambda ignored, *args, **kwds: ReplayingHttpConnection(self, self.__openFile("r"), *args, **kwds),
lambda ignored, *args, **kwds: ReplayingHttpsConnection(self, self.__openFile("r"), *args, **kwds)
)
self.login = "login"
self.password = "password"
self.oauth_token = "oauth_token"
def tearDown(self):
unittest.TestCase.tearDown(self)
self.__closeReplayFileIfNeeded()
def __openFile(self, mode):
for (_, _, functionName, _) in traceback.extract_stack():
if functionName.startswith("test") or functionName == "setUp" or functionName == "tearDown":
if functionName != "test": # because in class Hook(Framework.TestCase), method testTest calls Hook.test
fileName = os.path.join(os.path.dirname(__file__), "ReplayData", self.__class__.__name__ + "." + functionName + ".txt")
if fileName != self.__fileName:
self.__closeReplayFileIfNeeded()
self.__fileName = fileName
self.__file = open(self.__fileName, mode)
return self.__file
def __closeReplayFileIfNeeded(self):
if self.__file is not None:
if not self.recordMode:
self.assertEqual(self.__file.readline(), "")
self.__file.close()
def assertListKeyEqual(self, elements, key, expectedKeys):
realKeys = [key(element) for element in elements]
self.assertEqual(realKeys, expectedKeys)
def assertListKeyBegin(self, elements, key, expectedKeys):
realKeys = [key(element) for element in elements[: len(expectedKeys)]]
self.assertEqual(realKeys, expectedKeys)
class TestCase(BasicTestCase):
def setUp(self):
BasicTestCase.setUp(self)
self.g = github.Github(self.login, self.password)
def activateRecordMode():
BasicTestCase.recordMode = True
+87
View File
@@ -0,0 +1,87 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import github
import datetime
class Gist(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.gist = self.g.get_gist("2729810")
def testAttributes(self):
self.assertEquals(self.gist.comments, 0)
self.assertEquals(self.gist.created_at, datetime.datetime(2012, 2, 29, 16, 47, 12))
self.assertEquals(self.gist.description, "How to error 500 Github API v3, as requested by Rick (GitHub Staff)")
self.assertEquals(self.gist.files.keys(), ["fail_github.py"])
self.assertEquals(self.gist.files["fail_github.py"].size, 1636)
self.assertEquals(self.gist.files["fail_github.py"].filename, "fail_github.py")
self.assertEquals(self.gist.files["fail_github.py"].language, "Python")
self.assertEquals(self.gist.files["fail_github.py"].content, 'import httplib\nimport base64\nimport json\n\nlogin = ""\npassword = ""\norgName = ""\nrepoName = "FailGithubApi"\n\ndef doRequest( verb, url, input ):\n input = json.dumps( input )\n cnx = httplib.HTTPSConnection( "api.github.com", strict = True )\n cnx.request( verb, url, input, { "Authorization" : "Basic " + base64.b64encode( login + ":" + password ).replace( \'\\n\', \'\' ) } )\n response = cnx.getresponse()\n status = response.status\n output = response.read()\n cnx.close()\n print verb, url, input, "=>", status, output\n print\n if status < 200 or status >= 300:\n exit( 1 )\n return json.loads( output )\n\n# Create a repo\ndoRequest( "POST", "/user/repos", { "name": repoName } )\n\n# Create a blob, a tree, a commit and the master branch\nb = doRequest(\n "POST", "/repos/%s/%s/git/blobs" % ( login, repoName ),\n { "content": "Content of the blob", "encoding": "latin1" }\n)\nt = doRequest(\n "POST", "/repos/%s/%s/git/trees" % ( login, repoName ),\n { "tree" : [ { "path": "foo.bar", "type": "blob", "mode": "100644", "sha": b["sha"] } ] }\n)\nc = doRequest(\n "POST", "/repos/%s/%s/git/commits" % ( login, repoName ),\n { "parents": [], "message": "Message of the commit", "tree": t["sha"] }\n)\ndoRequest(\n "POST", "/repos/%s/%s/git/refs" % ( login, repoName ),\n { "ref": "refs/heads/master", "sha": c["sha"] }\n)\n\n# Fork the repo\ndoRequest( "POST", "/repos/%s/%s/forks?org=%s" % ( login, repoName, orgName ), None )\n\n# Create a new blob => BOOM error 500\ndoRequest(\n "POST", "/repos/%s/%s/git/blobs" % ( orgName, repoName ),\n { "content": "Content of the new blob", "encoding": "latin1" }\n)\n')
self.assertEquals(self.gist.files["fail_github.py"].raw_url, "https://gist.github.com/raw/2729810/2fb3aa84e0efa50dc0f4c18b5df5b7b9ab27076b/fail_github.py")
self.assertEquals(self.gist.forks, [])
self.assertEquals(self.gist.git_pull_url, "git://gist.github.com/2729810.git")
self.assertEquals(self.gist.git_push_url, "git@gist.github.com:2729810.git")
self.assertEquals(len(self.gist.history), 1)
self.assertEquals(self.gist.history[0].change_status.additions, 52)
self.assertEquals(self.gist.history[0].change_status.deletions, 0)
self.assertEquals(self.gist.history[0].change_status.total, 52)
self.assertEquals(self.gist.history[0].committed_at, datetime.datetime(2012, 2, 29, 16, 47, 12))
self.assertEquals(self.gist.history[0].url, "https://api.github.com/gists/2729810/a40de483e42ba33bda308371c0ef8383db73be9e")
self.assertEquals(self.gist.history[0].user.login, "jacquev6")
self.assertEquals(self.gist.history[0].version, "a40de483e42ba33bda308371c0ef8383db73be9e")
self.assertEquals(self.gist.html_url, "https://gist.github.com/2729810")
self.assertEquals(self.gist.id, "2729810")
self.assertEquals(self.gist.public, True)
self.assertEquals(self.gist.updated_at, datetime.datetime(2012, 2, 29, 16, 47, 12))
self.assertEquals(self.gist.url, "https://api.github.com/gists/2729810")
self.assertEquals(self.gist.user.login, "jacquev6")
def testEditWithoutParameters(self):
self.gist.edit()
self.assertEquals(self.gist.description, "Gist created by PyGithub")
self.assertEquals(self.gist.updated_at, datetime.datetime(2012, 5, 19, 7, 0, 58))
def testEditWithAllParameters(self):
self.gist.edit("Description edited by PyGithub", {"barbaz.txt": github.InputFileContent("File also created by PyGithub")})
self.assertEquals(self.gist.description, "Description edited by PyGithub")
self.assertEquals(self.gist.updated_at, datetime.datetime(2012, 5, 19, 7, 6, 10))
self.assertEquals(self.gist.files.keys(), ["foobar.txt", "barbaz.txt"])
def testCreateComment(self):
comment = self.gist.create_comment("Comment created by PyGithub")
self.assertEquals(comment.id, 323629)
def testGetComments(self):
self.assertListKeyEqual(self.gist.get_comments(), lambda c: c.id, [323637])
def testStarring(self):
self.assertFalse(self.gist.is_starred())
self.gist.set_starred()
self.assertTrue(self.gist.is_starred())
self.gist.reset_starred()
self.assertFalse(self.gist.is_starred())
def testFork(self):
gist = self.g.get_gist("2729818") # Random gist
myGist = gist.create_fork()
self.assertEquals(myGist.id, "2729865")
self.assertEquals(myGist.fork_of, None) # WTF
sameGist = self.g.get_gist("2729865")
self.assertEquals(sameGist.fork_of.id, "2729818")
def testDelete(self):
self.gist.delete()
+38
View File
@@ -0,0 +1,38 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import datetime
class GistComment(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.comment = self.g.get_gist("2729810").get_comment(323629)
def testAttributes(self):
self.assertEquals(self.comment.body, "Comment created by PyGithub")
self.assertEquals(self.comment.created_at, datetime.datetime(2012, 5, 19, 7, 7, 57))
self.assertEquals(self.comment.id, 323629)
self.assertEquals(self.comment.updated_at, datetime.datetime(2012, 5, 19, 7, 7, 57))
self.assertEquals(self.comment.url, "https://api.github.com/gists/comments/323629")
self.assertEquals(self.comment.user.login, "jacquev6")
def testEdit(self):
self.comment.edit("Comment edited by PyGithub")
self.assertEquals(self.comment.body, "Comment edited by PyGithub")
self.assertEquals(self.comment.updated_at, datetime.datetime(2012, 5, 19, 7, 12, 32))
def testDelete(self):
self.comment.delete()
+29
View File
@@ -0,0 +1,29 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
class GitBlob(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.blob = self.g.get_user().get_repo("PyGithub").get_git_blob("53bce9fa919b4544e67275089b3ec5b44be20667")
def testAttributes(self):
self.assertTrue(self.blob.content.startswith("IyEvdXNyL2Jpbi9lbnYgcHl0aG9uCgpmcm9tIGRpc3R1dGlscy5jb3JlIGlt\ncG9ydCBzZXR1cAppbXBvcnQgdGV4dHdyYXAKCnNldHVwKAogICAgbmFtZSA9\n"))
self.assertTrue(self.blob.content.endswith("Z3JhbW1pbmcgTGFuZ3VhZ2UgOjogUHl0aG9uIiwKICAgICAgICAiVG9waWMg\nOjogU29mdHdhcmUgRGV2ZWxvcG1lbnQiLAogICAgXSwKKQo=\n"))
self.assertEqual(len(self.blob.content), 1757)
self.assertEqual(self.blob.encoding, "base64")
self.assertEqual(self.blob.size, 1295)
self.assertEqual(self.blob.sha, "53bce9fa919b4544e67275089b3ec5b44be20667")
self.assertEqual(self.blob.url, "https://api.github.com/repos/jacquev6/PyGithub/git/blobs/53bce9fa919b4544e67275089b3ec5b44be20667")
+37
View File
@@ -0,0 +1,37 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import datetime
import Framework
class GitCommit(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.commit = self.g.get_user().get_repo("PyGithub").get_git_commit("4303c5b90e2216d927155e9609436ccb8984c495")
def testAttributes(self):
self.assertEqual(self.commit.author.name, "Vincent Jacques")
self.assertEqual(self.commit.author.email, "vincent@vincent-jacques.net")
self.assertEqual(self.commit.author.date, datetime.datetime(2012, 4, 17, 17, 55, 16))
self.assertEqual(self.commit.committer.name, "Vincent Jacques")
self.assertEqual(self.commit.committer.email, "vincent@vincent-jacques.net")
self.assertEqual(self.commit.committer.date, datetime.datetime(2012, 4, 17, 17, 55, 16))
self.assertEqual(self.commit.message, "Merge branch 'develop'\n")
self.assertEqual(len(self.commit.parents), 2)
self.assertEqual(self.commit.parents[0].sha, "936f4a97f1a86392637ec002bbf89ff036a5062d")
self.assertEqual(self.commit.parents[1].sha, "2a7e80e6421c5d4d201d60619068dea6bae612cb")
self.assertEqual(self.commit.sha, "4303c5b90e2216d927155e9609436ccb8984c495")
self.assertEqual(self.commit.tree.sha, "f492784d8ca837779650d1fb406a1a3587a764ad")
self.assertEqual(self.commit.url, "https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495")
+36
View File
@@ -0,0 +1,36 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
class GitRef(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.ref = self.g.get_user().get_repo("PyGithub").get_git_ref("refs/heads/BranchCreatedByPyGithub")
def testAttributes(self):
self.assertEqual(self.ref.object.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a")
self.assertEqual(self.ref.object.type, "commit")
self.assertEqual(self.ref.object.url, "https://api.github.com/repos/jacquev6/PyGithub/git/commits/1292bf0e22c796e91cc3d6e24b544aece8c21f2a")
self.assertEqual(self.ref.ref, "refs/heads/BranchCreatedByPyGithub")
self.assertEqual(self.ref.url, "https://api.github.com/repos/jacquev6/PyGithub/git/refs/heads/BranchCreatedByPyGithub")
def testEdit(self):
self.ref.edit("04cde900a0775b51f762735637bd30de392a2793")
def testEditWithForce(self):
self.ref.edit("4303c5b90e2216d927155e9609436ccb8984c495", force=True)
def testDelete(self):
self.ref.delete()
+34
View File
@@ -0,0 +1,34 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import datetime
import Framework
class GitTag(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.tag = self.g.get_user().get_repo("PyGithub").get_git_tag("f5f37322407b02a80de4526ad88d5f188977bc3c")
def testAttributes(self):
self.assertEqual(self.tag.message, "Version 0.6\n")
self.assertEqual(self.tag.object.sha, "4303c5b90e2216d927155e9609436ccb8984c495")
self.assertEqual(self.tag.object.type, "commit")
self.assertEqual(self.tag.object.url, "https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495")
self.assertEqual(self.tag.sha, "f5f37322407b02a80de4526ad88d5f188977bc3c")
self.assertEqual(self.tag.tag, "v0.6")
self.assertEqual(self.tag.tagger.date, datetime.datetime(2012, 5, 10, 18, 14, 15))
self.assertEqual(self.tag.tagger.email, "vincent@vincent-jacques.net")
self.assertEqual(self.tag.tagger.name, "Vincent Jacques")
self.assertEqual(self.tag.url, "https://api.github.com/repos/jacquev6/PyGithub/git/tags/f5f37322407b02a80de4526ad88d5f188977bc3c")
+37
View File
@@ -0,0 +1,37 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
class GitTree(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.tree = self.g.get_user().get_repo("PyGithub").get_git_tree("f492784d8ca837779650d1fb406a1a3587a764ad")
def testAttributes(self):
self.assertEqual(self.tree.sha, "f492784d8ca837779650d1fb406a1a3587a764ad")
self.assertEqual(len(self.tree.tree), 11)
self.assertEqual(self.tree.tree[0].mode, "100644")
self.assertEqual(self.tree.tree[0].path, ".gitignore")
self.assertEqual(self.tree.tree[0].sha, "8a9af1462c3f4e3358315c2d2e6ef1e7334c59dd")
self.assertEqual(self.tree.tree[0].size, 53)
self.assertEqual(self.tree.tree[0].type, "blob")
self.assertEqual(self.tree.tree[0].url, "https://api.github.com/repos/jacquev6/PyGithub/git/blobs/8a9af1462c3f4e3358315c2d2e6ef1e7334c59dd")
self.assertEqual(self.tree.tree[6].mode, "040000")
self.assertEqual(self.tree.tree[6].path, "ReplayDataForIntegrationTest")
self.assertEqual(self.tree.tree[6].sha, "60b4602b2c2070246c5df078fb7a5150b45815eb")
self.assertEqual(self.tree.tree[6].size, None)
self.assertEqual(self.tree.tree[6].type, "tree")
self.assertEqual(self.tree.tree[6].url, "https://api.github.com/repos/jacquev6/PyGithub/git/trees/60b4602b2c2070246c5df078fb7a5150b45815eb")
self.assertEqual(self.tree.url, "https://api.github.com/repos/jacquev6/PyGithub/git/trees/f492784d8ca837779650d1fb406a1a3587a764ad")
+92
View File
@@ -0,0 +1,92 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import datetime
import Framework
class Github(Framework.TestCase):
def testGetGists(self):
self.assertListKeyBegin(self.g.get_gists(), lambda g: g.id, ["2729695", "2729656", "2729597", "2729584", "2729569", "2729554", "2729543", "2729537", "2729536", "2729533", "2729525", "2729522", "2729519", "2729515", "2729506", "2729487", "2729484", "2729482", "2729441", "2729432", "2729420", "2729398", "2729372", "2729371", "2729351", "2729346", "2729316", "2729304", "2729296", "2729276", "2729272", "2729265", "2729195", "2729160", "2729143", "2729127", "2729119", "2729113", "2729103", "2729069", "2729059", "2729051", "2729029", "2729027", "2729026", "2729022", "2729002", "2728985", "2728979", "2728964", "2728937", "2728933", "2728884", "2728869", "2728866", "2728855", "2728854", "2728853", "2728846", "2728825", "2728814", "2728813", "2728812", "2728805", "2728802", "2728800", "2728798", "2728797", "2728796", "2728793", "2728758", "2728754", "2728751", "2728748", "2728721", "2728716", "2728715", "2728705", "2728701", "2728699", "2728697", "2728688", "2728683", "2728677", "2728649", "2728640", "2728625", "2728620", "2728615", "2728614", "2728565", "2728564", "2728554", "2728523", "2728519", "2728511", "2728497", "2728496", "2728495", "2728487"])
def testLegacySearchRepos(self):
repos = self.g.legacy_search_repos("github api v3")
self.assertListKeyBegin(repos, lambda r: r.name, ["octokit", "github-v3-api", "github_v3_api"])
self.assertEqual(repos[0].full_name, "pengwynn/octokit")
# Attributes retrieved from legacy API without lazy completion call
self.assertEqual(repos[1].created_at, datetime.datetime(2011, 6, 23, 22, 52, 33))
self.assertEqual(repos[1].name, "github-v3-api")
self.assertEqual(repos[1].watchers, 35)
self.assertEqual(repos[1].has_downloads, True)
self.assertEqual(repos[3].homepage, "http://peter-murach.github.com/github")
self.assertEqual(repos[1].url, "/repos/jwilger/github-v3-api")
self.assertEqual(repos[1].fork, False)
self.assertEqual(repos[1].has_issues, True)
self.assertEqual(repos[1].has_wiki, False)
self.assertEqual(repos[1].forks, 13)
self.assertEqual(repos[1].size, 212)
self.assertEqual(repos[1].private, False)
self.assertEqual(repos[1].open_issues, 2)
self.assertEqual(repos[3].pushed_at, datetime.datetime(2012, 6, 28, 21, 26, 31))
self.assertEqual(repos[1].description, "Ruby Client for the GitHub v3 API")
self.assertEqual(repos[1].language, "Ruby")
self.assertEqual(repos[1].owner.login, "jwilger")
self.assertEqual(repos[1].owner.url, "/users/jwilger")
def testLegacySearchReposPagination(self):
repos = self.g.legacy_search_repos("document")
self.assertListKeyBegin(repos, lambda r: r.name, ["git", "nimbus", "kss", "sstoolkit", "lawnchair", "appledoc", "jQ.Mobi", "ipython", "mongoengine", "ravendb", "substance", "symfony-docs", "JavaScript-Garden", "DocSets-for-iOS", "yard", "phpDocumentor2", "phpsh", "Tangle", "Ingredients", "documentjs", "xhp", "couchdb-lucene", "dox", "magento2", "javascriptmvc", "FastPdfKit", "roar", "DocumentUp", "NoRM", "jsdoc", "tagger", "mongodb-csharp", "php-github-api", "beautiful-docs", "mongodb-odm", "iodocs", "seesaw", "bcx-api", "developer.github.com", "amqp", "docsplit", "pycco", "standards-and-practices", "tidy-html5", "redis-doc", "tomdoc", "docs", "flourish", "userguide", "swagger-ui", "rfc", "Weasel-Diesel", "yuidoc", "apigen", "document-viewer", "develop.github.com", "Shanty-Mongo", "PTShowcaseViewController", "gravatar_image_tag", "api-wow-docs", "mongoid-tree", "safari-json-formatter", "mayan", "orm-documentation", "jsfiddle-docs-alpha", "core", "documentcloud", "flexible-nav", "writeCapture", "readium", "xmldocument", "Documentation-Examples", "grails-doc", "stdeb", "aws-autoscaling", "voteable_mongo", "review", "spreadsheet_on_rails", "UKSyntaxColoredTextDocument", "mandango", "bdoc", "Documentation", "documents.com", "rghost", "ticket_mule", "vendo", "khan-api", "spring-data-document-examples", "rspec_api_documentation", "axlsx", "phpdox", "documentation", "Sami", "innershiv", "doxyclean", "documents", "rvm-site", "jqapi", "documentation", "hadoopy", "VichUploaderBundle", "pdoc", "documentation", "wii-js", "oss-docs", "scala-maven-plugin", "Documents", "documenter", "behemoth", "documentation", "documentation", "propelorm.github.com", "Kobold2D", "AutoObjectDocumentation", "php-mongodb-admin", "django-mongokit", "puppet-docs", "docs", "Document", "vendorer", "symfony1-docs", "shocco", "documentation", "jog", "docs", "documentation", "documentation", "documentation", "documentation", "Documentation", "documentation", "documentation", "phpunit-documentation", "ADCtheme", "NelmioApiDocBundle", "iCloud-Singleton-CloudMe", "Documentation", "document", "document_mapper", "heroku-docs", "couchdb-odm", "documentation", "documentation", "document", "documentation", "NanoStore", "documentation", "Documentation", "documentation", "Documentation", "documentation", "document", "documentation", "documentation", "Documentation", "Documentation", "grendel", "ceylon-compiler", "mbtiles-spec", "documentation", "documents", "documents", "Documents", "Documentation", "documentation", "Documentation", "documentation", "documents", "Documentation", "documentation", "documentation", "documents", "Documentation", "documentation", "documenter", "documentation", "documents", "Documents", "documents", "documents", "documentation", "Document", "document", "rdoc", "mongoid_token", "travis-ci.github.com", "Documents", "Documents", "documents", "Document", "Documentation", "documents", "Documents", "Documentation", "documents", "documents", "documents", "documentation", "Documents", "Document", "documents", "documents", "Documentation", "Documentation", "Document", "documents", "Documents", "Documents", "Documentation", "Documents", "documents", "Documents", "document", "documents", "Documentation", "Documents", "documents", "documents", "Documents", "documents", "Documentation", "documentation", "Document", "Documents", "documents", "documents", "documents", "Documentation", "Documentation", "Documents", "Documents", "Documents", "Documenter", "document", "Documentation", "Documents", "Documents", "documentation", "documentation", "Document", "Documents", "Documentation", "Documentation", "Documents", "documents", "Documents", "document", "documentation", "Documents", "documentation", "documentation", "documentation", "Documentation", "Documents", "Documents", "documentation", "Documents", "Documents", "documentation", "documentation", "documents", "Documentation", "documents", "documentation", "Documentation", "Documents", "documentation", "documentation", "documents", "documentation", "Umbraco5Docs", "documents", "Documents", "Documentation", "documents", "document", "documents", "document", "documents", "documentation", "Documents", "documents", "document", "Documents", "Documentation", "Documentation", "documentation", "Documentation", "document", "documentation", "documents", "documents", "Documentations", "document", "documentation", "Documentation", "Document", "Documents", "Documents", "Document"])
def testLegacySearchReposExplicitPagination(self):
repos = self.g.legacy_search_repos("python")
self.assertEqual([r.name for r in repos.get_page(4)], ["assetic", "cartodb", "cuisine", "gae-sessions", "geoalchemy2", "Multicorn", "wmfr-timeline", "redis-rdb-tools", "applet-workflows", "TweetBuff", "groovy-core", "StarTrekGame", "Nuevo", "Cupid", "node-sqlserver", "Magnet2Torrent", "GroundControl", "mock-django", "4bit", "mock-django", "Fabulous", "SFML", "pydicas", "flixel", "up", "mongrel2", "SimpleHTTPServerJs", "ultimos", "Archipel", "JSbooks", "nova", "nodebox", "simplehttp", "dablooms", "solarized", "landslide", "jQuery-File-Upload", "jQuery-File-Upload", "jQuery-File-Upload", "password-manager", "electrum", "twitter_nlp", "djangbone", "pyxfst", "node-gyp", "flare", "www.gittip.com", "wymeditor", "Kokobox", "MyCQ", "runwalk", "git-sweep", "HPCPythonSC2012", "sundown", "node2dm", "statirator", "fantastic-futures", "chainsaw", "itcursos-gerenciador-tarefas", "TideSDK", "genmaybot", "melpa", "ConnectedWire", "tarantool", "anserindicus_sn", "luvit", "Minecraft-Overviewer", "Iconic", "pyist.net", "wikibok", "mejorenvo-scraper", "NewsBlur", "SocketRocket", "spf13-vim", "IWantToWorkAtGloboCom", "ruby-style-guide", "aery32-refguide", "fafsite", "compsense_demo", "enaml", "mpi4py", "fi.pycon.org", "scikits-image", "scikits-image", "uni", "mako.vim", "mako.vim", "slumber", "de-composer", "nvm", "helloshopply", "Alianza", "vimfiles", "socorro-crashstats", "menu", "analytics", "elFinder", "riak_wiki", "livestreamer", "git-goggles"])
def testLegacySearchReposWithLanguage(self):
repos = self.g.legacy_search_repos("document", language="Python")
self.assertListKeyBegin(repos, lambda r: r.name, ["ipython", "mongoengine", "tagger"])
self.assertEqual(repos[0].full_name, "ipython/ipython")
def testLegacySearchUsers(self):
users = self.g.legacy_search_users("vincent")
self.assertListKeyBegin(users, lambda u: u.login, ["nvie", "obra", "lusis"])
# Attributes retrieved from legacy API without lazy completion call
self.assertEqual(users[0].gravatar_id, "c5a7f21b46df698f3db31c37ed0cf55a")
self.assertEqual(users[0].name, "Vincent Driessen")
self.assertEqual(users[0].created_at, datetime.datetime(2009, 5, 12, 21, 19, 38))
self.assertEqual(users[0].location, "Netherlands")
self.assertEqual(users[0].followers, 310)
self.assertEqual(users[0].public_repos, 63)
self.assertEqual(users[0].login, "nvie")
def testLegacySearchUsersPagination(self):
self.assertEqual(len(list(self.g.legacy_search_users("Lucy"))), 146)
def testLegacySearchUsersExplicitPagination(self):
users = self.g.legacy_search_users("Lucy")
self.assertEqual([u.login for u in users.get_page(1)], ["lucievh", "lucyim", "Lucief", "RevolverUpstairs", "seriousprogramming", "reicul", "davincidubai", "LucianaNascimentodoPrado", "lucia-huenchunao", "kraji20", "Lucywolo", "Luciel", "sunnysummer", "elush", "oprealuci", "Flika", "lsher", "datadrivenjournalism", "nill2020", "doobi", "lucilu", "deldeldel", "lucianacocca", "lucyli-sfdc", "lucysatchell", "UBM", "kolousek", "lucyzhang", "lmegia", "luisolivo", "Lucyzhen", "Luhzinha", "beautifly", "lucybm96", "BuonocoreL", "lucywilliams", "ZxOxZ", "Motwinb", "johnlucy", "Aquanimation", "alaltaieri", "lucylin", "lucychambers", "JuanSesma", "cdwwebware", "ZachWills"])
def testLegacySearchUserByEmail(self):
user = self.g.legacy_search_user_by_email("vincent@vincent-jacques.net")
self.assertEqual(user.login, "jacquev6")
self.assertEqual(user.followers, 13)
def testGetHooks(self):
hooks = self.g.get_hooks()
hook = hooks[0]
self.assertEqual(hook.name, "activecollab")
self.assertEqual(hook.supported_events, ["push"])
self.assertEqual(hook.events, ["push"])
self.assertEqual(hook.schema, [["string", "url"], ["string", "token"], ["string", "project_id"], ["string", "milestone_id"], ["string", "category_id"]])
+56
View File
@@ -0,0 +1,56 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import datetime
class Hook(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.hook = self.g.get_user().get_repo("PyGithub").get_hook(257993)
def testAttributes(self):
self.assertEqual(self.hook.active, True) # WTF
self.assertEqual(self.hook.config, {"url": "http://foobar.com"})
self.assertEqual(self.hook.created_at, datetime.datetime(2012, 5, 19, 6, 1, 45))
self.assertEqual(self.hook.events, ["push"])
self.assertEqual(self.hook.id, 257993)
self.assertEqual(self.hook.last_response.status, "ok")
self.assertEqual(self.hook.last_response.message, "OK")
self.assertEqual(self.hook.last_response.code, 200)
self.assertEqual(self.hook.name, "web")
self.assertEqual(self.hook.updated_at, datetime.datetime(2012, 5, 29, 18, 49, 47))
self.assertEqual(self.hook.url, "https://api.github.com/repos/jacquev6/PyGithub/hooks/257993")
def testEditWithMinimalParameters(self):
self.hook.edit("web", {"url": "http://foobar.com/hook"})
self.assertEqual(self.hook.config, {"url": "http://foobar.com/hook"})
self.assertEqual(self.hook.updated_at, datetime.datetime(2012, 5, 19, 5, 8, 16))
def testDelete(self):
self.hook.delete()
def testTest(self):
self.hook.test() # This does not update attributes of hook
def testEditWithAllParameters(self):
self.hook.edit("web", {"url": "http://foobar.com"}, events=["fork", "push"])
self.assertEqual(self.hook.events, ["fork", "push"])
self.hook.edit("web", {"url": "http://foobar.com"}, add_events=["push"])
self.assertEqual(self.hook.events, ["fork", "push"])
self.hook.edit("web", {"url": "http://foobar.com"}, remove_events=["fork"])
self.assertEqual(self.hook.events, ["push"])
self.hook.edit("web", {"url": "http://foobar.com"}, active=True)
self.assertEqual(self.hook.active, True)
@@ -15,6 +15,7 @@
import Framework
from AuthenticatedUser import *
from Authentication import *
from Authorization import *
+100
View File
@@ -0,0 +1,100 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import datetime
class Issue(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.repo = self.g.get_user().get_repo("PyGithub")
self.issue = self.repo.get_issue(28)
def testAttributes(self):
self.assertEqual(self.issue.assignee.login, "jacquev6")
self.assertEqual(self.issue.body, "Body edited by PyGithub")
self.assertEqual(self.issue.closed_at, datetime.datetime(2012, 5, 26, 14, 59, 33))
self.assertEqual(self.issue.closed_by.login, "jacquev6")
self.assertEqual(self.issue.comments, 0)
self.assertEqual(self.issue.created_at, datetime.datetime(2012, 5, 19, 10, 38, 23))
self.assertEqual(self.issue.html_url, "https://github.com/jacquev6/PyGithub/issues/28")
self.assertEqual(self.issue.id, 4653757)
self.assertListKeyEqual(self.issue.labels, lambda l: l.name, ["Bug", "Project management", "Question"])
self.assertEqual(self.issue.milestone.title, "Version 0.4")
self.assertEqual(self.issue.number, 28)
self.assertEqual(self.issue.pull_request.diff_url, None)
self.assertEqual(self.issue.pull_request.patch_url, None)
self.assertEqual(self.issue.pull_request.html_url, None)
self.assertEqual(self.issue.state, "closed")
self.assertEqual(self.issue.title, "Issue created by PyGithub")
self.assertEqual(self.issue.updated_at, datetime.datetime(2012, 5, 26, 14, 59, 33))
self.assertEqual(self.issue.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/28")
self.assertEqual(self.issue.user.login, "jacquev6")
def testEditWithoutParameters(self):
self.issue.edit()
def testEditWithAllParameters(self):
user = self.g.get_user("jacquev6")
milestone = self.repo.get_milestone(2)
self.issue.edit("Title edited by PyGithub", "Body edited by PyGithub", user, "open", milestone, ["Bug"])
self.assertEqual(self.issue.assignee.login, "jacquev6")
self.assertEqual(self.issue.body, "Body edited by PyGithub")
self.assertEqual(self.issue.state, "open")
self.assertEqual(self.issue.title, "Title edited by PyGithub")
self.assertListKeyEqual(self.issue.labels, lambda l: l.name, ["Bug"])
def testEditResetMilestone(self):
self.assertEqual(self.issue.milestone.title, "Version 0.4")
self.issue.edit(milestone=None)
self.assertEqual(self.issue.milestone, None)
def testEditResetAssignee(self):
self.assertEqual(self.issue.assignee.login, "jacquev6")
self.issue.edit(assignee=None)
self.assertEqual(self.issue.assignee, None)
def testCreateComment(self):
comment = self.issue.create_comment("Comment created by PyGithub")
self.assertEqual(comment.id, 5808311)
def testGetComments(self):
self.assertListKeyEqual(self.issue.get_comments(), lambda c: c.user.login, ["jacquev6", "roskakori"])
def testGetEvents(self):
self.assertListKeyEqual(self.issue.get_events(), lambda e: e.id, [15819975, 15820048])
def testGetLabels(self):
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Project management", "Question"])
def testAddAndRemoveLabels(self):
bug = self.repo.get_label("Bug")
question = self.repo.get_label("Question")
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Project management", "Question"])
self.issue.remove_from_labels(bug)
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Project management", "Question"])
self.issue.remove_from_labels(question)
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Project management"])
self.issue.add_to_labels(bug, question)
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Project management", "Question"])
def testDeleteAndSetLabels(self):
bug = self.repo.get_label("Bug")
question = self.repo.get_label("Question")
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Project management", "Question"])
self.issue.delete_labels()
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, [])
self.issue.set_labels(bug, question)
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Question"])
+9 -8
View File
@@ -13,13 +13,14 @@
import Framework
class Issue33( Framework.TestCase ): # https://github.com/jacquev6/PyGithub/issues/33
def setUp( self ):
Framework.TestCase.setUp( self )
self.repo = self.g.get_user( "openframeworks" ).get_repo( "openFrameworks" )
def testOpenIssues( self ):
self.assertEqual( len( list( self.repo.get_issues() ) ), 338 )
class Issue33(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issues/33
def setUp(self):
Framework.TestCase.setUp(self)
self.repo = self.g.get_user("openframeworks").get_repo("openFrameworks")
def testClosedIssues( self ):
self.assertEqual( len( list( self.repo.get_issues( state = "closed" ) ) ), 950 )
def testOpenIssues(self):
self.assertEqual(len(list(self.repo.get_issues())), 338)
def testClosedIssues(self):
self.assertEqual(len(list(self.repo.get_issues(state="closed"))), 950)
+58
View File
@@ -0,0 +1,58 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import github
import Framework
class Issue50(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issues/50
def setUp(self):
Framework.TestCase.setUp(self)
self.repo = self.g.get_user().get_repo("PyGithub")
self.issue = self.repo.get_issue(50)
self.labelName = "Label with spaces and strange characters (&*#$)"
def testCreateLabel(self):
label = self.repo.create_label(self.labelName, "ffff00")
self.assertEqual(label.name, self.labelName)
def testGetLabel(self):
label = self.repo.get_label(self.labelName)
self.assertEqual(label.name, self.labelName)
def testGetLabels(self):
self.assertListKeyEqual(self.repo.get_labels(), lambda l: l.name, ["Refactoring", "Public interface", "Functionalities", "Project management", "Bug", "Question", "RequestedByUser", self.labelName])
def testAddLabelToIssue(self):
self.issue.add_to_labels(self.repo.get_label(self.labelName))
def testRemoveLabelFromIssue(self):
self.issue.remove_from_labels(self.repo.get_label(self.labelName))
def testSetIssueLabels(self):
self.issue.set_labels(self.repo.get_label("Bug"), self.repo.get_label("RequestedByUser"), self.repo.get_label(self.labelName))
def testIssueLabels(self):
self.assertListKeyEqual(self.issue.labels, lambda l: l.name, ["Bug", self.labelName, "RequestedByUser"])
def testIssueGetLabels(self):
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", self.labelName, "RequestedByUser"])
def testGetIssuesWithLabel(self):
self.assertListKeyEqual(self.repo.get_issues(labels=[self.repo.get_label(self.labelName)]), lambda i: i.number, [52, 50])
def testCreateIssueWithLabel(self):
issue = self.repo.create_issue("Issue created by PyGithub to test issue #50", labels=[self.repo.get_label(self.labelName)])
self.assertListKeyEqual(issue.labels, lambda l: l.name, [self.labelName])
self.assertEqual(issue.number, 52)
+9 -8
View File
@@ -15,12 +15,13 @@ import datetime
import Framework
class Issue54( Framework.TestCase ):
def setUp( self ):
Framework.TestCase.setUp( self )
self.repo = self.g.get_user().get_repo( "TestRepo" )
def testConversion( self ):
commit = self.repo.get_git_commit( "73f320ae06cd565cf38faca34b6a482addfc721b" )
self.assertEqual( commit.message, "Test commit created around Fri, 13 Jul 2012 18:43:21 GMT, that is vendredi 13 juillet 2012 20:43:21 GMT+2\n" )
self.assertEqual( commit.author.date, datetime.datetime( 2012, 7, 13, 18, 47, 10 ) )
class Issue54(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.repo = self.g.get_user().get_repo("TestRepo")
def testConversion(self):
commit = self.repo.get_git_commit("73f320ae06cd565cf38faca34b6a482addfc721b")
self.assertEqual(commit.message, "Test commit created around Fri, 13 Jul 2012 18:43:21 GMT, that is vendredi 13 juillet 2012 20:43:21 GMT+2\n")
self.assertEqual(commit.author.date, datetime.datetime(2012, 7, 13, 18, 47, 10))
+30
View File
@@ -0,0 +1,30 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import github
import Framework
class Issue80(Framework.BasicTestCase): # https://github.com/jacquev6/PyGithub/issues/80
def testIgnoreHttpsFromGithubEnterprise(self):
g = github.Github(self.login, self.password, base_url="http://my.enterprise.com/some/prefix") # http here
org = g.get_organization("BeaverSoftware")
self.assertEqual(org.url, "https://my.enterprise.com/some/prefix/orgs/BeaverSoftware") # https returned
self.assertListKeyEqual(org.get_repos(), lambda r: r.name, ["FatherBeaver", "TestPyGithub"]) # But still http in second request based on org.url
def testIgnoreHttpsFromGithubEnterpriseWithPort(self):
g = github.Github(self.login, self.password, base_url="http://my.enterprise.com:1234/some/prefix") # http here
org = g.get_organization("BeaverSoftware")
self.assertEqual(org.url, "https://my.enterprise.com:1234/some/prefix/orgs/BeaverSoftware") # https returned
self.assertListKeyEqual(org.get_repos(), lambda r: r.name, ["FatherBeaver", "TestPyGithub"]) # But still http in second request based on org.url
+38
View File
@@ -0,0 +1,38 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import github
import Framework
class Issue87(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issues/87
def setUp(self):
Framework.TestCase.setUp(self)
self.repo = self.g.get_user().get_repo("PyGithub")
def testCreateIssueWithPercentInTitle(self):
issue = self.repo.create_issue("Issue with percent % in title created by PyGithub")
self.assertEqual(issue.number, 99)
def testCreateIssueWithPercentInBody(self):
issue = self.repo.create_issue("Issue created by PyGithub", "Percent % in body")
self.assertEqual(issue.number, 98)
def testCreateIssueWithEscapedPercentInTitle(self):
issue = self.repo.create_issue("Issue with escaped percent %25 in title created by PyGithub")
self.assertEqual(issue.number, 97)
def testCreateIssueWithEscapedPercentInBody(self):
issue = self.repo.create_issue("Issue created by PyGithub", "Escaped percent %25 in body")
self.assertEqual(issue.number, 96)
+38
View File
@@ -0,0 +1,38 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import datetime
class IssueComment(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.comment = self.g.get_user().get_repo("PyGithub").get_issue(28).get_comment(5808311)
def testAttributes(self):
self.assertEqual(self.comment.body, "Comment created by PyGithub")
self.assertEqual(self.comment.created_at, datetime.datetime(2012, 5, 20, 11, 46, 42))
self.assertEqual(self.comment.id, 5808311)
self.assertEqual(self.comment.updated_at, datetime.datetime(2012, 5, 20, 11, 46, 42))
self.assertEqual(self.comment.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/comments/5808311")
self.assertEqual(self.comment.user.login, "jacquev6")
def testEdit(self):
self.comment.edit("Comment edited by PyGithub")
self.assertEqual(self.comment.body, "Comment edited by PyGithub")
self.assertEqual(self.comment.updated_at, datetime.datetime(2012, 5, 20, 11, 53, 59))
def testDelete(self):
self.comment.delete()
@@ -15,16 +15,17 @@ import Framework
import datetime
class IssueEvent( Framework.TestCase ):
def setUp( self ):
Framework.TestCase.setUp( self )
self.event = self.g.get_user().get_repo( "PyGithub" ).get_issues_event( 16348656 )
def testAttributes( self ):
self.assertEqual( self.event.actor.login, "jacquev6" )
self.assertEqual( self.event.commit_id, "ed866fc43833802ab553e5ff8581c81bb00dd433" )
self.assertEqual( self.event.created_at, datetime.datetime( 2012, 5, 27, 7, 29, 25 ) )
self.assertEqual( self.event.event, "referenced" )
self.assertEqual( self.event.id, 16348656 )
self.assertEqual( self.event.issue.number, 30 )
self.assertEqual( self.event.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/events/16348656" )
class IssueEvent(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.event = self.g.get_user().get_repo("PyGithub").get_issues_event(16348656)
def testAttributes(self):
self.assertEqual(self.event.actor.login, "jacquev6")
self.assertEqual(self.event.commit_id, "ed866fc43833802ab553e5ff8581c81bb00dd433")
self.assertEqual(self.event.created_at, datetime.datetime(2012, 5, 27, 7, 29, 25))
self.assertEqual(self.event.event, "referenced")
self.assertEqual(self.event.id, 16348656)
self.assertEqual(self.event.issue.number, 30)
self.assertEqual(self.event.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/events/16348656")
+15 -14
View File
@@ -13,21 +13,22 @@
import Framework
class Label( Framework.TestCase ):
def setUp( self ):
Framework.TestCase.setUp( self )
self.label = self.g.get_user().get_repo( "PyGithub" ).get_label( "Bug" )
def testAttributes( self ):
self.assertEqual( self.label.color, "e10c02" )
self.assertEqual( self.label.name, "Bug" )
self.assertEqual( self.label.url, "https://api.github.com/repos/jacquev6/PyGithub/labels/Bug" )
class Label(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.label = self.g.get_user().get_repo("PyGithub").get_label("Bug")
def testEdit( self ):
self.label.edit( "LabelEditedByPyGithub", "0000ff" )
self.assertEqual( self.label.color, "0000ff" )
self.assertEqual( self.label.name, "LabelEditedByPyGithub" )
self.assertEqual( self.label.url, "https://api.github.com/repos/jacquev6/PyGithub/labels/LabelEditedByPyGithub" )
def testAttributes(self):
self.assertEqual(self.label.color, "e10c02")
self.assertEqual(self.label.name, "Bug")
self.assertEqual(self.label.url, "https://api.github.com/repos/jacquev6/PyGithub/labels/Bug")
def testDelete( self ):
def testEdit(self):
self.label.edit("LabelEditedByPyGithub", "0000ff")
self.assertEqual(self.label.color, "0000ff")
self.assertEqual(self.label.name, "LabelEditedByPyGithub")
self.assertEqual(self.label.url, "https://api.github.com/repos/jacquev6/PyGithub/labels/LabelEditedByPyGithub")
def testDelete(self):
self.label.delete()
+52
View File
@@ -0,0 +1,52 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import logging
import github
import Framework
class Logging(Framework.BasicTestCase):
class MockHandler:
def __init__(self):
self.level = logging.DEBUG
self.handled = None
def handle(self, record):
self.handled = record.getMessage()
def setUp(self):
Framework.BasicTestCase.setUp(self)
logger = logging.getLogger("github")
logger.setLevel(logging.DEBUG)
self.__handler = self.MockHandler()
logger.addHandler(self.__handler)
def testLoggingWithBasicAuthentication(self):
self.assertEqual(github.Github(self.login, self.password).get_user().name, "Vincent Jacques")
self.assertEqual(self.__handler.handled, u'GET https://api.github.com/user {\'Authorization\': \'Basic (login and password removed)\'} None ==> 200 {\'status\': \'200 OK\', \'content-length\': \'806\', \'x-github-media-type\': \'github.beta; format=json\', \'x-content-type-options\': \'nosniff\', \'vary\': \'Accept, Authorization, Cookie\', \'x-ratelimit-remaining\': \'4993\', \'server\': \'nginx\', \'last-modified\': \'Fri, 14 Sep 2012 18:47:46 GMT\', \'connection\': \'keep-alive\', \'x-ratelimit-limit\': \'5000\', \'etag\': \'"434dfe5d3f50558fe3cea087cb95c401"\', \'cache-control\': \'private, s-maxage=60, max-age=60\', \'date\': \'Mon, 17 Sep 2012 17:12:32 GMT\', \'content-type\': \'application/json; charset=utf-8\'} {"owned_private_repos":3,"disk_usage":18612,"following":28,"type":"User","public_repos":13,"location":"Paris, France","company":"Criteo","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","plan":{"space":614400,"private_repos":5,"name":"micro","collaborators":1},"blog":"http://vincent-jacques.net","login":"jacquev6","public_gists":3,"html_url":"https://github.com/jacquev6","hireable":false,"created_at":"2010-07-09T06:10:06Z","private_gists":5,"followers":13,"name":"Vincent Jacques","email":"vincent@vincent-jacques.net","bio":"","total_private_repos":3,"collaborators":0,"gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146,"url":"https://api.github.com/users/jacquev6"}')
def testLoggingWithOAuthAuthentication(self):
self.assertEqual(github.Github(self.oauth_token).get_user().name, "Vincent Jacques")
self.assertEqual(self.__handler.handled, u'GET https://api.github.com/user {\'Authorization\': \'token (oauth token removed)\'} None ==> 200 {\'status\': \'200 OK\', \'x-ratelimit-remaining\': \'4993\', \'x-github-media-type\': \'github.beta; format=json\', \'x-content-type-options\': \'nosniff\', \'vary\': \'Accept, Authorization, Cookie\', \'content-length\': \'628\', \'server\': \'nginx\', \'last-modified\': \'Tue, 25 Sep 2012 07:42:42 GMT\', \'connection\': \'keep-alive\', \'x-ratelimit-limit\': \'5000\', \'etag\': \'"c23ad6b5815fc3d6ec6341c4a47afe85"\', \'cache-control\': \'private, max-age=60, s-maxage=60\', \'date\': \'Tue, 25 Sep 2012 20:36:54 GMT\', \'x-oauth-scopes\': \'\', \'content-type\': \'application/json; charset=utf-8\', \'x-accepted-oauth-scopes\': \'user\'} {"type":"User","bio":"","html_url":"https://github.com/jacquev6","login":"jacquev6","followers":14,"company":"Criteo","blog":"http://vincent-jacques.net","public_repos":13,"created_at":"2010-07-09T06:10:06Z","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","email":"vincent@vincent-jacques.net","following":29,"name":"Vincent Jacques","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","hireable":false,"id":327146,"public_gists":3,"location":"Paris, France","url":"https://api.github.com/users/jacquev6"}')
def testLoggingWithoutAuthentication(self):
self.assertEqual(github.Github().get_user("jacquev6").name, "Vincent Jacques")
self.assertEqual(self.__handler.handled, u'GET https://api.github.com/users/jacquev6 {} None ==> 200 {\'status\': \'200 OK\', \'content-length\': \'628\', \'x-github-media-type\': \'github.beta; format=json\', \'x-content-type-options\': \'nosniff\', \'vary\': \'Accept\', \'x-ratelimit-remaining\': \'4989\', \'server\': \'nginx\', \'last-modified\': \'Tue, 25 Sep 2012 07:42:42 GMT\', \'connection\': \'keep-alive\', \'x-ratelimit-limit\': \'5000\', \'etag\': \'"9bd085221a16b6d2ea95e72634c3c1ac"\', \'cache-control\': \'public, max-age=60, s-maxage=60\', \'date\': \'Tue, 25 Sep 2012 20:38:56 GMT\', \'content-type\': \'application/json; charset=utf-8\'} {"type":"User","html_url":"https://github.com/jacquev6","login":"jacquev6","followers":14,"company":"Criteo","created_at":"2010-07-09T06:10:06Z","email":"vincent@vincent-jacques.net","hireable":false,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","public_gists":3,"bio":"","following":29,"name":"Vincent Jacques","blog":"http://vincent-jacques.net","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146,"public_repos":13,"location":"Paris, France","url":"https://api.github.com/users/jacquev6"}')
def testLoggingWithBaseUrl(self):
# ReplayData forged, not recorded
self.assertEqual(github.Github(base_url="http://my.enterprise.com/my/prefix").get_user("jacquev6").name, "Vincent Jacques")
self.assertEqual(self.__handler.handled, u'GET http://my.enterprise.com/my/prefix/users/jacquev6 {} None ==> 200 {\'status\': \'200 OK\', \'content-length\': \'628\', \'x-github-media-type\': \'github.beta; format=json\', \'x-content-type-options\': \'nosniff\', \'vary\': \'Accept\', \'x-ratelimit-remaining\': \'4989\', \'server\': \'nginx\', \'last-modified\': \'Tue, 25 Sep 2012 07:42:42 GMT\', \'connection\': \'keep-alive\', \'x-ratelimit-limit\': \'5000\', \'etag\': \'"9bd085221a16b6d2ea95e72634c3c1ac"\', \'cache-control\': \'public, max-age=60, s-maxage=60\', \'date\': \'Tue, 25 Sep 2012 20:38:56 GMT\', \'content-type\': \'application/json; charset=utf-8\'} {"type":"User","html_url":"https://github.com/jacquev6","login":"jacquev6","followers":14,"company":"Criteo","created_at":"2010-07-09T06:10:06Z","email":"vincent@vincent-jacques.net","hireable":false,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","public_gists":3,"bio":"","following":29,"name":"Vincent Jacques","blog":"http://vincent-jacques.net","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146,"public_repos":13,"location":"Paris, France","url":"https://api.github.com/users/jacquev6"}')
@@ -13,14 +13,15 @@
import Framework
class Markdown( Framework.TestCase ):
def setUp( self ):
Framework.TestCase.setUp( self )
class Markdown(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.text = "MyTitle\n=======\n\nIssue #1"
self.repo = self.g.get_user().get_repo( "PyGithub" )
self.repo = self.g.get_user().get_repo("PyGithub")
def testRenderMarkdown( self ):
self.assertEqual( self.g.render_markdown( self.text ), '<h1><a name="mytitle" class="anchor" href="#mytitle"><span class="mini-icon mini-icon-link"></span></a>MyTitle</h1><p>Issue #1</p>' )
def testRenderMarkdown(self):
self.assertEqual(self.g.render_markdown(self.text), '<h1><a name="mytitle" class="anchor" href="#mytitle"><span class="mini-icon mini-icon-link"></span></a>MyTitle</h1><p>Issue #1</p>')
def testRenderGithubFlavoredMarkdown( self ):
self.assertEqual( self.g.render_markdown( self.text, self.repo ), '<h1>MyTitle</h1><p>Issue <a href="https://github.com/jacquev6/PyGithub/issues/1" class="issue-link" title="Gitub -&gt; Github everywhere">#1</a></p>' )
def testRenderGithubFlavoredMarkdown(self):
self.assertEqual(self.g.render_markdown(self.text, self.repo), '<h1>MyTitle</h1><p>Issue <a href="https://github.com/jacquev6/PyGithub/issues/1" class="issue-link" title="Gitub -&gt; Github everywhere">#1</a></p>')
+52
View File
@@ -0,0 +1,52 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import datetime
class Milestone(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.milestone = self.g.get_user().get_repo("PyGithub").get_milestone(1)
def testAttributes(self):
self.assertEqual(self.milestone.closed_issues, 2)
self.assertEqual(self.milestone.created_at, datetime.datetime(2012, 3, 8, 12, 22, 10))
self.assertEqual(self.milestone.description, "")
self.assertEqual(self.milestone.due_on, datetime.datetime(2012, 3, 13, 7, 0, 0))
self.assertEqual(self.milestone.id, 93546)
self.assertEqual(self.milestone.number, 1)
self.assertEqual(self.milestone.open_issues, 0)
self.assertEqual(self.milestone.state, "closed")
self.assertEqual(self.milestone.title, "Version 0.4")
self.assertEqual(self.milestone.url, "https://api.github.com/repos/jacquev6/PyGithub/milestones/1")
self.assertEqual(self.milestone.creator.login, "jacquev6")
def testEditWithMinimalParameters(self):
self.milestone.edit("Title edited by PyGithub")
self.assertEqual(self.milestone.title, "Title edited by PyGithub")
def testEditWithAllParameters(self):
self.milestone.edit("Title edited twice by PyGithub", "closed", "Description edited by PyGithub", due_on=datetime.date(2012, 6, 16))
self.assertEqual(self.milestone.title, "Title edited twice by PyGithub")
self.assertEqual(self.milestone.state, "closed")
self.assertEqual(self.milestone.description, "Description edited by PyGithub")
self.assertEqual(self.milestone.due_on, datetime.datetime(2012, 6, 16, 7, 0, 0))
def testGetLabels(self):
self.assertListKeyEqual(self.milestone.get_labels(), lambda l: l.name, ["Public interface", "Project management"])
def testDelete(self):
self.milestone.delete()
+131
View File
@@ -0,0 +1,131 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import github
import datetime
class NamedUser(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.user = self.g.get_user("jacquev6")
def testAttributesOfOtherUser(self):
self.user = self.g.get_user("nvie")
self.assertEqual(self.user.avatar_url, "https://secure.gravatar.com/avatar/c5a7f21b46df698f3db31c37ed0cf55a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png")
self.assertEqual(self.user.bio, None)
self.assertEqual(self.user.blog, "http://nvie.com")
self.assertEqual(self.user.collaborators, None)
self.assertEqual(self.user.company, "3rd Cloud")
self.assertEqual(self.user.created_at, datetime.datetime(2009, 5, 12, 21, 19, 38))
self.assertEqual(self.user.disk_usage, None)
self.assertEqual(self.user.email, "vincent@3rdcloud.com")
self.assertEqual(self.user.followers, 296)
self.assertEqual(self.user.following, 41)
self.assertEqual(self.user.gravatar_id, "c5a7f21b46df698f3db31c37ed0cf55a")
self.assertEqual(self.user.hireable, False)
self.assertEqual(self.user.html_url, "https://github.com/nvie")
self.assertEqual(self.user.id, 83844)
self.assertEqual(self.user.location, "Netherlands")
self.assertEqual(self.user.login, "nvie")
self.assertEqual(self.user.name, "Vincent Driessen")
self.assertEqual(self.user.owned_private_repos, None)
self.assertEqual(self.user.plan, None)
self.assertEqual(self.user.private_gists, None)
self.assertEqual(self.user.public_gists, 16)
self.assertEqual(self.user.public_repos, 61)
self.assertEqual(self.user.total_private_repos, None)
self.assertEqual(self.user.type, "User")
self.assertEqual(self.user.url, "https://api.github.com/users/nvie")
def testAttributesOfSelf(self):
self.assertEqual(self.user.avatar_url, "https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png")
self.assertEqual(self.user.bio, "")
self.assertEqual(self.user.blog, "http://vincent-jacques.net")
self.assertEqual(self.user.collaborators, 0)
self.assertEqual(self.user.company, "Criteo")
self.assertEqual(self.user.created_at, datetime.datetime(2010, 7, 9, 6, 10, 6))
self.assertEqual(self.user.disk_usage, 17080)
self.assertEqual(self.user.email, "vincent@vincent-jacques.net")
self.assertEqual(self.user.followers, 13)
self.assertEqual(self.user.following, 24)
self.assertEqual(self.user.gravatar_id, "b68de5ae38616c296fa345d2b9df2225")
self.assertEqual(self.user.hireable, False)
self.assertEqual(self.user.html_url, "https://github.com/jacquev6")
self.assertEqual(self.user.id, 327146)
self.assertEqual(self.user.location, "Paris, France")
self.assertEqual(self.user.login, "jacquev6")
self.assertEqual(self.user.name, "Vincent Jacques")
self.assertEqual(self.user.owned_private_repos, 5)
self.assertEqual(self.user.plan.name, "micro")
self.assertEqual(self.user.plan.collaborators, 1)
self.assertEqual(self.user.plan.space, 614400)
self.assertEqual(self.user.plan.private_repos, 5)
self.assertEqual(self.user.private_gists, 5)
self.assertEqual(self.user.public_gists, 2)
self.assertEqual(self.user.public_repos, 11)
self.assertEqual(self.user.total_private_repos, 5)
self.assertEqual(self.user.type, "User")
self.assertEqual(self.user.url, "https://api.github.com/users/jacquev6")
def testCreateGist(self):
gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")}, "Gist created by PyGithub on a NamedUser")
self.assertEqual(gist.description, "Gist created by PyGithub on a NamedUser")
def testCreateGistWithoutDescription(self):
gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")})
self.assertEqual(gist.description, None)
def testGetGists(self):
self.assertListKeyEqual(self.user.get_gists(), lambda g: g.description, ["Gist created by PyGithub", "FairThreadPoolPool.cpp", "How to error 500 Github API v3, as requested by Rick (GitHub Staff)", "Cadfael: order of episodes in French DVD edition"])
def testGetFollowers(self):
self.assertListKeyEqual(self.user.get_followers(), lambda f: f.login, ["jnorthrup", "brugidou", "regisb", "walidk", "afzalkhan", "sdanzan", "vineus", "gturri", "fjardon", "cjuniet", "jardon-u", "kamaradclimber", "L42y"])
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 testGetOrgs(self):
self.assertListKeyEqual(self.user.get_orgs(), lambda o: o.login, ["BeaverSoftware"])
def testGetRepo(self):
self.assertEqual(self.user.get_repo("PyGithub").description, "Python library implementing the full Github API v3")
def testGetRepos(self):
self.assertListKeyEqual(self.user.get_repos(), lambda r: r.name, ["TestPyGithub", "django", "PyGithub", "developer.github.com", "acme-public-website", "C4Planner", "DrawTurksHead", "DrawSyntax", "QuadProgMm", "Boost.HierarchicalEnum", "ViDE"])
def testGetReposWithType(self):
self.assertListKeyEqual(self.user.get_repos("owner"), lambda r: r.name, ["django", "PyGithub", "developer.github.com", "acme-public-website", "C4Planner", "DrawTurksHead", "DrawSyntax", "QuadProgMm", "Boost.HierarchicalEnum", "ViDE"])
def testGetWatched(self):
self.assertListKeyEqual(self.user.get_watched(), lambda r: r.name, ["git", "boost.php", "capistrano", "boost.perl", "git-subtree", "git-hg", "homebrew", "celtic_knot", "twisted-intro", "markup", "hub", "gitflow", "murder", "boto", "agit", "d3", "pygit2", "git-pulls", "django_mathlatex", "scrumblr", "developer.github.com", "python-github3", "PlantUML", "bootstrap", "drawnby", "django-socketio", "django-realtime", "playground", "BozoCrack", "FatherBeaver", "PyGithub", "django", "django", "TestPyGithub"])
def testGetStarred(self):
self.assertListKeyEqual(self.user.get_starred(), lambda r: r.name, ["git", "boost.php", "capistrano", "boost.perl", "git-subtree", "git-hg", "homebrew", "celtic_knot", "twisted-intro", "markup", "hub", "gitflow", "murder", "boto", "agit", "d3", "pygit2", "git-pulls", "django_mathlatex", "scrumblr", "developer.github.com", "python-github3", "PlantUML", "bootstrap", "drawnby", "django-socketio", "django-realtime", "playground", "BozoCrack", "FatherBeaver", "amaunet", "django", "django", "moviePlanning", "folly"])
def testGetSubscriptions(self):
self.assertListKeyEqual(self.user.get_subscriptions(), lambda r: r.name, ["ViDE", "Boost.HierarchicalEnum", "QuadProgMm", "DrawSyntax", "DrawTurksHead", "PrivateStuff", "vincent-jacques.net", "Hacking", "C4Planner", "developer.github.com", "PyGithub", "PyGithub", "django", "CinePlanning", "PyGithub", "PyGithub", "PyGithub", "IpMap", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub", "PyGithub"])
def testGetEvents(self):
self.assertListKeyBegin(self.user.get_events(), lambda e: e.type, ["GistEvent", "IssueCommentEvent", "PushEvent", "IssuesEvent"])
def testGetPublicEvents(self):
self.assertListKeyBegin(self.user.get_public_events(), lambda e: e.type, ["PushEvent", "CreateEvent", "GistEvent", "IssuesEvent"])
def testGetPublicReceivedEvents(self):
self.assertListKeyBegin(self.user.get_public_received_events(), lambda e: e.type, ["IssueCommentEvent", "IssueCommentEvent", "IssueCommentEvent", "IssueCommentEvent"])
def testGetReceivedEvents(self):
self.assertListKeyBegin(self.user.get_received_events(), lambda e: e.type, ["IssueCommentEvent", "IssueCommentEvent", "IssueCommentEvent", "IssueCommentEvent"])
+117
View File
@@ -0,0 +1,117 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import datetime
class Organization(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.org = self.g.get_organization("BeaverSoftware")
def testAttributes(self):
self.assertEqual(self.org.avatar_url, "https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png")
self.assertEqual(self.org.billing_email, "BeaverSoftware@vincent-jacques.net")
self.assertEqual(self.org.blog, None)
self.assertEqual(self.org.collaborators, 0)
self.assertEqual(self.org.company, None)
self.assertEqual(self.org.created_at, datetime.datetime(2012, 2, 9, 19, 20, 12))
self.assertEqual(self.org.disk_usage, 112)
self.assertEqual(self.org.email, None)
self.assertEqual(self.org.followers, 0)
self.assertEqual(self.org.following, 0)
self.assertEqual(self.org.gravatar_id, None)
self.assertEqual(self.org.html_url, "https://github.com/BeaverSoftware")
self.assertEqual(self.org.id, 1424031)
self.assertEqual(self.org.location, "Paris, France")
self.assertEqual(self.org.login, "BeaverSoftware")
self.assertEqual(self.org.name, None)
self.assertEqual(self.org.owned_private_repos, 0)
self.assertEqual(self.org.plan.name, "free")
self.assertEqual(self.org.plan.private_repos, 0)
self.assertEqual(self.org.plan.space, 307200)
self.assertEqual(self.org.private_gists, 0)
self.assertEqual(self.org.public_gists, 0)
self.assertEqual(self.org.public_repos, 2)
self.assertEqual(self.org.total_private_repos, 0)
self.assertEqual(self.org.type, "Organization")
self.assertEqual(self.org.url, "https://api.github.com/orgs/BeaverSoftware")
def testEditWithoutArguments(self):
self.org.edit()
def testEditWithAllArguments(self):
self.org.edit("BeaverSoftware2@vincent-jacques.net", "http://vincent-jacques.net", "Company edited by PyGithub", "BeaverSoftware2@vincent-jacques.net", "Location edited by PyGithub", "Name edited by PyGithub")
self.assertEqual(self.org.billing_email, "BeaverSoftware2@vincent-jacques.net")
self.assertEqual(self.org.blog, "http://vincent-jacques.net")
self.assertEqual(self.org.company, "Company edited by PyGithub")
self.assertEqual(self.org.email, "BeaverSoftware2@vincent-jacques.net")
self.assertEqual(self.org.location, "Location edited by PyGithub")
self.assertEqual(self.org.name, "Name edited by PyGithub")
def testCreateTeam(self):
team = self.org.create_team("Team created by PyGithub")
self.assertEqual(team.id, 189850)
def testCreateTeamWithAllArguments(self):
repo = self.org.get_repo("FatherBeaver")
team = self.org.create_team("Team also created by PyGithub", [repo], "push")
self.assertEqual(team.id, 189852)
def testPublicMembers(self):
lyloa = self.g.get_user("Lyloa")
self.assertFalse(self.org.has_in_public_members(lyloa))
self.org.add_to_public_members(lyloa)
self.assertTrue(self.org.has_in_public_members(lyloa))
self.org.remove_from_public_members(lyloa)
self.assertFalse(self.org.has_in_public_members(lyloa))
def testGetPublicMembers(self):
self.assertListKeyEqual(self.org.get_public_members(), lambda u: u.login, ["jacquev6"])
def testGetMembers(self):
self.assertListKeyEqual(self.org.get_members(), lambda u: u.login, ["cjuniet", "jacquev6", "Lyloa"])
def testMembers(self):
lyloa = self.g.get_user("Lyloa")
self.assertTrue(self.org.has_in_members(lyloa))
self.org.remove_from_members(lyloa)
self.assertFalse(self.org.has_in_members(lyloa))
def testGetRepos(self):
self.assertListKeyEqual(self.org.get_repos(), lambda r: r.name, ["FatherBeaver", "TestPyGithub"])
def testGetReposWithType(self):
self.assertListKeyEqual(self.org.get_repos("public"), lambda r: r.name, ["FatherBeaver", "PyGithub"])
def testGetEvents(self):
self.assertListKeyEqual(self.org.get_events(), lambda e: e.type, ["CreateEvent", "CreateEvent", "PushEvent", "PushEvent", "DeleteEvent", "DeleteEvent", "PushEvent", "PushEvent", "DeleteEvent", "DeleteEvent", "PushEvent", "PushEvent", "PushEvent", "CreateEvent", "CreateEvent", "CreateEvent", "CreateEvent", "CreateEvent", "PushEvent", "PushEvent", "PushEvent", "PushEvent", "PushEvent", "PushEvent", "ForkEvent", "CreateEvent"])
def testGetTeams(self):
self.assertListKeyEqual(self.org.get_teams(), lambda t: t.name, ["Members", "Owners"])
def testCreateRepoWithMinimalArguments(self):
repo = self.org.create_repo("TestPyGithub")
self.assertEqual(repo.url, "https://api.github.com/repos/BeaverSoftware/TestPyGithub")
def testCreateRepoWithAllArguments(self):
team = self.org.get_team(141496)
repo = self.org.create_repo("TestPyGithub2", "Repo created by PyGithub", "http://foobar.com", False, False, False, False, team)
self.assertEqual(repo.url, "https://api.github.com/repos/BeaverSoftware/TestPyGithub2")
def testCreateFork(self):
pygithub = self.g.get_user("jacquev6").get_repo("PyGithub")
repo = self.org.create_fork(pygithub)
self.assertEqual(repo.url, "https://api.github.com/repos/BeaverSoftware/PyGithub")
+80
View File
@@ -0,0 +1,80 @@
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
class PaginatedList(Framework.TestCase):
def setUp(self):
Framework.TestCase.setUp(self)
self.list = self.g.get_user("openframeworks").get_repo("openFrameworks").get_issues()
def testIteration(self):
self.assertEqual(len(list(self.list)), 333)
def testSeveralIterations(self):
self.assertEqual(len(list(self.list)), 333)
self.assertEqual(len(list(self.list)), 333)
self.assertEqual(len(list(self.list)), 333)
self.assertEqual(len(list(self.list)), 333)
def testIntIndexingInFirstPage(self):
self.assertEqual(self.list[0].id, 4772349)
self.assertEqual(self.list[24].id, 4286936)
def testIntIndexingInThirdPage(self):
self.assertEqual(self.list[50].id, 3911629)
self.assertEqual(self.list[74].id, 3605277)
def testGetFirstPage(self):
self.assertListKeyEqual(self.list.get_page(0), lambda i: i.id, [4772349, 4767675, 4758608, 4700182, 4662873, 4608132, 4604661, 4588997, 4557803, 4554058, 4539985, 4507572, 4507492, 4507416, 4447561, 4406584, 4384548, 4383465, 4373361, 4373201, 4370619, 4356530, 4352401, 4317009, 4286936])
def testGetThirdPage(self):
self.assertListKeyEqual(self.list.get_page(2), lambda i: i.id, [3911629, 3911537, 3910580, 3910555, 3910549, 3897090, 3883598, 3856005, 3850655, 3825582, 3813852, 3812318, 3812275, 3807459, 3799872, 3799653, 3795495, 3754055, 3710293, 3662214, 3647640, 3631618, 3627067, 3614231, 3605277])
def testIntIndexingAfterIteration(self):
self.assertEqual(len(list(self.list)), 333)
self.assertEqual(self.list[11].id, 4507572)
self.assertEqual(self.list[73].id, 3614231)
self.assertEqual(self.list[332].id, 94898)
def testSliceIndexingInFirstPage(self):
self.assertListKeyEqual(self.list[:13], lambda i: i.id, [4772349, 4767675, 4758608, 4700182, 4662873, 4608132, 4604661, 4588997, 4557803, 4554058, 4539985, 4507572, 4507492])
self.assertListKeyEqual(self.list[:13:3], lambda i: i.id, [4772349, 4700182, 4604661, 4554058, 4507492])
self.assertListKeyEqual(self.list[10:13], lambda i: i.id, [4539985, 4507572, 4507492])
self.assertListKeyEqual(self.list[5:13:3], lambda i: i.id, [4608132, 4557803, 4507572])
def testSliceIndexingUntilFourthPage(self):
self.assertListKeyEqual(self.list[:99:10], lambda i: i.id, [4772349, 4539985, 4370619, 4207350, 4063366, 3911629, 3813852, 3647640, 3528378, 3438233])
self.assertListKeyEqual(self.list[73:78], lambda i: i.id, [3614231, 3605277, 3596240, 3594731, 3593619])
self.assertListKeyEqual(self.list[70:80:2], lambda i: i.id, [3647640, 3627067, 3605277, 3594731, 3593430])
def testSliceIndexingUntilEnd(self):
self.assertListKeyEqual(self.list[310::3], lambda i: i.id, [268332, 204247, 169176, 166211, 165898, 163959, 132373, 104702])
self.assertListKeyEqual(self.list[310:], lambda i: i.id, [268332, 211418, 205935, 204247, 172424, 171615, 169176, 166214, 166212, 166211, 166209, 166208, 165898, 165537, 165409, 163959, 132671, 132377, 132373, 130269, 111018, 104702, 94898])
def testInterruptedIteration(self):
# No asserts, but checks that only three pages are fetched
l = 0
for element in self.list:
l += 1
if l == 75:
break
def testInterruptedIterationInSlice(self):
# No asserts, but checks that only three pages are fetched
l = 0
for element in self.list[:100]:
l += 1
if l == 75:
break

Some files were not shown because too many files have changed in this diff Show More