Skip to content

Commit

Permalink
Merge branch 'topic/Python3' into develop (issue #93)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquev6 committed Nov 22, 2012
2 parents 335e5a3 + be37b8a commit 61310d4
Show file tree
Hide file tree
Showing 63 changed files with 1,308 additions and 1,382 deletions.
5 changes: 4 additions & 1 deletion .gitignore
@@ -1,4 +1,7 @@
*.pyc
GithubCredentials.py
/dist
/dist/
/build/
/MANIFEST
/PyGithub.egg-info/
/.coverage
9 changes: 7 additions & 2 deletions .travis.yml
Expand Up @@ -3,5 +3,10 @@ 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; if [ "$(python --version 2>&1)" == "Python 2.6.8" ]; then pip install -r python26-requirements.txt --use-mirrors; fi
script: python ./setup.py test
- "3.1"
- "3.2"
install:
- if [ $TRAVIS_PYTHON_VERSION == '2.5' ]; then pip install -r python25-requirements.txt --use-mirrors; fi
- if [ $TRAVIS_PYTHON_VERSION == '2.6' ]; then pip install -r python26-requirements.txt --use-mirrors; fi
script:
- python setup.py test
5 changes: 5 additions & 0 deletions ReadMe.md
Expand Up @@ -13,6 +13,11 @@ What's new?

[![Build Status](https://secure.travis-ci.org/jacquev6/PyGithub.png)](http://travis-ci.org/jacquev6/PyGithub)

Next version
------------

* Major improvement: support Python 3! PyGithub is automaticaly tested on [Travis](http://travis-ci.org/jacquev6/PyGithub) with versions 2.5, 2.6, 2.7, 3.1 and 3.2 of Python

[Version 1.9.1](https://github.com/jacquev6/PyGithub/issues?milestone=17&state=closed) (November 20th, 2012)
------------------------------------------------------------------------------------------------------------

Expand Down
283 changes: 141 additions & 142 deletions github/AuthenticatedUser.py

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions github/Authorization.py
Expand Up @@ -13,12 +13,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/>.

import GithubObject
import github.GithubObject

import AuthorizationApplication
import github.AuthorizationApplication


class Authorization(GithubObject.GithubObject):
class Authorization(github.GithubObject.GithubObject):
@property
def app(self):
self._completeIfNotSet(self._app)
Expand Down Expand Up @@ -72,22 +72,22 @@ def delete(self):
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=github.GithubObject.NotSet, add_scopes=github.GithubObject.NotSet, remove_scopes=github.GithubObject.NotSet, note=github.GithubObject.NotSet, note_url=github.GithubObject.NotSet):
assert scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in scopes), scopes
assert add_scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in add_scopes), add_scopes
assert remove_scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in remove_scopes), remove_scopes
assert note is github.GithubObject.NotSet or isinstance(note, (str, unicode)), note
assert note_url is github.GithubObject.NotSet or isinstance(note_url, (str, unicode)), note_url
post_parameters = dict()
if scopes is not GithubObject.NotSet:
if scopes is not github.GithubObject.NotSet:
post_parameters["scopes"] = scopes
if add_scopes is not GithubObject.NotSet:
if add_scopes is not github.GithubObject.NotSet:
post_parameters["add_scopes"] = add_scopes
if remove_scopes is not GithubObject.NotSet:
if remove_scopes is not github.GithubObject.NotSet:
post_parameters["remove_scopes"] = remove_scopes
if note is not GithubObject.NotSet:
if note is not github.GithubObject.NotSet:
post_parameters["note"] = note
if note_url is not GithubObject.NotSet:
if note_url is not github.GithubObject.NotSet:
post_parameters["note_url"] = note_url
headers, data = self._requester.requestAndCheck(
"PATCH",
Expand All @@ -98,20 +98,20 @@ def edit(self, scopes=GithubObject.NotSet, add_scopes=GithubObject.NotSet, remov
self._useAttributes(data)

def _initAttributes(self):
self._app = GithubObject.NotSet
self._created_at = GithubObject.NotSet
self._id = GithubObject.NotSet
self._note = GithubObject.NotSet
self._note_url = GithubObject.NotSet
self._scopes = GithubObject.NotSet
self._token = GithubObject.NotSet
self._updated_at = GithubObject.NotSet
self._url = GithubObject.NotSet
self._app = github.GithubObject.NotSet
self._created_at = github.GithubObject.NotSet
self._id = github.GithubObject.NotSet
self._note = github.GithubObject.NotSet
self._note_url = github.GithubObject.NotSet
self._scopes = github.GithubObject.NotSet
self._token = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
self._url = github.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)
self._app = None if attributes["app"] is None else github.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"])
Expand Down
8 changes: 4 additions & 4 deletions github/AuthorizationApplication.py
Expand Up @@ -13,10 +13,10 @@

# 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 GithubObject
import github.GithubObject


class AuthorizationApplication(GithubObject.GithubObject):
class AuthorizationApplication(github.GithubObject.GithubObject):
@property
def name(self):
self._completeIfNotSet(self._name)
Expand All @@ -28,8 +28,8 @@ def url(self):
return self._NoneIfNotSet(self._url)

def _initAttributes(self):
self._name = GithubObject.NotSet
self._url = GithubObject.NotSet
self._name = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet

def _useAttributes(self, attributes):
if "name" in attributes: # pragma no branch
Expand Down
12 changes: 6 additions & 6 deletions github/Branch.py
Expand Up @@ -13,12 +13,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/>.

import GithubObject
import github.GithubObject

import Commit
import github.Commit


class Branch(GithubObject.BasicGithubObject):
class Branch(github.GithubObject.BasicGithubObject):
@property
def commit(self):
return self._NoneIfNotSet(self._commit)
Expand All @@ -28,13 +28,13 @@ def name(self):
return self._NoneIfNotSet(self._name)

def _initAttributes(self):
self._commit = GithubObject.NotSet
self._name = GithubObject.NotSet
self._commit = github.GithubObject.NotSet
self._name = github.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)
self._commit = None if attributes["commit"] is None else github.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"]
81 changes: 40 additions & 41 deletions github/Commit.py
Expand Up @@ -13,19 +13,18 @@

# 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 GithubObject
import PaginatedList
import github.GithubObject
import github.PaginatedList

import GitCommit
import NamedUser
import CommitStatus
import File
import CommitStats
import Commit
import CommitComment
import github.GitCommit
import github.NamedUser
import github.CommitStatus
import github.File
import github.CommitStats
import github.CommitComment


class Commit(GithubObject.GithubObject):
class Commit(github.GithubObject.GithubObject):
@property
def author(self):
self._completeIfNotSet(self._author)
Expand Down Expand Up @@ -66,58 +65,58 @@ 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):
def create_comment(self, body, line=github.GithubObject.NotSet, path=github.GithubObject.NotSet, position=github.GithubObject.NotSet):
assert isinstance(body, (str, unicode)), body
assert line is GithubObject.NotSet or isinstance(line, (int, long)), line
assert path is GithubObject.NotSet or isinstance(path, (str, unicode)), path
assert position is GithubObject.NotSet or isinstance(position, (int, long)), position
assert line is github.GithubObject.NotSet or isinstance(line, (int, long)), line
assert path is github.GithubObject.NotSet or isinstance(path, (str, unicode)), path
assert position is github.GithubObject.NotSet or isinstance(position, (int, long)), position
post_parameters = {
"body": body,
}
if line is not GithubObject.NotSet:
if line is not github.GithubObject.NotSet:
post_parameters["line"] = line
if path is not GithubObject.NotSet:
if path is not github.GithubObject.NotSet:
post_parameters["path"] = path
if position is not GithubObject.NotSet:
if position is not github.GithubObject.NotSet:
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 github.CommitComment.CommitComment(self._requester, data, completed=True)

def create_status(self, state, target_url=GithubObject.NotSet, description=GithubObject.NotSet):
def create_status(self, state, target_url=github.GithubObject.NotSet, description=github.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
assert target_url is github.GithubObject.NotSet or isinstance(target_url, (str, unicode)), target_url
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description
post_parameters = {
"state": state,
}
if target_url is not GithubObject.NotSet:
if target_url is not github.GithubObject.NotSet:
post_parameters["target_url"] = target_url
if description is not GithubObject.NotSet:
if description is not github.GithubObject.NotSet:
post_parameters["description"] = description
headers, data = self._requester.requestAndCheck(
"POST",
self._parentUrl(self._parentUrl(self.url)) + "/statuses/" + self.sha,
None,
post_parameters
)
return CommitStatus.CommitStatus(self._requester, data, completed=True)
return github.CommitStatus.CommitStatus(self._requester, data, completed=True)

def get_comments(self):
return PaginatedList.PaginatedList(
CommitComment.CommitComment,
return github.PaginatedList.PaginatedList(
github.CommitComment.CommitComment,
self._requester,
self.url + "/comments",
None
)

def get_statuses(self):
return PaginatedList.PaginatedList(
CommitStatus.CommitStatus,
return github.PaginatedList.PaginatedList(
github.CommitStatus.CommitStatus,
self._requester,
self._parentUrl(self._parentUrl(self.url)) + "/statuses/" + self.sha,
None
Expand All @@ -128,29 +127,29 @@ def _identity(self):
return self.sha

def _initAttributes(self):
self._author = GithubObject.NotSet
self._commit = GithubObject.NotSet
self._committer = GithubObject.NotSet
self._files = GithubObject.NotSet
self._parents = GithubObject.NotSet
self._sha = GithubObject.NotSet
self._stats = GithubObject.NotSet
self._url = GithubObject.NotSet
self._author = github.GithubObject.NotSet
self._commit = github.GithubObject.NotSet
self._committer = github.GithubObject.NotSet
self._files = github.GithubObject.NotSet
self._parents = github.GithubObject.NotSet
self._sha = github.GithubObject.NotSet
self._stats = github.GithubObject.NotSet
self._url = github.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)
self._author = None if attributes["author"] is None else github.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)
self._commit = None if attributes["commit"] is None else github.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)
self._committer = None if attributes["committer"] is None else github.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)
github.File.File(self._requester, element, completed=False)
for element in attributes["files"]
]
if "parents" in attributes: # pragma no branch
Expand All @@ -164,7 +163,7 @@ def _useAttributes(self, attributes):
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)
self._stats = None if attributes["stats"] is None else github.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"]
30 changes: 15 additions & 15 deletions github/CommitComment.py
Expand Up @@ -13,12 +13,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/>.

import GithubObject
import github.GithubObject

import NamedUser
import github.NamedUser


class CommitComment(GithubObject.GithubObject):
class CommitComment(github.GithubObject.GithubObject):
@property
def body(self):
self._completeIfNotSet(self._body)
Expand Down Expand Up @@ -96,17 +96,17 @@ def edit(self, body):
self._useAttributes(data)

def _initAttributes(self):
self._body = GithubObject.NotSet
self._commit_id = GithubObject.NotSet
self._created_at = GithubObject.NotSet
self._html_url = GithubObject.NotSet
self._id = GithubObject.NotSet
self._line = GithubObject.NotSet
self._path = GithubObject.NotSet
self._position = GithubObject.NotSet
self._updated_at = GithubObject.NotSet
self._url = GithubObject.NotSet
self._user = GithubObject.NotSet
self._body = github.GithubObject.NotSet
self._commit_id = github.GithubObject.NotSet
self._created_at = github.GithubObject.NotSet
self._html_url = github.GithubObject.NotSet
self._id = github.GithubObject.NotSet
self._line = github.GithubObject.NotSet
self._path = github.GithubObject.NotSet
self._position = github.GithubObject.NotSet
self._updated_at = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
self._user = github.GithubObject.NotSet

def _useAttributes(self, attributes):
if "body" in attributes: # pragma no branch
Expand Down Expand Up @@ -141,4 +141,4 @@ def _useAttributes(self, attributes):
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)
self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False)

0 comments on commit 61310d4

Please sign in to comment.