diff --git a/.travis.yml b/.travis.yml index c7170f74..1a031804 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ matrix: install: - pip install codecov script: - - if [[ $TRAVIS_PYTHON_VERSION != '2.7' ]]; then python -m lib2to3 -w -n tests; fi - coverage run --source github/tests setup.py test after_success: - codecov diff --git a/github/AuthenticatedUser.py b/github/AuthenticatedUser.py index 80400a27..37a9785c 100644 --- a/github/AuthenticatedUser.py +++ b/github/AuthenticatedUser.py @@ -40,6 +40,7 @@ # # ################################################################################ +from __future__ import absolute_import import datetime import github.GithubObject @@ -57,7 +58,8 @@ import github.Authorization import github.Notification import github.Migration -import Consts +from . import Consts +import six class AuthenticatedUser(github.GithubObject.CompletableGithubObject): @@ -372,7 +374,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param email: string :rtype: None """ - assert all(isinstance(element, (str, unicode)) for element in emails), emails + assert all(isinstance(element, (str, six.text_type)) for element in emails), emails post_parameters = emails headers, data = self._requester.requestJsonAndCheck( "POST", @@ -440,12 +442,12 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param onetime_password: string :rtype: :class:`github.Authorization.Authorization` """ - assert scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in scopes), 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 - assert client_id is github.GithubObject.NotSet or isinstance(client_id, (str, unicode)), client_id - assert client_secret is github.GithubObject.NotSet or isinstance(client_secret, (str, unicode)), client_secret - assert onetime_password is None or isinstance(onetime_password, (str, unicode)), onetime_password + assert scopes is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in scopes), scopes + assert note is github.GithubObject.NotSet or isinstance(note, (str, six.text_type)), note + assert note_url is github.GithubObject.NotSet or isinstance(note_url, (str, six.text_type)), note_url + assert client_id is github.GithubObject.NotSet or isinstance(client_id, (str, six.text_type)), client_id + assert client_secret is github.GithubObject.NotSet or isinstance(client_secret, (str, six.text_type)), client_secret + assert onetime_password is None or isinstance(onetime_password, (str, six.text_type)), onetime_password post_parameters = dict() if scopes is not github.GithubObject.NotSet: post_parameters["scopes"] = scopes @@ -491,11 +493,11 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Gist.Gist` """ assert isinstance(public, bool), public - assert all(isinstance(element, github.InputFileContent) for element in files.itervalues()), files - assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description + assert all(isinstance(element, github.InputFileContent) for element in six.itervalues(files)), files + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description post_parameters = { "public": public, - "files": {key: value._identity for key, value in files.iteritems()}, + "files": {key: value._identity for key, value in six.iteritems(files)}, } if description is not github.GithubObject.NotSet: post_parameters["description"] = description @@ -513,8 +515,8 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param key: string :rtype: :class:`github.UserKey.UserKey` """ - assert isinstance(title, (str, unicode)), title - assert isinstance(key, (str, unicode)), key + assert isinstance(title, (str, six.text_type)), title + assert isinstance(key, (str, six.text_type)), key post_parameters = { "title": title, "key": key, @@ -550,17 +552,17 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param allow_rebase_merge: bool :rtype: :class:`github.Repository.Repository` """ - assert isinstance(name, (str, unicode)), name - assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description - assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, unicode)), homepage + assert isinstance(name, (str, six.text_type)), name + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description + assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, six.text_type)), homepage assert private is github.GithubObject.NotSet or isinstance(private, bool), private assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects assert auto_init is github.GithubObject.NotSet or isinstance(auto_init, bool), auto_init - assert license_template is github.GithubObject.NotSet or isinstance(license_template, (str, unicode)), license_template - assert gitignore_template is github.GithubObject.NotSet or isinstance(gitignore_template, (str, unicode)), gitignore_template + assert license_template is github.GithubObject.NotSet or isinstance(license_template, (str, six.text_type)), license_template + assert gitignore_template is github.GithubObject.NotSet or isinstance(gitignore_template, (str, six.text_type)), gitignore_template assert allow_squash_merge is github.GithubObject.NotSet or isinstance(allow_squash_merge, bool), allow_squash_merge assert allow_merge_commit is github.GithubObject.NotSet or isinstance(allow_merge_commit, bool), allow_merge_commit assert allow_rebase_merge is github.GithubObject.NotSet or isinstance(allow_rebase_merge, bool), allow_rebase_merge @@ -612,13 +614,13 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param bio: string :rtype: None """ - assert name is github.GithubObject.NotSet or isinstance(name, (str, unicode)), name - assert email is github.GithubObject.NotSet or isinstance(email, (str, unicode)), email - assert blog is github.GithubObject.NotSet or isinstance(blog, (str, unicode)), blog - assert company is github.GithubObject.NotSet or isinstance(company, (str, unicode)), company - assert location is github.GithubObject.NotSet or isinstance(location, (str, unicode)), location + assert name is github.GithubObject.NotSet or isinstance(name, (str, six.text_type)), name + assert email is github.GithubObject.NotSet or isinstance(email, (str, six.text_type)), email + assert blog is github.GithubObject.NotSet or isinstance(blog, (str, six.text_type)), blog + assert company is github.GithubObject.NotSet or isinstance(company, (str, six.text_type)), company + assert location is github.GithubObject.NotSet or isinstance(location, (str, six.text_type)), location assert hireable is github.GithubObject.NotSet or isinstance(hireable, bool), hireable - assert bio is github.GithubObject.NotSet or isinstance(bio, (str, unicode)), bio + assert bio is github.GithubObject.NotSet or isinstance(bio, (str, six.text_type)), bio post_parameters = dict() if name is not github.GithubObject.NotSet: post_parameters["name"] = name @@ -647,7 +649,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.Authorization.Authorization` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", "/authorizations/" + str(id) @@ -742,11 +744,11 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param since: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` """ - assert filter is github.GithubObject.NotSet or isinstance(filter, (str, unicode)), filter - assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state + assert filter is github.GithubObject.NotSet or isinstance(filter, (str, six.text_type)), filter + assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) for element in labels), labels - assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort - assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction + assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort + assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since url_parameters = dict() if filter is not github.GithubObject.NotSet: @@ -780,11 +782,11 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param since: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` """ - assert filter is github.GithubObject.NotSet or isinstance(filter, (str, unicode)), filter - assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state + assert filter is github.GithubObject.NotSet or isinstance(filter, (str, six.text_type)), filter + assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) for element in labels), labels - assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort - assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction + assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort + assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since url_parameters = dict() if filter is not github.GithubObject.NotSet: @@ -812,7 +814,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.UserKey.UserKey` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", "/user/keys/" + str(id) @@ -837,7 +839,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Notification.Notification` """ - assert isinstance(id, (str, unicode)), id + assert isinstance(id, (str, six.text_type)), id headers, data = self._requester.requestJsonAndCheck( "GET", "/notifications/threads/" + id @@ -908,7 +910,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param name: string :rtype: :class:`github.Repository.Repository` """ - assert isinstance(name, (str, unicode)), name + assert isinstance(name, (str, six.text_type)), name headers, data = self._requester.requestJsonAndCheck( "GET", "/repos/" + self.login + "/" + name @@ -925,11 +927,11 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param direction: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ - assert visibility is github.GithubObject.NotSet or isinstance(visibility, (str, unicode)), visibility - assert affiliation is github.GithubObject.NotSet or isinstance(affiliation, (str, unicode)), affiliation - assert type is github.GithubObject.NotSet or isinstance(type, (str, unicode)), type - assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort - assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction + assert visibility is github.GithubObject.NotSet or isinstance(visibility, (str, six.text_type)), visibility + assert affiliation is github.GithubObject.NotSet or isinstance(affiliation, (str, six.text_type)), affiliation + assert type is github.GithubObject.NotSet or isinstance(type, (str, six.text_type)), type + assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort + assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction url_parameters = dict() if visibility is not github.GithubObject.NotSet: url_parameters["visibility"] = visibility @@ -1082,7 +1084,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :param email: string :rtype: None """ - assert all(isinstance(element, (str, unicode)) for element in emails), emails + assert all(isinstance(element, (str, six.text_type)) for element in emails), emails post_parameters = emails headers, data = self._requester.requestJsonAndCheck( "DELETE", @@ -1176,7 +1178,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Migration.Migration` """ assert isinstance(repos, (list, tuple)), repos - assert all(isinstance(repo, (str, unicode)) for repo in repos), repos + assert all(isinstance(repo, (str, six.text_type)) for repo in repos), repos assert lock_repositories is github.GithubObject.NotSet or isinstance(lock_repositories, bool), lock_repositories assert exclude_attachments is github.GithubObject.NotSet or isinstance(exclude_attachments, bool), exclude_attachments post_parameters = { diff --git a/github/Authorization.py b/github/Authorization.py index 22c7ad3b..faea16ca 100644 --- a/github/Authorization.py +++ b/github/Authorization.py @@ -30,9 +30,11 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.AuthorizationApplication +import six class Authorization(github.GithubObject.CompletableGithubObject): @@ -135,11 +137,11 @@ class Authorization(github.GithubObject.CompletableGithubObject): :param note_url: string :rtype: None """ - 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 + assert scopes is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in scopes), scopes + assert add_scopes is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in add_scopes), add_scopes + assert remove_scopes is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in remove_scopes), remove_scopes + assert note is github.GithubObject.NotSet or isinstance(note, (str, six.text_type)), note + assert note_url is github.GithubObject.NotSet or isinstance(note_url, (str, six.text_type)), note_url post_parameters = dict() if scopes is not github.GithubObject.NotSet: post_parameters["scopes"] = scopes diff --git a/github/AuthorizationApplication.py b/github/AuthorizationApplication.py index c6b9bc50..ab3e93e5 100644 --- a/github/AuthorizationApplication.py +++ b/github/AuthorizationApplication.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Branch.py b/github/Branch.py index 07f615fd..7f5e4773 100644 --- a/github/Branch.py +++ b/github/Branch.py @@ -33,6 +33,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.BranchProtection @@ -40,7 +41,8 @@ import github.Commit import github.RequiredPullRequestReviews import github.RequiredStatusChecks -import Consts +from . import Consts +import six class Branch(github.GithubObject.NonCompletableGithubObject): @@ -125,10 +127,10 @@ class Branch(github.GithubObject.NonCompletableGithubObject): changing. Use edit_required_status_checks() to avoid this. """ assert strict is github.GithubObject.NotSet or isinstance(strict, bool), strict - assert contexts is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in contexts), contexts + assert contexts is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in contexts), contexts assert enforce_admins is github.GithubObject.NotSet or isinstance(enforce_admins, bool), enforce_admins - assert dismissal_users is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in dismissal_users), dismissal_users - assert dismissal_teams is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in dismissal_teams), dismissal_teams + assert dismissal_users is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in dismissal_users), dismissal_users + assert dismissal_teams is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in dismissal_teams), dismissal_teams assert dismiss_stale_reviews is github.GithubObject.NotSet or isinstance(dismiss_stale_reviews, bool), dismiss_stale_reviews assert require_code_owner_reviews is github.GithubObject.NotSet or isinstance(require_code_owner_reviews, bool), require_code_owner_reviews assert required_approving_review_count is github.GithubObject.NotSet or isinstance(required_approving_review_count, int), required_approving_review_count @@ -207,7 +209,7 @@ class Branch(github.GithubObject.NonCompletableGithubObject): :contexts: list of strings """ assert strict is github.GithubObject.NotSet or isinstance(strict, bool), strict - assert contexts is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in contexts), contexts + assert contexts is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in contexts), contexts post_parameters = {} if strict is not github.GithubObject.NotSet: @@ -250,8 +252,8 @@ class Branch(github.GithubObject.NonCompletableGithubObject): :require_code_owner_reviews: bool :required_approving_review_count: int """ - assert dismissal_users is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in dismissal_users), dismissal_users - assert dismissal_teams is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in dismissal_teams), dismissal_teams + assert dismissal_users is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in dismissal_users), dismissal_users + assert dismissal_teams is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in dismissal_teams), dismissal_teams assert dismiss_stale_reviews is github.GithubObject.NotSet or isinstance(dismiss_stale_reviews, bool), dismiss_stale_reviews assert require_code_owner_reviews is github.GithubObject.NotSet or isinstance(require_code_owner_reviews, bool), require_code_owner_reviews assert required_approving_review_count is github.GithubObject.NotSet or isinstance(required_approving_review_count, int), required_approving_review_count @@ -343,7 +345,7 @@ class Branch(github.GithubObject.NonCompletableGithubObject): :calls: `POST /repos/:owner/:repo/branches/:branch/protection/restrictions `_ :users: list of strings """ - assert all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in users), users + assert all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in users), users headers, data = self._requester.requestJsonAndCheck( "POST", @@ -356,7 +358,7 @@ class Branch(github.GithubObject.NonCompletableGithubObject): :calls: `POST /repos/:owner/:repo/branches/:branch/protection/restrictions `_ :teams: list of strings """ - assert all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in teams), teams + assert all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in teams), teams headers, data = self._requester.requestJsonAndCheck( "POST", diff --git a/github/BranchProtection.py b/github/BranchProtection.py index cf48147a..caf1bfd9 100644 --- a/github/BranchProtection.py +++ b/github/BranchProtection.py @@ -22,6 +22,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser diff --git a/github/Clones.py b/github/Clones.py index b8c1adc7..1f3faac6 100644 --- a/github/Clones.py +++ b/github/Clones.py @@ -26,6 +26,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Commit.py b/github/Commit.py index fb6afa21..a15fdc6e 100644 --- a/github/Commit.py +++ b/github/Commit.py @@ -32,6 +32,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.PaginatedList @@ -42,6 +43,7 @@ import github.CommitCombinedStatus import github.File import github.CommitStats import github.CommitComment +import six class Commit(github.GithubObject.CompletableGithubObject): @@ -141,10 +143,10 @@ class Commit(github.GithubObject.CompletableGithubObject): :param position: integer :rtype: :class:`github.CommitComment.CommitComment` """ - assert isinstance(body, (str, unicode)), body - 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 + assert isinstance(body, (str, six.text_type)), body + assert line is github.GithubObject.NotSet or isinstance(line, six.integer_types), line + assert path is github.GithubObject.NotSet or isinstance(path, (str, six.text_type)), path + assert position is github.GithubObject.NotSet or isinstance(position, six.integer_types), position post_parameters = { "body": body, } @@ -170,10 +172,10 @@ class Commit(github.GithubObject.CompletableGithubObject): :param context: string :rtype: :class:`github.CommitStatus.CommitStatus` """ - assert isinstance(state, (str, unicode)), state - 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 - assert context is github.GithubObject.NotSet or isinstance(context, (str, unicode)), context + assert isinstance(state, (str, six.text_type)), state + assert target_url is github.GithubObject.NotSet or isinstance(target_url, (str, six.text_type)), target_url + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description + assert context is github.GithubObject.NotSet or isinstance(context, (str, six.text_type)), context post_parameters = { "state": state, } diff --git a/github/CommitCombinedStatus.py b/github/CommitCombinedStatus.py index 9cf21dcf..3516ea39 100644 --- a/github/CommitCombinedStatus.py +++ b/github/CommitCombinedStatus.py @@ -26,6 +26,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.CommitStatus diff --git a/github/CommitComment.py b/github/CommitComment.py index d5224a11..6a085168 100644 --- a/github/CommitComment.py +++ b/github/CommitComment.py @@ -32,10 +32,12 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser -import Consts +from . import Consts +import six class CommitComment(github.GithubObject.CompletableGithubObject): @@ -150,7 +152,7 @@ class CommitComment(github.GithubObject.CompletableGithubObject): :param body: string :rtype: None """ - assert isinstance(body, (str, unicode)), body + assert isinstance(body, (str, six.text_type)), body post_parameters = { "body": body, } @@ -182,7 +184,7 @@ class CommitComment(github.GithubObject.CompletableGithubObject): :param reaction_type: string :rtype: :class:`github.Reaction.Reaction` """ - assert isinstance(reaction_type, (str, unicode)), "reaction type should be a string" + assert isinstance(reaction_type, (str, six.text_type)), "reaction type should be a string" assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \ "Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)" diff --git a/github/CommitStats.py b/github/CommitStats.py index e98fb210..e1b78b76 100644 --- a/github/CommitStats.py +++ b/github/CommitStats.py @@ -29,6 +29,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/CommitStatus.py b/github/CommitStatus.py index 2fa5d58c..91b05d70 100644 --- a/github/CommitStatus.py +++ b/github/CommitStatus.py @@ -32,6 +32,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser diff --git a/github/Comparison.py b/github/Comparison.py index 22d01beb..cfcbc9a0 100644 --- a/github/Comparison.py +++ b/github/Comparison.py @@ -29,6 +29,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.Commit diff --git a/github/ContentFile.py b/github/ContentFile.py index e597a099..10b30ff0 100644 --- a/github/ContentFile.py +++ b/github/ContentFile.py @@ -31,6 +31,7 @@ # # ################################################################################ +from __future__ import absolute_import import base64 import sys diff --git a/github/Download.py b/github/Download.py index 7e31593c..2b7fb92e 100644 --- a/github/Download.py +++ b/github/Download.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Event.py b/github/Event.py index 5b9fb9af..6a92a010 100644 --- a/github/Event.py +++ b/github/Event.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.Organization diff --git a/github/File.py b/github/File.py index a07baaf0..7fc09776 100644 --- a/github/File.py +++ b/github/File.py @@ -32,6 +32,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Gist.py b/github/Gist.py index 0164ded6..6115f852 100644 --- a/github/Gist.py +++ b/github/Gist.py @@ -33,6 +33,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.PaginatedList @@ -40,6 +41,7 @@ import github.GistComment import github.NamedUser import github.GistFile import github.GistHistoryState +import six class Gist(github.GithubObject.CompletableGithubObject): @@ -208,7 +210,7 @@ class Gist(github.GithubObject.CompletableGithubObject): :param body: string :rtype: :class:`github.GistComment.GistComment` """ - assert isinstance(body, (str, unicode)), body + assert isinstance(body, (str, six.text_type)), body post_parameters = { "body": body, } @@ -247,13 +249,13 @@ class Gist(github.GithubObject.CompletableGithubObject): :param files: dict of string to :class:`github.InputFileContent.InputFileContent` :rtype: None """ - assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description - assert files is github.GithubObject.NotSet or all(element is None or isinstance(element, github.InputFileContent) for element in files.itervalues()), files + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description + assert files is github.GithubObject.NotSet or all(element is None or isinstance(element, github.InputFileContent) for element in six.itervalues(files)), files post_parameters = dict() if description is not github.GithubObject.NotSet: post_parameters["description"] = description if files is not github.GithubObject.NotSet: - post_parameters["files"] = {key: None if value is None else value._identity for key, value in files.iteritems()} + post_parameters["files"] = {key: None if value is None else value._identity for key, value in six.iteritems(files)} headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, @@ -267,7 +269,7 @@ class Gist(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.GistComment.GistComment` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/comments/" + str(id) diff --git a/github/GistComment.py b/github/GistComment.py index c62c0e6c..2de766f7 100644 --- a/github/GistComment.py +++ b/github/GistComment.py @@ -30,9 +30,11 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser +import six class GistComment(github.GithubObject.CompletableGithubObject): @@ -107,7 +109,7 @@ class GistComment(github.GithubObject.CompletableGithubObject): :param body: string :rtype: None """ - assert isinstance(body, (str, unicode)), body + assert isinstance(body, (str, six.text_type)), body post_parameters = { "body": body, } diff --git a/github/GistFile.py b/github/GistFile.py index c9245116..a16829a1 100644 --- a/github/GistFile.py +++ b/github/GistFile.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/GistHistoryState.py b/github/GistHistoryState.py index 01fc3add..bd01a79b 100644 --- a/github/GistHistoryState.py +++ b/github/GistHistoryState.py @@ -29,6 +29,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser diff --git a/github/GitAuthor.py b/github/GitAuthor.py index d7f5dc8a..6532f96e 100644 --- a/github/GitAuthor.py +++ b/github/GitAuthor.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/GitBlob.py b/github/GitBlob.py index 2db328d9..367db983 100644 --- a/github/GitBlob.py +++ b/github/GitBlob.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/GitCommit.py b/github/GitCommit.py index 92e903a6..9198240e 100644 --- a/github/GitCommit.py +++ b/github/GitCommit.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.GitAuthor diff --git a/github/GitObject.py b/github/GitObject.py index ce2fd71f..b03c7fdb 100644 --- a/github/GitObject.py +++ b/github/GitObject.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/GitRef.py b/github/GitRef.py index b35e3ab7..9c929d60 100644 --- a/github/GitRef.py +++ b/github/GitRef.py @@ -30,9 +30,11 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.GitObject +import six class GitRef(github.GithubObject.CompletableGithubObject): @@ -84,7 +86,7 @@ class GitRef(github.GithubObject.CompletableGithubObject): :param force: bool :rtype: None """ - assert isinstance(sha, (str, unicode)), sha + assert isinstance(sha, (str, six.text_type)), sha assert force is github.GithubObject.NotSet or isinstance(force, bool), force post_parameters = { "sha": sha, diff --git a/github/GitRelease.py b/github/GitRelease.py index 2b050749..8ab79fdb 100644 --- a/github/GitRelease.py +++ b/github/GitRelease.py @@ -35,10 +35,12 @@ # # ################################################################################ +from __future__ import absolute_import from os.path import basename import github.GithubObject import github.NamedUser import github.GitReleaseAsset +import six class GitRelease(github.GithubObject.CompletableGithubObject): @@ -187,13 +189,13 @@ class GitRelease(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.GitRelease.GitRelease` """ assert tag_name is github.GithubObject.NotSet \ - or isinstance(tag_name, (str, unicode)), \ + or isinstance(tag_name, (str, six.text_type)), \ 'tag_name must be a str/unicode object' assert target_commitish is github.GithubObject.NotSet \ - or isinstance(target_commitish, (str, unicode)), \ + or isinstance(target_commitish, (str, six.text_type)), \ 'target_commitish must be a str/unicode object' - assert isinstance(name, (str, unicode)), name - assert isinstance(message, (str, unicode)), message + assert isinstance(name, (str, six.text_type)), name + assert isinstance(message, (str, six.text_type)), message assert isinstance(draft, bool), draft assert isinstance(prerelease, bool), prerelease if tag_name is github.GithubObject.NotSet: @@ -221,9 +223,9 @@ class GitRelease(github.GithubObject.CompletableGithubObject): :calls: `POST https:///repos/:owner/:repo/releases/:release_id/assets `_ :rtype: :class:`github.GitReleaseAsset.GitReleaseAsset` """ - assert isinstance(path, (str, unicode)), path - assert isinstance(label, (str, unicode)), label - assert name is github.GithubObject.NotSet or isinstance(name, (str, unicode)), name + assert isinstance(path, (str, six.text_type)), path + assert isinstance(label, (str, six.text_type)), label + assert name is github.GithubObject.NotSet or isinstance(name, (str, six.text_type)), name post_parameters = { "label": label diff --git a/github/GitReleaseAsset.py b/github/GitReleaseAsset.py index 1f899e7e..a92848a4 100644 --- a/github/GitReleaseAsset.py +++ b/github/GitReleaseAsset.py @@ -25,7 +25,9 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject +import six class GitReleaseAsset(github.GithubObject.CompletableGithubObject): @@ -164,8 +166,8 @@ class GitReleaseAsset(github.GithubObject.CompletableGithubObject): Update asset metadata. :rtype: github.GitReleaseAsset.GitReleaseAsset """ - assert isinstance(name, (str, unicode)), name - assert isinstance(label, (str, unicode)), label + assert isinstance(name, (str, six.text_type)), name + assert isinstance(label, (str, six.text_type)), label post_parameters = { "name": name, "label": label diff --git a/github/GitTag.py b/github/GitTag.py index 059fc9f1..5b9a41dd 100644 --- a/github/GitTag.py +++ b/github/GitTag.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.GitAuthor diff --git a/github/GitTree.py b/github/GitTree.py index c9aca0d1..a5c0fd79 100644 --- a/github/GitTree.py +++ b/github/GitTree.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.GitTreeElement diff --git a/github/GitTreeElement.py b/github/GitTreeElement.py index cf7d21e8..eadf7d1e 100644 --- a/github/GitTreeElement.py +++ b/github/GitTreeElement.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/GithubObject.py b/github/GithubObject.py index af8587e2..b5462cf0 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -32,12 +32,14 @@ # # ################################################################################ +from __future__ import absolute_import import sys import datetime from operator import itemgetter -import GithubException -import Consts +from . import GithubException +from . import Consts +import six atLeastPython3 = sys.hexversion >= 0x03000000 @@ -140,18 +142,18 @@ class GithubObject(object): elif isinstance(value, type): try: return _ValuedAttribute(transform(value)) - except Exception, e: + except Exception as e: return _BadAttribute(value, type, e) else: return _BadAttribute(value, type) @staticmethod def _makeStringAttribute(value): - return GithubObject.__makeSimpleAttribute(value, (str, unicode)) + return GithubObject.__makeSimpleAttribute(value, (str, six.text_type)) @staticmethod def _makeIntAttribute(value): - return GithubObject.__makeSimpleAttribute(value, (int, long)) + return GithubObject.__makeSimpleAttribute(value, six.integer_types) @staticmethod def _makeBoolAttribute(value): @@ -163,7 +165,7 @@ class GithubObject(object): @staticmethod def _makeTimestampAttribute(value): - return GithubObject.__makeTransformedAttribute(value, (int, long), datetime.datetime.utcfromtimestamp) + return GithubObject.__makeTransformedAttribute(value, six.integer_types, datetime.datetime.utcfromtimestamp) @staticmethod def _makeDatetimeAttribute(value): @@ -177,14 +179,14 @@ class GithubObject(object): else: return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%SZ") - return GithubObject.__makeTransformedAttribute(value, (str, unicode), parseDatetime) + return GithubObject.__makeTransformedAttribute(value, (str, six.text_type), parseDatetime) def _makeClassAttribute(self, klass, value): return GithubObject.__makeTransformedAttribute(value, dict, lambda value: klass(self._requester, self._headers, value, completed=False)) @staticmethod def _makeListOfStringsAttribute(value): - return GithubObject.__makeSimpleListAttribute(value, (str, unicode)) + return GithubObject.__makeSimpleListAttribute(value, (str, six.text_type)) @staticmethod def _makeListOfIntsAttribute(value): @@ -205,10 +207,10 @@ class GithubObject(object): return _BadAttribute(value, [dict]) def _makeDictOfStringsToClassesAttribute(self, klass, value): - if isinstance(value, dict) and all(isinstance(key, (str, unicode)) and isinstance(element, dict) for key, element in value.iteritems()): - return _ValuedAttribute(dict((key, klass(self._requester, self._headers, element, completed=False)) for key, element in value.iteritems())) + if isinstance(value, dict) and all(isinstance(key, (str, six.text_type)) and isinstance(element, dict) for key, element in six.iteritems(value)): + return _ValuedAttribute(dict((key, klass(self._requester, self._headers, element, completed=False)) for key, element in six.iteritems(value))) else: - return _BadAttribute(value, {(str, unicode): dict}) + return _BadAttribute(value, {(str, six.text_type): dict}) @property def etag(self): @@ -230,11 +232,11 @@ class GithubObject(object): """ def format_params(params): if atLeastPython3: - items = params.items() + items = list(params.items()) else: items = list(params.items()) for k, v in sorted(items, key=itemgetter(0), reverse=True): - isText = isinstance(v, (str, unicode)) + isText = isinstance(v, (str, six.text_type)) if isText and not atLeastPython3: v = v.encode('utf-8') yield '{k}="{v}"'.format(k=k, v=v) if isText else '{k}={v}'.format(k=k, v=v) diff --git a/github/GitignoreTemplate.py b/github/GitignoreTemplate.py index 79c708be..650885dd 100644 --- a/github/GitignoreTemplate.py +++ b/github/GitignoreTemplate.py @@ -29,6 +29,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Hook.py b/github/Hook.py index 3866368f..30b2ab9f 100644 --- a/github/Hook.py +++ b/github/Hook.py @@ -31,9 +31,11 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.HookResponse +import six class Hook(github.GithubObject.CompletableGithubObject): @@ -153,11 +155,11 @@ class Hook(github.GithubObject.CompletableGithubObject): :param active: bool :rtype: None """ - assert isinstance(name, (str, unicode)), name + assert isinstance(name, (str, six.text_type)), name assert isinstance(config, dict), config - assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in events), events - assert add_events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in add_events), add_events - assert remove_events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in remove_events), remove_events + assert events is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in events), events + assert add_events is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in add_events), add_events + assert remove_events is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in remove_events), remove_events assert active is github.GithubObject.NotSet or isinstance(active, bool), active post_parameters = { "name": name, diff --git a/github/HookDescription.py b/github/HookDescription.py index d2f43063..0a971dc7 100644 --- a/github/HookDescription.py +++ b/github/HookDescription.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/HookResponse.py b/github/HookResponse.py index 72b02375..1a8172ba 100644 --- a/github/HookResponse.py +++ b/github/HookResponse.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/InputFileContent.py b/github/InputFileContent.py index b9e26e7e..33b6481e 100644 --- a/github/InputFileContent.py +++ b/github/InputFileContent.py @@ -28,7 +28,9 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject +import six class InputFileContent(object): @@ -42,8 +44,8 @@ class InputFileContent(object): :param new_name: string """ - assert isinstance(content, (str, unicode)), content - assert new_name is github.GithubObject.NotSet or isinstance(new_name, (str, unicode)), new_name + assert isinstance(content, (str, six.text_type)), content + assert new_name is github.GithubObject.NotSet or isinstance(new_name, (str, six.text_type)), new_name self.__newName = new_name self.__content = content diff --git a/github/InputGitAuthor.py b/github/InputGitAuthor.py index a5cd596b..667fd54c 100644 --- a/github/InputGitAuthor.py +++ b/github/InputGitAuthor.py @@ -30,7 +30,9 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject +import six class InputGitAuthor(object): @@ -45,9 +47,9 @@ class InputGitAuthor(object): :param date: string """ - assert isinstance(name, (str, unicode)), name - assert isinstance(email, (str, unicode)), email - assert date is github.GithubObject.NotSet or isinstance(date, (str, unicode)), date # @todo Datetime? + assert isinstance(name, (str, six.text_type)), name + assert isinstance(email, (str, six.text_type)), email + assert date is github.GithubObject.NotSet or isinstance(date, (str, six.text_type)), date # @todo Datetime? self.__name = name self.__email = email diff --git a/github/InputGitTreeElement.py b/github/InputGitTreeElement.py index 0fec87d7..78c354cc 100644 --- a/github/InputGitTreeElement.py +++ b/github/InputGitTreeElement.py @@ -28,7 +28,9 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject +import six class InputGitTreeElement(object): @@ -45,11 +47,11 @@ class InputGitTreeElement(object): :param sha: string """ - assert isinstance(path, (str, unicode)), path - assert isinstance(mode, (str, unicode)), mode - assert isinstance(type, (str, unicode)), type - assert content is github.GithubObject.NotSet or isinstance(content, (str, unicode)), content - assert sha is github.GithubObject.NotSet or isinstance(sha, (str, unicode)), sha + assert isinstance(path, (str, six.text_type)), path + assert isinstance(mode, (str, six.text_type)), mode + assert isinstance(type, (str, six.text_type)), type + assert content is github.GithubObject.NotSet or isinstance(content, (str, six.text_type)), content + assert sha is github.GithubObject.NotSet or isinstance(sha, (str, six.text_type)), sha self.__path = path self.__mode = mode self.__type = type diff --git a/github/Installation.py b/github/Installation.py index 79690d5f..7f6c36b6 100644 --- a/github/Installation.py +++ b/github/Installation.py @@ -25,6 +25,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.PaginatedList @@ -39,7 +40,7 @@ import github.Event import github.Authorization import github.Notification -import Consts +from . import Consts INTEGRATION_PREVIEW_HEADERS = {"Accept": Consts.mediaTypeIntegrationPreview} diff --git a/github/InstallationAuthorization.py b/github/InstallationAuthorization.py index d0a47313..d95fe0db 100644 --- a/github/InstallationAuthorization.py +++ b/github/InstallationAuthorization.py @@ -25,6 +25,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.PaginatedList import github.NamedUser diff --git a/github/Invitation.py b/github/Invitation.py index 6b66f388..cee0b5a4 100644 --- a/github/Invitation.py +++ b/github/Invitation.py @@ -24,6 +24,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Issue.py b/github/Issue.py index b1a40be4..cc8a482a 100644 --- a/github/Issue.py +++ b/github/Issue.py @@ -42,7 +42,8 @@ # # ################################################################################ -import urllib +from __future__ import absolute_import +import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error import datetime import github.GithubObject import github.PaginatedList @@ -56,7 +57,8 @@ import github.IssueComment import github.IssuePullRequest import github.Reaction -import Consts +from . import Consts +import six class Issue(github.GithubObject.CompletableGithubObject): @@ -280,7 +282,7 @@ class Issue(github.GithubObject.CompletableGithubObject): :param assignee: :class:`github.NamedUser.NamedUser` or string :rtype: None """ - assert all(isinstance(element, (github.NamedUser.NamedUser, str, unicode)) for element in assignees), assignees + assert all(isinstance(element, (github.NamedUser.NamedUser, str, six.text_type)) for element in assignees), assignees post_parameters = {"assignees": [assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees]} headers, data = self._requester.requestJsonAndCheck( "POST", @@ -295,7 +297,7 @@ class Issue(github.GithubObject.CompletableGithubObject): :param label: :class:`github.Label.Label` or string :rtype: None """ - assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels + assert all(isinstance(element, (github.Label.Label, str, six.text_type)) for element in labels), labels post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] headers, data = self._requester.requestJsonAndCheck( "POST", @@ -309,7 +311,7 @@ class Issue(github.GithubObject.CompletableGithubObject): :param body: string :rtype: :class:`github.IssueComment.IssueComment` """ - assert isinstance(body, (str, unicode)), body + assert isinstance(body, (str, six.text_type)), body post_parameters = { "body": body, } @@ -342,20 +344,20 @@ class Issue(github.GithubObject.CompletableGithubObject): :param labels: list of string :rtype: None """ - assert title is github.GithubObject.NotSet or isinstance(title, (str, unicode)), title - assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body - assert assignee is github.GithubObject.NotSet or assignee is None or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, unicode)), assignee - assert assignees is github.GithubObject.NotSet or all(isinstance(element, github.NamedUser.NamedUser) or isinstance(element, (str, unicode)) for element in assignees), assignees - assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state + assert title is github.GithubObject.NotSet or isinstance(title, (str, six.text_type)), title + assert body is github.GithubObject.NotSet or isinstance(body, (str, six.text_type)), body + assert assignee is github.GithubObject.NotSet or assignee is None or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, six.text_type)), assignee + assert assignees is github.GithubObject.NotSet or all(isinstance(element, github.NamedUser.NamedUser) or isinstance(element, (str, six.text_type)) for element in assignees), assignees + assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state assert milestone is github.GithubObject.NotSet or milestone is None or isinstance(milestone, github.Milestone.Milestone), milestone - assert labels is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in labels), labels + assert labels is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in labels), labels post_parameters = dict() if title is not github.GithubObject.NotSet: post_parameters["title"] = title if body is not github.GithubObject.NotSet: post_parameters["body"] = body if assignee is not github.GithubObject.NotSet: - if isinstance(assignee, (str, unicode)): + if isinstance(assignee, (str, six.text_type)): post_parameters["assignee"] = assignee else: post_parameters["assignee"] = assignee._identity if assignee else '' @@ -380,7 +382,7 @@ class Issue(github.GithubObject.CompletableGithubObject): :param lock_reason: string :rtype: None """ - assert isinstance(lock_reason, (str, unicode)), lock_reason + assert isinstance(lock_reason, (str, six.text_type)), lock_reason put_parameters = dict() put_parameters["lock_reason"] = lock_reason headers, data = self._requester.requestJsonAndCheck( @@ -406,7 +408,7 @@ class Issue(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.IssueComment.IssueComment` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", self._parentUrl(self.url) + "/comments/" + str(id) @@ -461,7 +463,7 @@ class Issue(github.GithubObject.CompletableGithubObject): :param assignee: :class:`github.NamedUser.NamedUser` or string :rtype: None """ - assert all(isinstance(element, (github.NamedUser.NamedUser, str, unicode)) for element in assignees), assignees + assert all(isinstance(element, (github.NamedUser.NamedUser, str, six.text_type)) for element in assignees), assignees post_parameters = {"assignees": [assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees]} headers, data = self._requester.requestJsonAndCheck( "DELETE", @@ -476,11 +478,11 @@ class Issue(github.GithubObject.CompletableGithubObject): :param label: :class:`github.Label.Label` or string :rtype: None """ - assert isinstance(label, (github.Label.Label, str, unicode)), label + assert isinstance(label, (github.Label.Label, str, six.text_type)), label if isinstance(label, github.Label.Label): label = label._identity else: - label = urllib.quote(label) + label = six.moves.urllib.parse.quote(label) headers, data = self._requester.requestJsonAndCheck( "DELETE", self.url + "/labels/" + label @@ -492,7 +494,7 @@ class Issue(github.GithubObject.CompletableGithubObject): :param labels: list of :class:`github.Label.Label` or strings :rtype: None """ - assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels + assert all(isinstance(element, (github.Label.Label, str, six.text_type)) for element in labels), labels post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] headers, data = self._requester.requestJsonAndCheck( "PUT", @@ -519,7 +521,7 @@ class Issue(github.GithubObject.CompletableGithubObject): :param reaction_type: string :rtype: :class:`github.Reaction.Reaction` """ - assert isinstance(reaction_type, (str, unicode)), "reaction type should be a string" + assert isinstance(reaction_type, (str, six.text_type)), "reaction type should be a string" assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \ "Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)" diff --git a/github/IssueComment.py b/github/IssueComment.py index dc689c5a..2e2c659f 100644 --- a/github/IssueComment.py +++ b/github/IssueComment.py @@ -33,10 +33,12 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser -import Consts +from . import Consts +import six class IssueComment(github.GithubObject.CompletableGithubObject): @@ -127,7 +129,7 @@ class IssueComment(github.GithubObject.CompletableGithubObject): :param body: string :rtype: None """ - assert isinstance(body, (str, unicode)), body + assert isinstance(body, (str, six.text_type)), body post_parameters = { "body": body, } @@ -159,7 +161,7 @@ class IssueComment(github.GithubObject.CompletableGithubObject): :param reaction_type: string :rtype: :class:`github.Reaction.Reaction` """ - assert isinstance(reaction_type, (str, unicode)), "reaction type should be a string" + assert isinstance(reaction_type, (str, six.text_type)), "reaction type should be a string" assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \ "Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)" diff --git a/github/IssueEvent.py b/github/IssueEvent.py index e746ae0e..e813d7f6 100644 --- a/github/IssueEvent.py +++ b/github/IssueEvent.py @@ -31,6 +31,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.Issue diff --git a/github/IssuePullRequest.py b/github/IssuePullRequest.py index f35f4da0..e3f637e0 100644 --- a/github/IssuePullRequest.py +++ b/github/IssuePullRequest.py @@ -29,6 +29,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Label.py b/github/Label.py index e2efac20..edffca7d 100644 --- a/github/Label.py +++ b/github/Label.py @@ -31,11 +31,13 @@ # # ################################################################################ -import urllib +from __future__ import absolute_import +import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error import github.GithubObject -import Consts +from . import Consts +import six class Label(github.GithubObject.CompletableGithubObject): @@ -96,9 +98,9 @@ class Label(github.GithubObject.CompletableGithubObject): :param description: string :rtype: None """ - assert isinstance(name, (str, unicode)), name - assert isinstance(color, (str, unicode)), color - assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description + assert isinstance(name, (str, six.text_type)), name + assert isinstance(color, (str, six.text_type)), color + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description post_parameters = { "name": name, "color": color, @@ -115,7 +117,7 @@ class Label(github.GithubObject.CompletableGithubObject): @property def _identity(self): - return urllib.quote(self.name) + return six.moves.urllib.parse.quote(self.name) def _initAttributes(self): self._color = github.GithubObject.NotSet diff --git a/github/Legacy.py b/github/Legacy.py index 23267d69..22fabc6e 100644 --- a/github/Legacy.py +++ b/github/Legacy.py @@ -29,9 +29,11 @@ # # ################################################################################ -import urlparse +from __future__ import absolute_import +import six.moves.urllib.parse import github.PaginatedList +import six class PaginatedList(github.PaginatedList.PaginatedListBase): @@ -55,7 +57,7 @@ class PaginatedList(github.PaginatedList.PaginatedListBase): return self.get_page(page) def get_page(self, page): - assert isinstance(page, (int, long)), page + assert isinstance(page, six.integer_types), page args = dict(self.__args) if page != 0: args["start_page"] = page + 1 @@ -133,7 +135,7 @@ def convertRepo(attributes): def convertIssue(attributes): convertedAttributes = { "number": attributes["number"], - "url": "/repos" + urlparse.urlparse(attributes["html_url"]).path, + "url": "/repos" + six.moves.urllib.parse.urlparse(attributes["html_url"]).path, "user": {"login": attributes["user"], "url": "/users/" + attributes["user"]}, } if "labels" in attributes: # pragma no branch diff --git a/github/License.py b/github/License.py index 31014942..b6f0b1a2 100644 --- a/github/License.py +++ b/github/License.py @@ -22,6 +22,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.PaginatedList diff --git a/github/MainClass.py b/github/MainClass.py index f41c2015..afdf9d46 100644 --- a/github/MainClass.py +++ b/github/MainClass.py @@ -48,6 +48,7 @@ # # ################################################################################ +from __future__ import absolute_import import datetime import pickle @@ -57,24 +58,25 @@ import requests import jwt import urllib3 -from Requester import Requester -import AuthenticatedUser -import NamedUser -import Gist +from .Requester import Requester +from . import AuthenticatedUser +from . import NamedUser +from . import Gist import github.PaginatedList -import Repository -import Installation -import License -import Topic +from . import Repository +from . import Installation +from . import License +from . import Topic import github.GithubObject -import HookDescription -import GitignoreTemplate -import RateLimit -import InstallationAuthorization -import GithubException -import Invitation +from . import HookDescription +from . import GitignoreTemplate +from . import RateLimit +from . import InstallationAuthorization +from . import GithubException +from . import Invitation -import Consts +from . import Consts +import six atLeastPython3 = sys.hexversion >= 0x03000000 @@ -106,14 +108,14 @@ class Github(object): :param retry: int or urllib3.util.retry.Retry object """ - assert login_or_token is None or isinstance(login_or_token, (str, unicode)), login_or_token - assert password is None or isinstance(password, (str, unicode)), password - assert jwt is None or isinstance(jwt, (str, unicode)), jwt - assert isinstance(base_url, (str, unicode)), base_url - assert isinstance(timeout, (int, long)), timeout - assert client_id is None or isinstance(client_id, (str, unicode)), client_id - assert client_secret is None or isinstance(client_secret, (str, unicode)), client_secret - assert user_agent is None or isinstance(user_agent, (str, unicode)), user_agent + assert login_or_token is None or isinstance(login_or_token, (str, six.text_type)), login_or_token + assert password is None or isinstance(password, (str, six.text_type)), password + assert jwt is None or isinstance(jwt, (str, six.text_type)), jwt + assert isinstance(base_url, (str, six.text_type)), base_url + assert isinstance(timeout, six.integer_types), timeout + assert client_id is None or isinstance(client_id, (str, six.text_type)), client_id + assert client_secret is None or isinstance(client_secret, (str, six.text_type)), client_secret + assert user_agent is None or isinstance(user_agent, (str, six.text_type)), user_agent assert isinstance(api_preview, (bool)) assert retry is None or isinstance(retry, (int)) or isinstance(retry, (urllib3.util.Retry)) self.__requester = Requester(login_or_token, password, jwt, base_url, timeout, client_id, client_secret, user_agent, per_page, api_preview, verify, retry) @@ -194,7 +196,7 @@ class Github(object): :rtype: :class:`github.License.License` """ - assert isinstance(key, (str, unicode)), key + assert isinstance(key, (str, six.text_type)), key headers, data = self.__requester.requestJsonAndCheck( "GET", "/licenses/" + key @@ -222,7 +224,7 @@ class Github(object): :param login: string :rtype: :class:`github.NamedUser.NamedUser` """ - assert login is github.GithubObject.NotSet or isinstance(login, (str, unicode)), login + assert login is github.GithubObject.NotSet or isinstance(login, (str, six.text_type)), login if login is github.GithubObject.NotSet: return AuthenticatedUser.AuthenticatedUser(self.__requester, {}, {"url": "/user"}, completed=False) else: @@ -238,7 +240,7 @@ class Github(object): :param since: integer :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ - assert since is github.GithubObject.NotSet or isinstance(since, (int, long)), since + assert since is github.GithubObject.NotSet or isinstance(since, six.integer_types), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since @@ -255,7 +257,7 @@ class Github(object): :param login: string :rtype: :class:`github.Organization.Organization` """ - assert isinstance(login, (str, unicode)), login + assert isinstance(login, (str, six.text_type)), login headers, data = self.__requester.requestJsonAndCheck( "GET", "/orgs/" + login @@ -268,7 +270,7 @@ class Github(object): :param since: integer :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Organization.Organization` """ - assert since is github.GithubObject.NotSet or isinstance(since, (int, long)), since + assert since is github.GithubObject.NotSet or isinstance(since, six.integer_types), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since @@ -284,8 +286,8 @@ class Github(object): :calls: `GET /repos/:owner/:repo `_ or `GET /repositories/:id `_ :rtype: :class:`github.Repository.Repository` """ - assert isinstance(full_name_or_id, (str, unicode, int, long)), full_name_or_id - url_base = "/repositories/" if isinstance(full_name_or_id, int) or isinstance(full_name_or_id, long) else "/repos/" + assert isinstance(full_name_or_id, (str, six.text_type, int, int)), full_name_or_id + url_base = "/repositories/" if isinstance(full_name_or_id, int) or isinstance(full_name_or_id, int) else "/repos/" url = "%s%s" % (url_base, full_name_or_id) if lazy: return Repository.Repository(self.__requester, {}, {"url": url}, completed=False) @@ -302,7 +304,7 @@ class Github(object): :param visibility: string ('all','public') :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ - assert since is github.GithubObject.NotSet or isinstance(since, (int, long)), since + assert since is github.GithubObject.NotSet or isinstance(since, six.integer_types), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since @@ -335,7 +337,7 @@ class Github(object): :param id: string :rtype: :class:`github.Gist.Gist` """ - assert isinstance(id, (str, unicode)), id + assert isinstance(id, (str, six.text_type)), id headers, data = self.__requester.requestJsonAndCheck( "GET", "/gists/" + id @@ -368,7 +370,7 @@ class Github(object): :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ - assert isinstance(query, (str, unicode)), query + assert isinstance(query, (str, six.text_type)), query url_parameters = dict() if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered) assert sort in ('stars', 'forks', 'updated'), sort @@ -403,7 +405,7 @@ class Github(object): :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ - assert isinstance(query, (str, unicode)), query + assert isinstance(query, (str, six.text_type)), query url_parameters = dict() if sort is not github.GithubObject.NotSet: assert sort in ('followers', 'repositories', 'joined'), sort @@ -438,7 +440,7 @@ class Github(object): :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` """ - assert isinstance(query, (str, unicode)), query + assert isinstance(query, (str, six.text_type)), query url_parameters = dict() if sort is not github.GithubObject.NotSet: assert sort in ('comments', 'created', 'updated'), sort @@ -474,7 +476,7 @@ class Github(object): :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ContentFile.ContentFile` """ - assert isinstance(query, (str, unicode)), query + assert isinstance(query, (str, six.text_type)), query url_parameters = dict() if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered) assert sort in ('indexed',), sort @@ -512,7 +514,7 @@ class Github(object): :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit` """ - assert isinstance(query, (str, unicode)), query + assert isinstance(query, (str, six.text_type)), query url_parameters = dict() if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered) assert sort in ('author-date', 'committer-date'), sort @@ -548,7 +550,7 @@ class Github(object): :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Topic.Topic` """ - assert isinstance(query, (str, unicode)), query + assert isinstance(query, (str, six.text_type)), query url_parameters = dict() query_chunks = [] @@ -578,7 +580,7 @@ class Github(object): :param context: :class:`github.Repository.Repository` :rtype: string """ - assert isinstance(text, (str, unicode)), text + assert isinstance(text, (str, six.text_type)), text assert context is github.GithubObject.NotSet or isinstance(context, github.Repository.Repository), context post_parameters = { "text": text @@ -599,7 +601,7 @@ class Github(object): :param name: string :rtype: :class:`github.HookDescription.HookDescription` """ - assert isinstance(name, (str, unicode)), name + assert isinstance(name, (str, six.text_type)), name headers, attributes = self.__requester.requestJsonAndCheck( "GET", "/hooks/" + name @@ -633,7 +635,7 @@ class Github(object): :calls: `GET /gitignore/templates/:name `_ :rtype: :class:`github.GitignoreTemplate.GitignoreTemplate` """ - assert isinstance(name, (str, unicode)), name + assert isinstance(name, (str, six.text_type)), name headers, attributes = self.__requester.requestJsonAndCheck( "GET", "/gitignore/templates/" + name @@ -707,7 +709,7 @@ class GithubIntegration(object): self.base_url = base_url self.integration_id = integration_id self.private_key = private_key - assert isinstance(base_url, (str, unicode)), base_url + assert isinstance(base_url, (str, six.text_type)), base_url def create_jwt(self, expiration=60): """ diff --git a/github/Migration.py b/github/Migration.py index fc14be6f..38f796c8 100644 --- a/github/Migration.py +++ b/github/Migration.py @@ -32,12 +32,14 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.PaginatedList import github.NamedUser -import Consts +from . import Consts +import six class Migration(github.GithubObject.CompletableGithubObject): @@ -176,7 +178,7 @@ class Migration(github.GithubObject.CompletableGithubObject): :param repo_name: str :rtype: None """ - assert isinstance(repo_name, (str, unicode)), repo_name + assert isinstance(repo_name, (str, six.text_type)), repo_name headers, data = self._requester.requestJsonAndCheck( "DELETE", self.url + "/repos/" + repo_name + "/lock", diff --git a/github/Milestone.py b/github/Milestone.py index 18d0e5ea..bd0343aa 100644 --- a/github/Milestone.py +++ b/github/Milestone.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import datetime import github.GithubObject @@ -37,6 +38,7 @@ import github.PaginatedList import github.NamedUser import github.Label +import six class Milestone(github.GithubObject.CompletableGithubObject): @@ -170,9 +172,9 @@ class Milestone(github.GithubObject.CompletableGithubObject): :param due_on: date :rtype: None """ - assert isinstance(title, (str, unicode)), title - assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state - assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description + assert isinstance(title, (str, six.text_type)), title + assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description assert due_on is github.GithubObject.NotSet or isinstance(due_on, datetime.date), due_on post_parameters = { "title": title, diff --git a/github/NamedUser.py b/github/NamedUser.py index 8286859f..0fd2b50c 100644 --- a/github/NamedUser.py +++ b/github/NamedUser.py @@ -37,6 +37,7 @@ # # ################################################################################ +from __future__ import absolute_import import datetime import github.GithubObject @@ -49,6 +50,7 @@ import github.Permissions import github.Plan import github.Organization import github.Event +import six class NamedUser(github.GithubObject.CompletableGithubObject): @@ -536,7 +538,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject): :param name: string :rtype: :class:`github.Repository.Repository` """ - assert isinstance(name, (str, unicode)), name + assert isinstance(name, (str, six.text_type)), name headers, data = self._requester.requestJsonAndCheck( "GET", "/repos/" + self.login + "/" + name @@ -552,9 +554,9 @@ class NamedUser(github.GithubObject.CompletableGithubObject): :param direction: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ - assert type is github.GithubObject.NotSet or isinstance(type, (str, unicode)), type - assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort - assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction + assert type is github.GithubObject.NotSet or isinstance(type, (str, six.text_type)), type + assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort + assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction url_parameters = dict() if type is not github.GithubObject.NotSet: url_parameters["type"] = type diff --git a/github/Notification.py b/github/Notification.py index b62d75f6..72947ac0 100644 --- a/github/Notification.py +++ b/github/Notification.py @@ -29,6 +29,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.Repository diff --git a/github/NotificationSubject.py b/github/NotificationSubject.py index e970a171..46b70ff1 100644 --- a/github/NotificationSubject.py +++ b/github/NotificationSubject.py @@ -28,6 +28,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Organization.py b/github/Organization.py index 258938ac..e9daa8af 100644 --- a/github/Organization.py +++ b/github/Organization.py @@ -41,6 +41,7 @@ # # ################################################################################ +from __future__ import absolute_import import datetime import github.GithubObject @@ -53,7 +54,8 @@ import github.Repository import github.Project import github.NamedUser -import Consts +from . import Consts +import six class Organization(github.GithubObject.CompletableGithubObject): @@ -319,7 +321,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :param role: string :rtype: None """ - assert role is github.GithubObject.NotSet or isinstance(role, (str, unicode)), role + assert role is github.GithubObject.NotSet or isinstance(role, (str, six.text_type)), role assert isinstance(member, github.NamedUser.NamedUser), member put_parameters = {} if role is not github.GithubObject.NotSet: @@ -367,9 +369,9 @@ class Organization(github.GithubObject.CompletableGithubObject): :param active: bool :rtype: :class:`github.Hook.Hook` """ - assert isinstance(name, (str, unicode)), name + assert isinstance(name, (str, six.text_type)), name assert isinstance(config, dict), config - assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in events), events + assert events is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in events), events assert active is github.GithubObject.NotSet or isinstance(active, bool), active post_parameters = { "name": name, @@ -412,18 +414,18 @@ class Organization(github.GithubObject.CompletableGithubObject): :param allow_rebase_merge: bool :rtype: :class:`github.Repository.Repository` """ - assert isinstance(name, (str, unicode)), name - assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description - assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, unicode)), homepage + assert isinstance(name, (str, six.text_type)), name + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description + assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, six.text_type)), homepage assert private is github.GithubObject.NotSet or isinstance(private, bool), private assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects - assert team_id is github.GithubObject.NotSet or isinstance(team_id, (int, long)), team_id + assert team_id is github.GithubObject.NotSet or isinstance(team_id, six.integer_types), team_id assert auto_init is github.GithubObject.NotSet or isinstance(auto_init, bool), auto_init - assert license_template is github.GithubObject.NotSet or isinstance(license_template, (str, unicode)), license_template - assert gitignore_template is github.GithubObject.NotSet or isinstance(gitignore_template, (str, unicode)), gitignore_template + assert license_template is github.GithubObject.NotSet or isinstance(license_template, (str, six.text_type)), license_template + assert gitignore_template is github.GithubObject.NotSet or isinstance(gitignore_template, (str, six.text_type)), gitignore_template assert allow_squash_merge is github.GithubObject.NotSet or isinstance(allow_squash_merge, bool), allow_squash_merge assert allow_merge_commit is github.GithubObject.NotSet or isinstance(allow_merge_commit, bool), allow_merge_commit assert allow_rebase_merge is github.GithubObject.NotSet or isinstance(allow_rebase_merge, bool), allow_rebase_merge @@ -475,11 +477,11 @@ class Organization(github.GithubObject.CompletableGithubObject): :param description: string :rtype: :class:`github.Team.Team` """ - assert isinstance(name, (str, unicode)), name + assert isinstance(name, (str, six.text_type)), name assert repo_names is github.GithubObject.NotSet or all(isinstance(element, github.Repository.Repository) for element in repo_names), repo_names - assert permission is github.GithubObject.NotSet or isinstance(permission, (str, unicode)), permission - assert privacy is github.GithubObject.NotSet or isinstance(privacy, (str, unicode)), privacy - assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description + assert permission is github.GithubObject.NotSet or isinstance(permission, (str, six.text_type)), permission + assert privacy is github.GithubObject.NotSet or isinstance(privacy, (str, six.text_type)), privacy + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description post_parameters = { "name": name, } @@ -504,7 +506,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: None` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "DELETE", self.url + "/hooks/" + str(id) @@ -522,13 +524,13 @@ class Organization(github.GithubObject.CompletableGithubObject): :param name: string :rtype: None """ - assert billing_email is github.GithubObject.NotSet or isinstance(billing_email, (str, unicode)), billing_email - assert blog is github.GithubObject.NotSet or isinstance(blog, (str, unicode)), blog - assert company is github.GithubObject.NotSet or isinstance(company, (str, unicode)), company - assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description - assert email is github.GithubObject.NotSet or isinstance(email, (str, unicode)), email - assert location is github.GithubObject.NotSet or isinstance(location, (str, unicode)), location - assert name is github.GithubObject.NotSet or isinstance(name, (str, unicode)), name + assert billing_email is github.GithubObject.NotSet or isinstance(billing_email, (str, six.text_type)), billing_email + assert blog is github.GithubObject.NotSet or isinstance(blog, (str, six.text_type)), blog + assert company is github.GithubObject.NotSet or isinstance(company, (str, six.text_type)), company + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description + assert email is github.GithubObject.NotSet or isinstance(email, (str, six.text_type)), email + assert location is github.GithubObject.NotSet or isinstance(location, (str, six.text_type)), location + assert name is github.GithubObject.NotSet or isinstance(name, (str, six.text_type)), name post_parameters = dict() if billing_email is not github.GithubObject.NotSet: post_parameters["billing_email"] = billing_email @@ -561,10 +563,10 @@ class Organization(github.GithubObject.CompletableGithubObject): :param active: bool :rtype: :class:`github.Hook.Hook` """ - assert isinstance(id, (int, long)), id - assert isinstance(name, (str, unicode)), name + assert isinstance(id, six.integer_types), id + assert isinstance(name, (str, six.text_type)), name assert isinstance(config, dict), config - assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in events), events + assert events is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in events), events assert active is github.GithubObject.NotSet or isinstance(active, bool), active post_parameters = { "name": name, @@ -599,7 +601,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.Hook.Hook` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/hooks/" + str(id) @@ -630,11 +632,11 @@ class Organization(github.GithubObject.CompletableGithubObject): :param since: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` """ - assert filter is github.GithubObject.NotSet or isinstance(filter, (str, unicode)), filter - assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state + assert filter is github.GithubObject.NotSet or isinstance(filter, (str, six.text_type)), filter + assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) for element in labels), labels - assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort - assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction + assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort + assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since url_parameters = dict() if filter is not github.GithubObject.NotSet: @@ -665,9 +667,9 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ assert (filter_ is github.GithubObject.NotSet or - isinstance(filter_, (str, unicode))), filter_ + isinstance(filter_, (str, six.text_type))), filter_ assert (role is github.GithubObject.NotSet or - isinstance(role, (str, unicode))), role + isinstance(role, (str, six.text_type))), role url_parameters = {} if filter_ is not github.GithubObject.NotSet: @@ -719,7 +721,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ assert (filter_ is github.GithubObject.NotSet or - isinstance(filter_, (str, unicode))), filter_ + isinstance(filter_, (str, six.text_type))), filter_ url_parameters = {} if filter_ is not github.GithubObject.NotSet: @@ -761,7 +763,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :param name: string :rtype: :class:`github.Repository.Repository` """ - assert isinstance(name, (str, unicode)), name + assert isinstance(name, (str, six.text_type)), name headers, data = self._requester.requestJsonAndCheck( "GET", "/repos/" + self.login + "/" + name @@ -776,9 +778,9 @@ class Organization(github.GithubObject.CompletableGithubObject): :param direction: string ('asc', desc') :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ - assert type is github.GithubObject.NotSet or isinstance(type, (str, unicode)), type - assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort - assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction + assert type is github.GithubObject.NotSet or isinstance(type, (str, six.text_type)), type + assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort + assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction url_parameters = dict() if type is not github.GithubObject.NotSet: @@ -800,7 +802,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.Team.Team` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", "/teams/" + str(id) @@ -813,7 +815,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :param slug: string :rtype: :class:`github.Team.Team` """ - assert isinstance(slug, (str, unicode)), slug + assert isinstance(slug, (str, six.text_type)), slug headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/teams/" + slug @@ -857,7 +859,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: None """ assert user is github.GithubObject.NotSet or isinstance(user, github.NamedUser.NamedUser), user - assert email is github.GithubObject.NotSet or isinstance(email, (str, unicode)), email + assert email is github.GithubObject.NotSet or isinstance(email, (str, six.text_type)), email assert (email is github.GithubObject.NotSet) ^ (user is github.GithubObject.NotSet), "specify only one of email or user" parameters = {} if user is not github.GithubObject.NotSet: @@ -865,7 +867,7 @@ class Organization(github.GithubObject.CompletableGithubObject): elif email is not github.GithubObject.NotSet: parameters["email"] = email if role is not github.GithubObject.NotSet: - assert isinstance(role, (str, unicode)), role + assert isinstance(role, (str, six.text_type)), role assert role in ['admin', 'direct_member', 'billing_manager'] parameters["role"] = role if teams is not github.GithubObject.NotSet: @@ -954,7 +956,7 @@ class Organization(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.Migration.Migration` """ assert isinstance(repos, (list, tuple)), repos - assert all(isinstance(repo, (str, unicode)) for repo in repos), repos + assert all(isinstance(repo, (str, six.text_type)) for repo in repos), repos assert lock_repositories is github.GithubObject.NotSet or isinstance(lock_repositories, bool), lock_repositories assert exclude_attachments is github.GithubObject.NotSet or isinstance(exclude_attachments, bool), exclude_attachments post_parameters = { diff --git a/github/PaginatedList.py b/github/PaginatedList.py index 20c2ddf8..14d148b1 100644 --- a/github/PaginatedList.py +++ b/github/PaginatedList.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import +import six # -*- coding: utf-8 -*- ############################ Copyrights and license ############################ @@ -40,7 +42,7 @@ try: from urllib.parse import parse_qs except ImportError: - from urlparse import parse_qs + from six.moves.urllib.parse import parse_qs class PaginatedListBase: @@ -49,7 +51,7 @@ class PaginatedListBase: def __getitem__(self, index): assert isinstance(index, (int, slice)) - if isinstance(index, (int, long)): + if isinstance(index, six.integer_types): self.__fetchToIndex(index) return self.__elements[index] else: diff --git a/github/Path.py b/github/Path.py index 615c0da1..7843b9f7 100644 --- a/github/Path.py +++ b/github/Path.py @@ -26,6 +26,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Permissions.py b/github/Permissions.py index 1438ee47..4a298e90 100644 --- a/github/Permissions.py +++ b/github/Permissions.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Plan.py b/github/Plan.py index a740afbb..22377bdb 100644 --- a/github/Plan.py +++ b/github/Plan.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Project.py b/github/Project.py index e5653dc6..cdbe9f96 100644 --- a/github/Project.py +++ b/github/Project.py @@ -22,10 +22,12 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.ProjectColumn -import Consts +from . import Consts +import six class Project(github.GithubObject.CompletableGithubObject): @@ -159,7 +161,7 @@ class Project(github.GithubObject.CompletableGithubObject): calls: `POST https://developer.github.com/v3/projects/columns/#create-a-project-column>`_ :param name: string """ - assert isinstance(name, (str, unicode)), name + assert isinstance(name, (str, six.text_type)), name post_parameters = {"name": name} import_header = {"Accept": Consts.mediaTypeProjectsPreview} headers, data = self._requester.requestJsonAndCheck( diff --git a/github/ProjectCard.py b/github/ProjectCard.py index 8b52f2c9..52d1e5a5 100644 --- a/github/ProjectCard.py +++ b/github/ProjectCard.py @@ -22,6 +22,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject # NOTE: There is currently no way to get cards "in triage" for a project. diff --git a/github/ProjectColumn.py b/github/ProjectColumn.py index 41a9658a..816b3fd9 100644 --- a/github/ProjectColumn.py +++ b/github/ProjectColumn.py @@ -22,11 +22,13 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.Project import github.ProjectCard -import Consts +from . import Consts +import six class ProjectColumn(github.GithubObject.CompletableGithubObject): @@ -99,7 +101,7 @@ class ProjectColumn(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ProjectCard.ProjectCard` :param archived_state: string """ - assert archived_state is github.GithubObject.NotSet or isinstance(archived_state, (str, unicode)), archived_state + assert archived_state is github.GithubObject.NotSet or isinstance(archived_state, (str, six.text_type)), archived_state url_parameters = dict() if archived_state is not github.GithubObject.NotSet: @@ -123,14 +125,14 @@ class ProjectColumn(github.GithubObject.CompletableGithubObject): :param content_type: string """ post_parameters = {} - if isinstance(note, (str, unicode)): + if isinstance(note, (str, six.text_type)): assert content_id is github.GithubObject.NotSet, content_id assert content_type is github.GithubObject.NotSet, content_type post_parameters = {"note": note} else: assert note is github.GithubObject.NotSet, note assert isinstance(content_id, int), content_id - assert isinstance(content_type, (str, unicode)), content_type + assert isinstance(content_type, (str, six.text_type)), content_type post_parameters = {"content_id": content_id, "content_type": content_type} diff --git a/github/PullRequest.py b/github/PullRequest.py index 82073b31..590fc07f 100644 --- a/github/PullRequest.py +++ b/github/PullRequest.py @@ -42,8 +42,9 @@ # # ################################################################################ +from __future__ import absolute_import import datetime -import urllib +import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error import github.GithubObject import github.PaginatedList @@ -56,7 +57,8 @@ import github.IssueComment import github.Commit import github.PullRequestReview -import Consts +from . import Consts +import six class PullRequest(github.GithubObject.CompletableGithubObject): @@ -386,10 +388,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param position: integer :rtype: :class:`github.PullRequestComment.PullRequestComment` """ - assert isinstance(body, (str, unicode)), body + assert isinstance(body, (str, six.text_type)), body assert isinstance(commit_id, github.Commit.Commit), commit_id - assert isinstance(path, (str, unicode)), path - assert isinstance(position, (int, long)), position + assert isinstance(path, (str, six.text_type)), path + assert isinstance(position, six.integer_types), position post_parameters = { "body": body, "commit_id": commit_id._identity, @@ -409,7 +411,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param body: string :rtype: :class:`github.IssueComment.IssueComment` """ - assert isinstance(body, (str, unicode)), body + assert isinstance(body, (str, six.text_type)), body post_parameters = { "body": body, } @@ -459,10 +461,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject): """ post_parameters = dict() if reviewers is not github.GithubObject.NotSet: - assert all(isinstance(element, (str, unicode)) for element in reviewers), reviewers + assert all(isinstance(element, (str, six.text_type)) for element in reviewers), reviewers post_parameters["reviewers"] = reviewers if team_reviewers is not github.GithubObject.NotSet: - assert all(isinstance(element, (str, unicode)) for element in team_reviewers), team_reviewers + assert all(isinstance(element, (str, six.text_type)) for element in team_reviewers), team_reviewers post_parameters["team_reviewers"] = team_reviewers headers, data = self._requester.requestJsonAndCheck( "POST", @@ -479,10 +481,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject): """ post_parameters = dict() if reviewers is not github.GithubObject.NotSet: - assert all(isinstance(element, (str, unicode)) for element in reviewers), reviewers + assert all(isinstance(element, (str, six.text_type)) for element in reviewers), reviewers post_parameters["reviewers"] = reviewers if team_reviewers is not github.GithubObject.NotSet: - assert all(isinstance(element, (str, unicode)) for element in team_reviewers), team_reviewers + assert all(isinstance(element, (str, six.text_type)) for element in team_reviewers), team_reviewers post_parameters["team_reviewers"] = team_reviewers headers, data = self._requester.requestJsonAndCheck( "DELETE", @@ -499,10 +501,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param base: string :rtype: None """ - assert title is github.GithubObject.NotSet or isinstance(title, (str, unicode)), title - assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body - assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state - assert base is github.GithubObject.NotSet or isinstance(base, (str, unicode)), base + assert title is github.GithubObject.NotSet or isinstance(title, (str, six.text_type)), title + assert body is github.GithubObject.NotSet or isinstance(body, (str, six.text_type)), body + assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state + assert base is github.GithubObject.NotSet or isinstance(base, (str, six.text_type)), base post_parameters = dict() if title is not github.GithubObject.NotSet: post_parameters["title"] = title @@ -533,7 +535,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.PullRequestComment.PullRequestComment` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", self._parentUrl(self.url) + "/comments/" + str(id) @@ -572,7 +574,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id return github.PaginatedList.PaginatedList( github.PullRequestComment.PullRequestComment, self._requester, @@ -610,7 +612,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.IssueComment.IssueComment` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", self._parentUrl(self.issue_url) + "/comments/" + str(id) @@ -648,7 +650,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.PullRequestReview.PullRequestReview` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/reviews/" + str(id), @@ -707,7 +709,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param label: :class:`github.Label.Label` or string :rtype: None """ - assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels + assert all(isinstance(element, (github.Label.Label, str, six.text_type)) for element in labels), labels post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] headers, data = self._requester.requestJsonAndCheck( "POST", @@ -731,11 +733,11 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param label: :class:`github.Label.Label` or string :rtype: None """ - assert isinstance(label, (github.Label.Label, str, unicode)), label + assert isinstance(label, (github.Label.Label, str, six.text_type)), label if isinstance(label, github.Label.Label): label = label._identity else: - label = urllib.quote(label) + label = six.moves.urllib.parse.quote(label) headers, data = self._requester.requestJsonAndCheck( "DELETE", self.issue_url + "/labels/" + label @@ -747,7 +749,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param labels: list of :class:`github.Label.Label` or strings :rtype: None """ - assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels + assert all(isinstance(element, (github.Label.Label, str, six.text_type)) for element in labels), labels post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] headers, data = self._requester.requestJsonAndCheck( "PUT", @@ -772,10 +774,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param commit_message: string :rtype: :class:`github.PullRequestMergeStatus.PullRequestMergeStatus` """ - assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, (str, unicode)), commit_message - assert commit_title is github.GithubObject.NotSet or isinstance(commit_title, (str, unicode)), commit_title - assert merge_method is github.GithubObject.NotSet or isinstance(merge_method, (str, unicode)), merge_method - assert sha is github.GithubObject.NotSet or isinstance(sha, (str, unicode)), sha + assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, (str, six.text_type)), commit_message + assert commit_title is github.GithubObject.NotSet or isinstance(commit_title, (str, six.text_type)), commit_title + assert merge_method is github.GithubObject.NotSet or isinstance(merge_method, (str, six.text_type)), merge_method + assert sha is github.GithubObject.NotSet or isinstance(sha, (str, six.text_type)), sha post_parameters = dict() if commit_message is not github.GithubObject.NotSet: post_parameters["commit_message"] = commit_message diff --git a/github/PullRequestComment.py b/github/PullRequestComment.py index e8636114..edd4a54e 100644 --- a/github/PullRequestComment.py +++ b/github/PullRequestComment.py @@ -34,10 +34,12 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser -import Consts +from . import Consts +import six class PullRequestComment(github.GithubObject.CompletableGithubObject): @@ -184,7 +186,7 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject): :param body: string :rtype: None """ - assert isinstance(body, (str, unicode)), body + assert isinstance(body, (str, six.text_type)), body post_parameters = { "body": body, } @@ -216,7 +218,7 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject): :param reaction_type: string :rtype: :class:`github.Reaction.Reaction` """ - assert isinstance(reaction_type, (str, unicode)), "reaction type should be a string" + assert isinstance(reaction_type, (str, six.text_type)), "reaction type should be a string" assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \ "Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)" diff --git a/github/PullRequestMergeStatus.py b/github/PullRequestMergeStatus.py index add34390..5cf0a53f 100644 --- a/github/PullRequestMergeStatus.py +++ b/github/PullRequestMergeStatus.py @@ -31,6 +31,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/PullRequestPart.py b/github/PullRequestPart.py index e68ba151..3e4a4da1 100644 --- a/github/PullRequestPart.py +++ b/github/PullRequestPart.py @@ -30,6 +30,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.Repository diff --git a/github/PullRequestReview.py b/github/PullRequestReview.py index afde6f6a..d48b3b1e 100644 --- a/github/PullRequestReview.py +++ b/github/PullRequestReview.py @@ -26,9 +26,11 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser +import six class PullRequestReview(github.GithubObject.CompletableGithubObject): @@ -116,7 +118,7 @@ class PullRequestReview(github.GithubObject.CompletableGithubObject): :calls: `PUT /repos/:owner/:repo/pulls/:number/reviews/:review_id/dismissals `_ :rtype: None """ - assert isinstance(message, (str, unicode)), message + assert isinstance(message, (str, six.text_type)), message post_parameters = {'message': message} headers, data = self._requester.requestJsonAndCheck( "PUT", diff --git a/github/Rate.py b/github/Rate.py index e9fbe500..22ed3e8d 100644 --- a/github/Rate.py +++ b/github/Rate.py @@ -27,6 +27,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/RateLimit.py b/github/RateLimit.py index 8fc78e40..68d928fb 100644 --- a/github/RateLimit.py +++ b/github/RateLimit.py @@ -27,6 +27,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.Rate diff --git a/github/Reaction.py b/github/Reaction.py index 994ef755..2f916e2d 100644 --- a/github/Reaction.py +++ b/github/Reaction.py @@ -24,10 +24,11 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser -import Consts +from . import Consts class Reaction(github.GithubObject.CompletableGithubObject): diff --git a/github/Referrer.py b/github/Referrer.py index eb14931b..9a03dd9e 100644 --- a/github/Referrer.py +++ b/github/Referrer.py @@ -26,6 +26,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Repository.py b/github/Repository.py index f8fb9ee8..e2e1291f 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -85,8 +85,9 @@ # # ################################################################################ +from __future__ import absolute_import import sys -import urllib +import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error import datetime from base64 import b64encode @@ -134,7 +135,8 @@ import github.Path import github.Clones import github.View -import Consts +from . import Consts +import six atLeastPython3 = sys.hexversion >= 0x03000000 @@ -778,8 +780,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :param permission: string 'pull', 'push' or 'admin' :rtype: None """ - assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, unicode)), collaborator - assert permission is github.GithubObject.NotSet or isinstance(permission, (str, unicode)), permission + assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, six.text_type)), collaborator + assert permission is github.GithubObject.NotSet or isinstance(permission, (str, six.text_type)), permission if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity @@ -805,7 +807,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param collaborator: string or :class:`github.NamedUser.NamedUser` :rtype: string """ - assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, unicode)), collaborator + assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, six.text_type)), collaborator if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity headers, data = self._requester.requestJsonAndCheck( @@ -845,8 +847,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :param head: string :rtype: :class:`github.Comparison.Comparison` """ - assert isinstance(base, (str, unicode)), base - assert isinstance(head, (str, unicode)), head + assert isinstance(base, (str, six.text_type)), base + assert isinstance(head, (str, six.text_type)), head headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/compare/" + base + "..." + head @@ -860,8 +862,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :param encoding: string :rtype: :class:`github.GitBlob.GitBlob` """ - assert isinstance(content, (str, unicode)), content - assert isinstance(encoding, (str, unicode)), encoding + assert isinstance(content, (str, six.text_type)), content + assert isinstance(encoding, (str, six.text_type)), encoding post_parameters = { "content": content, "encoding": encoding, @@ -883,7 +885,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param committer: :class:`github.InputGitAuthor.InputGitAuthor` :rtype: :class:`github.GitCommit.GitCommit` """ - assert isinstance(message, (str, unicode)), message + assert isinstance(message, (str, six.text_type)), message assert isinstance(tree, github.GitTree.GitTree), tree assert all(isinstance(element, github.GitCommit.GitCommit) for element in parents), parents assert author is github.GithubObject.NotSet or isinstance(author, github.InputGitAuthor), author @@ -911,8 +913,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :param sha: string :rtype: :class:`github.GitRef.GitRef` """ - assert isinstance(ref, (str, unicode)), ref - assert isinstance(sha, (str, unicode)), sha + assert isinstance(ref, (str, six.text_type)), ref + assert isinstance(sha, (str, six.text_type)), sha post_parameters = { "ref": ref, "sha": sha, @@ -939,12 +941,12 @@ class Repository(github.GithubObject.CompletableGithubObject): :param target_commitish: string or :class:`github.Branch.Branch` or :class:`github.Commit.Commit` or :class:`github.GitCommit.GitCommit` :rtype: :class:`github.GitRelease.GitRelease` """ - assert isinstance(tag, (str, unicode)), tag - assert isinstance(name, (str, unicode)), name - assert isinstance(message, (str, unicode)), message + assert isinstance(tag, (str, six.text_type)), tag + assert isinstance(name, (str, six.text_type)), name + assert isinstance(message, (str, six.text_type)), message assert isinstance(draft, bool), draft assert isinstance(prerelease, bool), prerelease - assert target_commitish is github.GithubObject.NotSet or isinstance(target_commitish, (str, unicode, github.Branch.Branch, github.Commit.Commit, github.GitCommit.GitCommit)), target_commitish + assert target_commitish is github.GithubObject.NotSet or isinstance(target_commitish, (str, six.text_type, github.Branch.Branch, github.Commit.Commit, github.GitCommit.GitCommit)), target_commitish post_parameters = { "tag_name": tag, "name": name, @@ -952,7 +954,7 @@ class Repository(github.GithubObject.CompletableGithubObject): "draft": draft, "prerelease": prerelease, } - if isinstance(target_commitish, (str, unicode)): + if isinstance(target_commitish, (str, six.text_type)): post_parameters["target_commitish"] = target_commitish elif isinstance(target_commitish, github.Branch.Branch): post_parameters["target_commitish"] = target_commitish.name @@ -975,10 +977,10 @@ class Repository(github.GithubObject.CompletableGithubObject): :param tagger: :class:`github.InputGitAuthor.InputGitAuthor` :rtype: :class:`github.GitTag.GitTag` """ - assert isinstance(tag, (str, unicode)), tag - assert isinstance(message, (str, unicode)), message - assert isinstance(object, (str, unicode)), object - assert isinstance(type, (str, unicode)), type + assert isinstance(tag, (str, six.text_type)), tag + assert isinstance(message, (str, six.text_type)), message + assert isinstance(object, (str, six.text_type)), object + assert isinstance(type, (str, six.text_type)), type assert tagger is github.GithubObject.NotSet or isinstance(tagger, github.InputGitAuthor), tagger post_parameters = { "tag": tag, @@ -1025,9 +1027,9 @@ class Repository(github.GithubObject.CompletableGithubObject): :param active: bool :rtype: :class:`github.Hook.Hook` """ - assert isinstance(name, (str, unicode)), name + assert isinstance(name, (str, six.text_type)), name assert isinstance(config, dict), config - assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in events), events + assert events is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in events), events assert active is github.GithubObject.NotSet or isinstance(active, bool), active post_parameters = { "name": name, @@ -1055,12 +1057,12 @@ class Repository(github.GithubObject.CompletableGithubObject): :param labels: list of :class:`github.Label.Label` :rtype: :class:`github.Issue.Issue` """ - assert isinstance(title, (str, unicode)), title - assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body - assert assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, unicode)), assignee - assert assignees is github.GithubObject.NotSet or all(isinstance(element, github.NamedUser.NamedUser) or isinstance(element, (str, unicode)) for element in assignees), assignees + assert isinstance(title, (str, six.text_type)), title + assert body is github.GithubObject.NotSet or isinstance(body, (str, six.text_type)), body + assert assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, six.text_type)), assignee + assert assignees is github.GithubObject.NotSet or all(isinstance(element, github.NamedUser.NamedUser) or isinstance(element, (str, six.text_type)) for element in assignees), assignees assert milestone is github.GithubObject.NotSet or isinstance(milestone, github.Milestone.Milestone), milestone - assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) or isinstance(element, (str, unicode)) for element in labels), labels + assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) or isinstance(element, (str, six.text_type)) for element in labels), labels post_parameters = { "title": title, @@ -1068,7 +1070,7 @@ class Repository(github.GithubObject.CompletableGithubObject): if body is not github.GithubObject.NotSet: post_parameters["body"] = body if assignee is not github.GithubObject.NotSet: - if isinstance(assignee, (str, unicode)): + if isinstance(assignee, (str, six.text_type)): post_parameters["assignee"] = assignee else: post_parameters["assignee"] = assignee._identity @@ -1093,8 +1095,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :param read_only: bool :rtype: :class:`github.RepositoryKey.RepositoryKey` """ - assert isinstance(title, (str, unicode)), title - assert isinstance(key, (str, unicode)), key + assert isinstance(title, (str, six.text_type)), title + assert isinstance(key, (str, six.text_type)), key assert isinstance(read_only, bool), read_only post_parameters = { "title": title, @@ -1116,9 +1118,9 @@ class Repository(github.GithubObject.CompletableGithubObject): :param description: string :rtype: :class:`github.Label.Label` """ - assert isinstance(name, (str, unicode)), name - assert isinstance(color, (str, unicode)), color - assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description + assert isinstance(name, (str, six.text_type)), name + assert isinstance(color, (str, six.text_type)), color + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description post_parameters = { "name": name, "color": color, @@ -1142,9 +1144,9 @@ class Repository(github.GithubObject.CompletableGithubObject): :param due_on: datetime :rtype: :class:`github.Milestone.Milestone` """ - assert isinstance(title, (str, unicode)), title - assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state - assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description + assert isinstance(title, (str, six.text_type)), title + assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description assert due_on is github.GithubObject.NotSet or isinstance(due_on, (datetime.datetime, datetime.date)), due_on post_parameters = { "title": title, @@ -1171,8 +1173,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :param name: string :param body: string """ - assert isinstance(name, (str, unicode)), name - assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body + assert isinstance(name, (str, six.text_type)), name + assert body is github.GithubObject.NotSet or isinstance(body, (str, six.text_type)), body post_parameters = { "name": name, "body": body, @@ -1205,10 +1207,10 @@ class Repository(github.GithubObject.CompletableGithubObject): return self.__create_pull_2(*args, **kwds) def __create_pull_1(self, title, body, base, head, maintainer_can_modify=github.GithubObject.NotSet): - assert isinstance(title, (str, unicode)), title - assert isinstance(body, (str, unicode)), body - assert isinstance(base, (str, unicode)), base - assert isinstance(head, (str, unicode)), head + assert isinstance(title, (str, six.text_type)), title + assert isinstance(body, (str, six.text_type)), body + assert isinstance(base, (str, six.text_type)), base + assert isinstance(head, (str, six.text_type)), head assert maintainer_can_modify is github.GithubObject.NotSet or isinstance(maintainer_can_modify, bool), maintainer_can_modify if maintainer_can_modify is not github.GithubObject.NotSet: return self.__create_pull(title=title, body=body, base=base, head=head, maintainer_can_modify=maintainer_can_modify) @@ -1217,8 +1219,8 @@ class Repository(github.GithubObject.CompletableGithubObject): def __create_pull_2(self, issue, base, head): assert isinstance(issue, github.Issue.Issue), issue - assert isinstance(base, (str, unicode)), base - assert isinstance(head, (str, unicode)), head + assert isinstance(base, (str, six.text_type)), base + assert isinstance(head, (str, six.text_type)), head return self.__create_pull(issue=issue._identity, base=base, head=head) def __create_pull(self, **kwds): @@ -1239,10 +1241,10 @@ class Repository(github.GithubObject.CompletableGithubObject): :param vcs_password: string :rtype: :class:`github.SourceImport.SourceImport` """ - assert isinstance(vcs, (str, unicode)), vcs - assert isinstance(vcs_url, (str, unicode)), vcs_url - assert vcs_username is github.GithubObject.NotSet or isinstance(vcs_username, (str, unicode)), vcs_username - assert vcs_password is github.GithubObject.NotSet or isinstance(vcs_password, (str, unicode)), vcs_password + assert isinstance(vcs, (str, six.text_type)), vcs + assert isinstance(vcs_url, (str, six.text_type)), vcs_url + assert vcs_username is github.GithubObject.NotSet or isinstance(vcs_username, (str, six.text_type)), vcs_username + assert vcs_password is github.GithubObject.NotSet or isinstance(vcs_password, (str, six.text_type)), vcs_password put_parameters = { "vcs": vcs, "vcs_url": vcs_url @@ -1295,15 +1297,15 @@ class Repository(github.GithubObject.CompletableGithubObject): """ if name is None: name = self.name - assert isinstance(name, (str, unicode)), name - assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description - assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, unicode)), homepage + assert isinstance(name, (str, six.text_type)), name + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description + assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, six.text_type)), homepage assert private is github.GithubObject.NotSet or isinstance(private, bool), private assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads - assert default_branch is github.GithubObject.NotSet or isinstance(default_branch, (str, unicode)), default_branch + assert default_branch is github.GithubObject.NotSet or isinstance(default_branch, (str, six.text_type)), default_branch assert allow_squash_merge is github.GithubObject.NotSet or isinstance(allow_squash_merge, bool), allow_squash_merge assert allow_merge_commit is github.GithubObject.NotSet or isinstance(allow_merge_commit, bool), allow_merge_commit assert allow_rebase_merge is github.GithubObject.NotSet or isinstance(allow_rebase_merge, bool), allow_rebase_merge @@ -1349,8 +1351,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :param ref: string :rtype: string """ - assert isinstance(archive_format, (str, unicode)), archive_format - assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref + assert isinstance(archive_format, (str, six.text_type)), archive_format + assert ref is github.GithubObject.NotSet or isinstance(ref, (str, six.text_type)), ref url = self.url + "/" + archive_format if ref is not github.GithubObject.NotSet: url += "/" + ref @@ -1378,7 +1380,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param branch: string :rtype: :class:`github.Branch.Branch` """ - assert isinstance(branch, (str, unicode)), branch + assert isinstance(branch, (str, six.text_type)), branch headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/branches/" + branch @@ -1425,7 +1427,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.CommitComment.CommitComment` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/comments/" + str(id) @@ -1450,7 +1452,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param sha: string :rtype: :class:`github.Commit.Commit` """ - assert isinstance(sha, (str, unicode)), sha + assert isinstance(sha, (str, six.text_type)), sha headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/commits/" + sha @@ -1467,11 +1469,11 @@ class Repository(github.GithubObject.CompletableGithubObject): :param author: string or :class:`github.NamedUser.NamedUser` or :class:`github.AuthenticatedUser.AuthenticatedUser` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit` """ - assert sha is github.GithubObject.NotSet or isinstance(sha, (str, unicode)), sha - assert path is github.GithubObject.NotSet or isinstance(path, (str, unicode)), path + assert sha is github.GithubObject.NotSet or isinstance(sha, (str, six.text_type)), sha + assert path is github.GithubObject.NotSet or isinstance(path, (str, six.text_type)), path assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since assert until is github.GithubObject.NotSet or isinstance(until, datetime.datetime), until - assert author is github.GithubObject.NotSet or isinstance(author, (str, unicode, github.NamedUser.NamedUser, github.AuthenticatedUser.AuthenticatedUser)), author + assert author is github.GithubObject.NotSet or isinstance(author, (str, six.text_type, github.NamedUser.NamedUser, github.AuthenticatedUser.AuthenticatedUser)), author url_parameters = dict() if sha is not github.GithubObject.NotSet: url_parameters["sha"] = sha @@ -1500,8 +1502,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :param ref: string :rtype: :class:`github.ContentFile.ContentFile` """ - assert isinstance(path, (str, unicode)), path - assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref + assert isinstance(path, (str, six.text_type)), path + assert ref is github.GithubObject.NotSet or isinstance(ref, (str, six.text_type)), ref # Path of '/' should be the empty string. if path == '/': path = '' @@ -1510,7 +1512,7 @@ class Repository(github.GithubObject.CompletableGithubObject): url_parameters["ref"] = ref headers, data = self._requester.requestJsonAndCheck( "GET", - self.url + "/contents/" + urllib.quote(path), + self.url + "/contents/" + six.moves.urllib.parse.quote(path), parameters=url_parameters ) if isinstance(data, list): @@ -1556,7 +1558,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param per: string, must be one of day or week, day by default :rtype: None or list of :class:`github.View.View` """ - assert per is github.GithubObject.NotSet or (isinstance(per, (str, unicode)) and (per == "day" or per == "week")), "per must be day or week, day by default" + assert per is github.GithubObject.NotSet or (isinstance(per, (str, six.text_type)) and (per == "day" or per == "week")), "per must be day or week, day by default" url_parameters = dict() if per is not github.GithubObject.NotSet: url_parameters["per"] = per @@ -1578,7 +1580,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param per: string, must be one of day or week, day by default :rtype: None or list of :class:`github.Clone.Clone` """ - assert per is github.GithubObject.NotSet or (isinstance(per, (str, unicode)) and (per == "day" or per == "week")), "per must be day or week, day by default" + assert per is github.GithubObject.NotSet or (isinstance(per, (str, six.text_type)) and (per == "day" or per == "week")), "per must be day or week, day by default" url_parameters = dict() if per is not github.GithubObject.NotSet: url_parameters["per"] = per @@ -1630,14 +1632,14 @@ class Repository(github.GithubObject.CompletableGithubObject): 'content': :class:`ContentFile `:, 'commit': :class:`Commit `} """ - assert isinstance(path, (str, unicode)), \ + assert isinstance(path, (str, six.text_type)), \ 'path must be str/unicode object' - assert isinstance(message, (str, unicode)), \ + assert isinstance(message, (str, six.text_type)), \ 'message must be str/unicode object' - assert isinstance(content, (str, unicode, bytes)), \ + assert isinstance(content, (str, six.text_type, bytes)), \ 'content must be a str/unicode object' assert branch is github.GithubObject.NotSet \ - or isinstance(branch, (str, unicode)), \ + or isinstance(branch, (str, six.text_type)), \ 'branch must be a str/unicode object' assert author is github.GithubObject.NotSet \ or isinstance(author, github.InputGitAuthor), \ @@ -1651,7 +1653,7 @@ class Repository(github.GithubObject.CompletableGithubObject): content = content.encode('utf-8') content = b64encode(content).decode('utf-8') else: - if isinstance(content, unicode): + if isinstance(content, six.text_type): content = content.encode('utf-8') content = b64encode(content) put_parameters = {'message': message, 'content': content} @@ -1665,7 +1667,7 @@ class Repository(github.GithubObject.CompletableGithubObject): headers, data = self._requester.requestJsonAndCheck( "PUT", - self.url + "/contents/" + urllib.quote(path), + self.url + "/contents/" + six.moves.urllib.parse.quote(path), input=put_parameters ) @@ -1690,16 +1692,16 @@ class Repository(github.GithubObject.CompletableGithubObject): 'content': :class:`ContentFile `:, 'commit': :class:`Commit `} """ - assert isinstance(path, (str, unicode)), \ + assert isinstance(path, (str, six.text_type)), \ 'path must be str/unicode object' - assert isinstance(message, (str, unicode)), \ + assert isinstance(message, (str, six.text_type)), \ 'message must be str/unicode object' - assert isinstance(content, (str, unicode, bytes)), \ + assert isinstance(content, (str, six.text_type, bytes)), \ 'content must be a str/unicode object' - assert isinstance(sha, (str, unicode)), \ + assert isinstance(sha, (str, six.text_type)), \ 'sha must be a str/unicode object' assert branch is github.GithubObject.NotSet \ - or isinstance(branch, (str, unicode)), \ + or isinstance(branch, (str, six.text_type)), \ 'branch must be a str/unicode object' assert author is github.GithubObject.NotSet \ or isinstance(author, github.InputGitAuthor), \ @@ -1713,7 +1715,7 @@ class Repository(github.GithubObject.CompletableGithubObject): content = content.encode('utf-8') content = b64encode(content).decode('utf-8') else: - if isinstance(content, unicode): + if isinstance(content, six.text_type): content = content.encode('utf-8') content = b64encode(content) @@ -1729,7 +1731,7 @@ class Repository(github.GithubObject.CompletableGithubObject): headers, data = self._requester.requestJsonAndCheck( "PUT", - self.url + "/contents/" + urllib.quote(path), + self.url + "/contents/" + six.moves.urllib.parse.quote(path), input=put_parameters ) @@ -1753,14 +1755,14 @@ class Repository(github.GithubObject.CompletableGithubObject): 'content': :class:`null `:, 'commit': :class:`Commit `} """ - assert isinstance(path, (str, unicode)), \ + assert isinstance(path, (str, six.text_type)), \ 'path must be str/unicode object' - assert isinstance(message, (str, unicode)), \ + assert isinstance(message, (str, six.text_type)), \ 'message must be str/unicode object' - assert isinstance(sha, (str, unicode)), \ + assert isinstance(sha, (str, six.text_type)), \ 'sha must be a str/unicode object' assert branch is github.GithubObject.NotSet \ - or isinstance(branch, (str, unicode)), \ + or isinstance(branch, (str, six.text_type)), \ 'branch must be a str/unicode object' assert author is github.GithubObject.NotSet \ or isinstance(author, github.InputGitAuthor), \ @@ -1779,7 +1781,7 @@ class Repository(github.GithubObject.CompletableGithubObject): headers, data = self._requester.requestJsonAndCheck( "DELETE", - self.url + "/contents/" + urllib.quote(path), + self.url + "/contents/" + six.moves.urllib.parse.quote(path), input=url_parameters ) @@ -1793,14 +1795,14 @@ class Repository(github.GithubObject.CompletableGithubObject): :param ref: string :rtype: list of :class:`github.ContentFile.ContentFile` """ - assert isinstance(path, (str, unicode)), path - assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref + assert isinstance(path, (str, six.text_type)), path + assert ref is github.GithubObject.NotSet or isinstance(ref, (str, six.text_type)), ref url_parameters = dict() if ref is not github.GithubObject.NotSet: url_parameters["ref"] = ref headers, data = self._requester.requestJsonAndCheck( "GET", - self.url + "/contents/" + urllib.quote(path), + self.url + "/contents/" + six.moves.urllib.parse.quote(path), parameters=url_parameters ) @@ -1840,7 +1842,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.Download.Download` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/downloads/" + str(id) @@ -1889,7 +1891,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param sha: string :rtype: :class:`github.GitBlob.GitBlob` """ - assert isinstance(sha, (str, unicode)), sha + assert isinstance(sha, (str, six.text_type)), sha headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/git/blobs/" + sha @@ -1902,7 +1904,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param sha: string :rtype: :class:`github.GitCommit.GitCommit` """ - assert isinstance(sha, (str, unicode)), sha + assert isinstance(sha, (str, six.text_type)), sha headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/git/commits/" + sha @@ -1918,7 +1920,7 @@ class Repository(github.GithubObject.CompletableGithubObject): prefix = "/git/refs/" if not self._requester.FIX_REPO_GET_GIT_REF: prefix = "/git/" - assert isinstance(ref, (str, unicode)), ref + assert isinstance(ref, (str, six.text_type)), ref headers, data = self._requester.requestJsonAndCheck( "GET", self.url + prefix + ref @@ -1943,7 +1945,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param sha: string :rtype: :class:`github.GitTag.GitTag` """ - assert isinstance(sha, (str, unicode)), sha + assert isinstance(sha, (str, six.text_type)), sha headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/git/tags/" + sha @@ -1957,7 +1959,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param recursive: bool :rtype: :class:`github.GitTree.GitTree` """ - assert isinstance(sha, (str, unicode)), sha + assert isinstance(sha, (str, six.text_type)), sha assert recursive is github.GithubObject.NotSet or isinstance(recursive, bool), recursive url_parameters = dict() if recursive is not github.GithubObject.NotSet and recursive: @@ -1976,7 +1978,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.Hook.Hook` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/hooks/" + str(id) @@ -2001,7 +2003,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param number: integer :rtype: :class:`github.Issue.Issue` """ - assert isinstance(number, (int, long)), number + assert isinstance(number, six.integer_types), number headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/issues/" + str(number) @@ -2023,24 +2025,24 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` """ assert milestone is github.GithubObject.NotSet or milestone == "*" or milestone == "none" or isinstance(milestone, github.Milestone.Milestone), milestone - assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state - assert assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, unicode)), assignee + assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state + assert assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, six.text_type)), assignee assert mentioned is github.GithubObject.NotSet or isinstance(mentioned, github.NamedUser.NamedUser), mentioned assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) for element in labels), labels - assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort - assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction + assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort + assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since - assert creator is github.GithubObject.NotSet or isinstance(creator, github.NamedUser.NamedUser) or isinstance(creator, (str, unicode)), creator + assert creator is github.GithubObject.NotSet or isinstance(creator, github.NamedUser.NamedUser) or isinstance(creator, (str, six.text_type)), creator url_parameters = dict() if milestone is not github.GithubObject.NotSet: - if isinstance(milestone, (str, unicode)): + if isinstance(milestone, (str, six.text_type)): url_parameters["milestone"] = milestone else: url_parameters["milestone"] = milestone._identity if state is not github.GithubObject.NotSet: url_parameters["state"] = state if assignee is not github.GithubObject.NotSet: - if isinstance(assignee, (str, unicode)): + if isinstance(assignee, (str, six.text_type)): url_parameters["assignee"] = assignee else: url_parameters["assignee"] = assignee._identity @@ -2055,7 +2057,7 @@ class Repository(github.GithubObject.CompletableGithubObject): if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") if creator is not github.GithubObject.NotSet: - if isinstance(creator, (str, unicode)): + if isinstance(creator, (str, six.text_type)): url_parameters["creator"] = creator else: url_parameters["creator"] = creator._identity @@ -2074,8 +2076,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :param since: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.IssueComment.IssueComment` """ - assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort - assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction + assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort + assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since url_parameters = dict() if sort is not github.GithubObject.NotSet: @@ -2097,7 +2099,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.IssueEvent.IssueEvent` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/issues/events/" + str(id), @@ -2124,7 +2126,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param id: integer :rtype: :class:`github.RepositoryKey.RepositoryKey` """ - assert isinstance(id, (int, long)), id + assert isinstance(id, six.integer_types), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/keys/" + str(id) @@ -2149,10 +2151,10 @@ class Repository(github.GithubObject.CompletableGithubObject): :param name: string :rtype: :class:`github.Label.Label` """ - assert isinstance(name, (str, unicode)), name + assert isinstance(name, (str, six.text_type)), name headers, data = self._requester.requestJsonAndCheck( "GET", - self.url + "/labels/" + urllib.quote(name) + self.url + "/labels/" + six.moves.urllib.parse.quote(name) ) return github.Label.Label(self._requester, headers, data, completed=True) @@ -2197,7 +2199,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param number: integer :rtype: :class:`github.Milestone.Milestone` """ - assert isinstance(number, (int, long)), number + assert isinstance(number, six.integer_types), number headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/milestones/" + str(number) @@ -2212,9 +2214,9 @@ class Repository(github.GithubObject.CompletableGithubObject): :param direction: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Milestone.Milestone` """ - assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state - assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort - assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction + assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state + assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort + assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction url_parameters = dict() if state is not github.GithubObject.NotSet: url_parameters["state"] = state @@ -2247,7 +2249,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param number: integer :rtype: :class:`github.PullRequest.PullRequest` """ - assert isinstance(number, (int, long)), number + assert isinstance(number, six.integer_types), number headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/pulls/" + str(number) @@ -2264,11 +2266,11 @@ class Repository(github.GithubObject.CompletableGithubObject): :param head: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequest.PullRequest` """ - assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state - assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort - assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction - assert base is github.GithubObject.NotSet or isinstance(base, (str, unicode)), base - assert head is github.GithubObject.NotSet or isinstance(head, (str, unicode)), head + assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state + assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort + assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction + assert base is github.GithubObject.NotSet or isinstance(base, (str, six.text_type)), base + assert head is github.GithubObject.NotSet or isinstance(head, (str, six.text_type)), head url_parameters = dict() if state is not github.GithubObject.NotSet: url_parameters["state"] = state @@ -2305,8 +2307,8 @@ class Repository(github.GithubObject.CompletableGithubObject): :param since: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` """ - assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort - assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction + assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort + assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since url_parameters = dict() if sort is not github.GithubObject.NotSet: @@ -2328,7 +2330,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param ref: string :rtype: :class:`github.ContentFile.ContentFile` """ - assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref + assert ref is github.GithubObject.NotSet or isinstance(ref, (str, six.text_type)), ref url_parameters = dict() if ref is not github.GithubObject.NotSet: url_parameters["ref"] = ref @@ -2507,7 +2509,7 @@ class Repository(github.GithubObject.CompletableGithubObject): self.url + "/releases/" + str(id) ) return github.GitRelease.GitRelease(self._requester, headers, data, completed=True) - elif isinstance(id, (str, unicode)): + elif isinstance(id, (str, six.text_type)): headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/releases/tags/" + id @@ -2567,7 +2569,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param assignee: string or :class:`github.NamedUser.NamedUser` :rtype: bool """ - assert isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, unicode)), assignee + assert isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, six.text_type)), assignee if isinstance(assignee, github.NamedUser.NamedUser): assignee = assignee._identity @@ -2584,7 +2586,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param collaborator: string or :class:`github.NamedUser.NamedUser` :rtype: bool """ - assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, unicode)), collaborator + assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, six.text_type)), collaborator if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity @@ -2603,10 +2605,10 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` """ assert state in ["open", "closed"], state - assert isinstance(keyword, (str, unicode)), keyword + assert isinstance(keyword, (str, six.text_type)), keyword headers, data = self._requester.requestJsonAndCheck( "GET", - "/legacy/issues/search/" + self.owner.login + "/" + self.name + "/" + state + "/" + urllib.quote(keyword) + "/legacy/issues/search/" + self.owner.login + "/" + self.name + "/" + state + "/" + six.moves.urllib.parse.quote(keyword) ) return [ github.Issue.Issue(self._requester, headers, github.Legacy.convertIssue(element), completed=False) @@ -2637,9 +2639,9 @@ class Repository(github.GithubObject.CompletableGithubObject): :param commit_message: string :rtype: :class:`github.Commit.Commit` """ - assert isinstance(base, (str, unicode)), base - assert isinstance(head, (str, unicode)), head - assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, (str, unicode)), commit_message + assert isinstance(base, (str, six.text_type)), base + assert isinstance(head, (str, six.text_type)), head + assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, (str, six.text_type)), commit_message post_parameters = { "base": base, "head": head, @@ -2678,7 +2680,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :param collaborator: string or :class:`github.NamedUser.NamedUser` :rtype: None """ - assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, unicode)), collaborator + assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, six.text_type)), collaborator if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity @@ -2709,10 +2711,10 @@ class Repository(github.GithubObject.CompletableGithubObject): return self._hub("unsubscribe", event, callback, github.GithubObject.NotSet) def _hub(self, mode, event, callback, secret): - assert isinstance(mode, (str, unicode)), mode - assert isinstance(event, (str, unicode)), event - assert isinstance(callback, (str, unicode)), callback - assert secret is github.GithubObject.NotSet or isinstance(secret, (str, unicode)), secret + assert isinstance(mode, (str, six.text_type)), mode + assert isinstance(event, (str, six.text_type)), event + assert isinstance(callback, (str, six.text_type)), callback + assert secret is github.GithubObject.NotSet or isinstance(secret, (str, six.text_type)), secret post_parameters = { "hub.mode": mode, diff --git a/github/RepositoryKey.py b/github/RepositoryKey.py index e3c29758..a1de7d61 100644 --- a/github/RepositoryKey.py +++ b/github/RepositoryKey.py @@ -35,6 +35,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Requester.py b/github/Requester.py index 6eb51e8d..63daaac2 100644 --- a/github/Requester.py +++ b/github/Requester.py @@ -52,6 +52,7 @@ # # ################################################################################ +from __future__ import absolute_import import base64 import json import logging @@ -61,12 +62,13 @@ import re import requests import sys import time -import urllib -import urlparse +import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error +import six.moves.urllib.parse from io import IOBase -import Consts -import GithubException +from . import Consts +from . import GithubException +import six atLeastPython3 = sys.hexversion >= 0x03000000 @@ -80,9 +82,9 @@ class RequestsResponse: def getheaders(self): if atLeastPython3: - return self.headers.items() + return list(self.headers.items()) else: - return self.headers.iteritems() + return six.iteritems(self.headers) def read(self): return self.text @@ -243,7 +245,7 @@ class Requester: self.__authorizationHeader = None self.__base_url = base_url - o = urlparse.urlparse(base_url) + o = six.moves.urllib.parse.urlparse(base_url) self.__hostname = o.hostname self.__port = o.port self.__prefix = o.path @@ -290,7 +292,7 @@ class Requester: def __customConnection(self, url): cnx = None if not url.startswith("/"): - o = urlparse.urlparse(url) + o = six.moves.urllib.parse.urlparse(url) if o.hostname != self.__hostname or \ (o.port and o.port != self.__port) or \ (o.scheme != self.__scheme and not (o.scheme == "https" and self.__scheme == "http")): # issue80 @@ -341,7 +343,7 @@ class Requester: eol = "\r\n" encoded_input = "" - for name, value in input.iteritems(): + for name, value in six.iteritems(input): encoded_input += "--" + boundary + eol encoded_input += "Content-Disposition: form-data; name=\"" + name + "\"" + eol encoded_input += eol @@ -428,7 +430,7 @@ class Requester: return self.__requestRaw(original_cnx, verb, url, requestHeaders, input) if status == 301 and 'location' in responseHeaders: - o = urlparse.urlparse(responseHeaders['location']) + o = six.moves.urllib.parse.urlparse(responseHeaders['location']) return self.__requestRaw(original_cnx, verb, o.path, requestHeaders, input) return status, responseHeaders, output @@ -446,7 +448,7 @@ class Requester: if url.startswith("/"): url = self.__prefix + url else: - o = urlparse.urlparse(url) + o = six.moves.urllib.parse.urlparse(url) assert o.hostname in [self.__hostname, "uploads.github.com", "status.github.com"], o.hostname assert o.path.startswith((self.__prefix, "/api/")) assert o.port == self.__port @@ -459,7 +461,7 @@ class Requester: if len(parameters) == 0: return url else: - return url + "?" + urllib.urlencode(parameters) + return url + "?" + six.moves.urllib.parse.urlencode(parameters) def __createConnection(self): kwds = {} diff --git a/github/RequiredPullRequestReviews.py b/github/RequiredPullRequestReviews.py index c3da7be4..0ffbfa54 100644 --- a/github/RequiredPullRequestReviews.py +++ b/github/RequiredPullRequestReviews.py @@ -22,6 +22,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser diff --git a/github/RequiredStatusChecks.py b/github/RequiredStatusChecks.py index e4fba2e1..24be0c0f 100644 --- a/github/RequiredStatusChecks.py +++ b/github/RequiredStatusChecks.py @@ -22,6 +22,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/SourceImport.py b/github/SourceImport.py index 26a60d2c..2e9671d5 100644 --- a/github/SourceImport.py +++ b/github/SourceImport.py @@ -22,6 +22,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/Stargazer.py b/github/Stargazer.py index 335bd840..add2423f 100644 --- a/github/Stargazer.py +++ b/github/Stargazer.py @@ -26,6 +26,7 @@ # # ################################################################################ +from __future__ import absolute_import import github diff --git a/github/StatsCodeFrequency.py b/github/StatsCodeFrequency.py index aab58812..5f6b42aa 100755 --- a/github/StatsCodeFrequency.py +++ b/github/StatsCodeFrequency.py @@ -26,6 +26,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/StatsCommitActivity.py b/github/StatsCommitActivity.py index ade32342..a8e39714 100755 --- a/github/StatsCommitActivity.py +++ b/github/StatsCommitActivity.py @@ -26,6 +26,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/StatsContributor.py b/github/StatsContributor.py index 7b8d0db7..f21980b8 100755 --- a/github/StatsContributor.py +++ b/github/StatsContributor.py @@ -26,6 +26,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser diff --git a/github/StatsParticipation.py b/github/StatsParticipation.py index 326496f5..b51d4a44 100755 --- a/github/StatsParticipation.py +++ b/github/StatsParticipation.py @@ -26,6 +26,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser diff --git a/github/StatsPunchCard.py b/github/StatsPunchCard.py index 01a472c8..925b2f03 100755 --- a/github/StatsPunchCard.py +++ b/github/StatsPunchCard.py @@ -26,6 +26,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.NamedUser diff --git a/github/Tag.py b/github/Tag.py index 17033042..0315dc24 100644 --- a/github/Tag.py +++ b/github/Tag.py @@ -31,6 +31,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.Commit diff --git a/github/Team.py b/github/Team.py index a5d56a66..a6df41a6 100644 --- a/github/Team.py +++ b/github/Team.py @@ -41,6 +41,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject import github.PaginatedList @@ -48,7 +49,8 @@ import github.Repository import github.NamedUser import github.Organization -import Consts +from . import Consts +import six class Team(github.GithubObject.CompletableGithubObject): @@ -179,7 +181,7 @@ class Team(github.GithubObject.CompletableGithubObject): """ assert isinstance(member, github.NamedUser.NamedUser), member assert role is github.GithubObject.NotSet or isinstance( - role, (str, unicode)), role + role, (str, six.text_type)), role if role is not github.GithubObject.NotSet: assert role in ['member', 'maintainer'] put_parameters = { @@ -243,10 +245,10 @@ class Team(github.GithubObject.CompletableGithubObject): :param privacy: string :rtype: None """ - assert isinstance(name, (str, unicode)), name - assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description - assert permission is github.GithubObject.NotSet or isinstance(permission, (str, unicode)), permission - assert privacy is github.GithubObject.NotSet or isinstance(privacy, (str, unicode)), privacy + assert isinstance(name, (str, six.text_type)), name + assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description + assert permission is github.GithubObject.NotSet or isinstance(permission, (str, six.text_type)), permission + assert privacy is github.GithubObject.NotSet or isinstance(privacy, (str, six.text_type)), privacy post_parameters = { "name": name, } @@ -269,7 +271,7 @@ class Team(github.GithubObject.CompletableGithubObject): :param role: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ - assert role is github.GithubObject.NotSet or isinstance(role, (str, unicode)), role + assert role is github.GithubObject.NotSet or isinstance(role, (str, six.text_type)), role url_parameters = dict() if role is not github.GithubObject.NotSet: assert role in ['member', 'maintainer', 'all'] diff --git a/github/Topic.py b/github/Topic.py index c347c2c2..99fed6e9 100644 --- a/github/Topic.py +++ b/github/Topic.py @@ -22,6 +22,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/UserKey.py b/github/UserKey.py index a01a867f..9f9ac594 100644 --- a/github/UserKey.py +++ b/github/UserKey.py @@ -31,6 +31,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/View.py b/github/View.py index ed0bce5d..f64078dd 100644 --- a/github/View.py +++ b/github/View.py @@ -26,6 +26,7 @@ # # ################################################################################ +from __future__ import absolute_import import github.GithubObject diff --git a/github/__init__.py b/github/__init__.py index 8475e734..ff539ff1 100644 --- a/github/__init__.py +++ b/github/__init__.py @@ -37,13 +37,14 @@ like :class:`github.NamedUser.NamedUser` or :class:`github.Repository.Repository All classes inherit from :class:`github.GithubObject.GithubObject`. """ +from __future__ import absolute_import import logging from github.MainClass import Github, GithubIntegration -from GithubException import GithubException, BadCredentialsException, UnknownObjectException, BadUserAgentException, RateLimitExceededException, BadAttributeException, TwoFactorException -from InputFileContent import InputFileContent -from InputGitAuthor import InputGitAuthor -from InputGitTreeElement import InputGitTreeElement +from .GithubException import GithubException, BadCredentialsException, UnknownObjectException, BadUserAgentException, RateLimitExceededException, BadAttributeException, TwoFactorException +from .InputFileContent import InputFileContent +from .InputGitAuthor import InputGitAuthor +from .InputGitTreeElement import InputGitTreeElement def enable_console_debug_logging(): # pragma no cover (Function useful only outside test environment) diff --git a/requirements.txt b/requirements.txt index d678b9ff..e29381df 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ requests>=2.14.0 pyjwt +six sphinx<1.8 sphinx-rtd-theme<0.5 Deprecated diff --git a/scripts/add_attribute.py b/scripts/add_attribute.py index 52332b4c..6c3945e2 100644 --- a/scripts/add_attribute.py +++ b/scripts/add_attribute.py @@ -28,6 +28,7 @@ # # ################################################################################ +from __future__ import absolute_import import sys import os.path diff --git a/scripts/fix_headers.py b/scripts/fix_headers.py index 7b7813bb..bb764102 100755 --- a/scripts/fix_headers.py +++ b/scripts/fix_headers.py @@ -26,6 +26,8 @@ # # ################################################################################ +from __future__ import absolute_import +from __future__ import print_function import os import subprocess @@ -153,17 +155,17 @@ def findHeadersAndFiles(): elif fullname.endswith(".pyc"): pass else: - print "Don't know what to do with", filename + print("Don't know what to do with", filename) def main(): for header, filename in findHeadersAndFiles(): - print "Analyzing", filename + print("Analyzing", filename) with open(filename) as f: lines = list(line.rstrip() for line in f) newLines = header.fix(filename, lines) if newLines != lines: - print " => actually modifying", filename + print(" => actually modifying", filename) with open(filename, "w") as f: for line in newLines: f.write(line + "\n") diff --git a/tests/AllTests.py b/tests/AllTests.py index 98bbb2e5..84b172e2 100644 --- a/tests/AllTests.py +++ b/tests/AllTests.py @@ -40,90 +40,91 @@ # # ################################################################################ -from AuthenticatedUser import * -from Authentication import * -from Authorization import * -from Branch import * -from BranchProtection import * -from Commit import * -from CommitCombinedStatus 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 GitRelease import * -from GitReleaseAsset import * -from GitTag import * -from GitTree import * -from Hook import * -from Issue import * -from IssueComment import * -from Reaction import * -from IssueEvent import * -from License import * -from Label import * -from Milestone import * -from NamedUser import * -from Markdown import * -from Notification import * -from OrganizationHasInMembers import * -from Organization import * -from Project import * -from PullRequest import * -from PullRequestComment import * -from PullRequestReview import * -from PullRequestFile import * -from RateLimiting import * -from Repository import * -from RepositoryKey import * -from RequiredPullRequestReviews import * -from RequiredStatusChecks import * -from SourceImport import * -from Tag import * -from Team import * -from Traffic import * -from UserKey import * -from Migration import * -from GithubIntegration import * +from __future__ import absolute_import +from .AuthenticatedUser import * +from .Authentication import * +from .Authorization import * +from .Branch import * +from .BranchProtection import * +from .Commit import * +from .CommitCombinedStatus 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 .GitRelease import * +from .GitReleaseAsset import * +from .GitTag import * +from .GitTree import * +from .Hook import * +from .Issue import * +from .IssueComment import * +from .Reaction import * +from .IssueEvent import * +from .License import * +from .Label import * +from .Milestone import * +from .NamedUser import * +from .Markdown import * +from .Notification import * +from .OrganizationHasInMembers import * +from .Organization import * +from .Project import * +from .PullRequest import * +from .PullRequestComment import * +from .PullRequestReview import * +from .PullRequestFile import * +from .RateLimiting import * +from .Repository import * +from .RepositoryKey import * +from .RequiredPullRequestReviews import * +from .RequiredStatusChecks import * +from .SourceImport import * +from .Tag import * +from .Team import * +from .Traffic import * +from .UserKey import * +from .Migration import * +from .GithubIntegration import * -from PaginatedList import * -from Exceptions import * -from Enterprise import * -from Logging_ import * -from RawData import * -from ConditionalRequestUpdate import * -from Persistence import * -from ExposeAllAttributes import * -from BadAttributes import * -from Equality import * -from Search import * -from Retry import * +from .PaginatedList import * +from .Exceptions import * +from .Enterprise import * +from .Logging_ import * +from .RawData import * +from .ConditionalRequestUpdate import * +from .Persistence import * +from .ExposeAllAttributes import * +from .BadAttributes import * +from .Equality import * +from .Search import * +from .Retry import * -from Issue33 import * -from Issue50 import * -from Issue54 import * -from Issue80 import * -from Issue87 import * -from Issue131 import * -from Issue133 import * -from Issue134 import * -from Issue139 import * -from Issue140 import * -from Issue142 import * -from Issue158 import * -from Issue174 import * -from Issue214 import * -from Issue216 import * -from Issue278 import * -from Issue494 import * -from Issue572 import * -from Issue937 import * -from Issue945 import * -from Issue823 import * \ No newline at end of file +from .Issue33 import * +from .Issue50 import * +from .Issue54 import * +from .Issue80 import * +from .Issue87 import * +from .Issue131 import * +from .Issue133 import * +from .Issue134 import * +from .Issue139 import * +from .Issue140 import * +from .Issue142 import * +from .Issue158 import * +from .Issue174 import * +from .Issue214 import * +from .Issue216 import * +from .Issue278 import * +from .Issue494 import * +from .Issue572 import * +from .Issue937 import * +from .Issue945 import * +from .Issue823 import * \ No newline at end of file diff --git a/tests/AuthenticatedUser.py b/tests/AuthenticatedUser.py index 9da32ad9..2b2de785 100644 --- a/tests/AuthenticatedUser.py +++ b/tests/AuthenticatedUser.py @@ -32,7 +32,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import github import datetime @@ -167,13 +168,13 @@ class AuthenticatedUser(Framework.TestCase): 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(list(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(list(gist.files.keys()), ["foobar.txt"]) self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub") def testCreateKey(self): @@ -245,7 +246,7 @@ class AuthenticatedUser(Framework.TestCase): self.assertListKeyEqual(self.user.get_notifications(all=True), lambda n: n.id, []) def testMarkNotificationsAsRead(self): - self.user.mark_notifications_as_read(datetime.datetime(2018, 10, 18, 18, 20, 01, 0)) + self.user.mark_notifications_as_read(datetime.datetime(2018, 10, 18, 18, 20, 0o1, 0)) def testGetTeams(self): self.assertListKeyEqual(self.user.get_teams(), lambda t: t.name, ["Owners", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries"]) diff --git a/tests/Authentication.py b/tests/Authentication.py index 1edf7881..2c1213d9 100644 --- a/tests/Authentication.py +++ b/tests/Authentication.py @@ -28,7 +28,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import github diff --git a/tests/Authorization.py b/tests/Authorization.py index 14be38ed..78350b60 100644 --- a/tests/Authorization.py +++ b/tests/Authorization.py @@ -27,7 +27,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/BadAttributes.py b/tests/BadAttributes.py index d8f19971..69bb1b76 100755 --- a/tests/BadAttributes.py +++ b/tests/BadAttributes.py @@ -26,10 +26,12 @@ # # ################################################################################ +from __future__ import absolute_import import datetime -import Framework +from . import Framework import github +import six # Replay data is forged to simulate bad things returned by Github @@ -41,7 +43,7 @@ class BadAttributes(Framework.TestCase): with self.assertRaises(github.BadAttributeException) as raisedexp: user.name self.assertEqual(raisedexp.exception.actual_value, 42) - self.assertEqual(raisedexp.exception.expected_type, (str, unicode)) + self.assertEqual(raisedexp.exception.expected_type, (str, six.text_type)) self.assertEqual(raisedexp.exception.transformation_exception, None) def testBadAttributeTransformation(self): @@ -51,7 +53,7 @@ class BadAttributes(Framework.TestCase): with self.assertRaises(github.BadAttributeException) as raisedexp: user.created_at self.assertEqual(raisedexp.exception.actual_value, "foobar") - self.assertEqual(raisedexp.exception.expected_type, (str, unicode)) + self.assertEqual(raisedexp.exception.expected_type, (str, six.text_type)) self.assertEqual(raisedexp.exception.transformation_exception.__class__, ValueError) self.assertEqual(raisedexp.exception.transformation_exception.args, ("time data 'foobar' does not match format '%Y-%m-%dT%H:%M:%SZ'",)) @@ -62,7 +64,7 @@ class BadAttributes(Framework.TestCase): with self.assertRaises(github.BadAttributeException) as raisedexp: user.updated_at self.assertEqual(raisedexp.exception.actual_value, 42) - self.assertEqual(raisedexp.exception.expected_type, (str, unicode)) + self.assertEqual(raisedexp.exception.expected_type, (str, six.text_type)) self.assertEqual(raisedexp.exception.transformation_exception, None) def testBadSimpleAttributeInList(self): @@ -72,7 +74,7 @@ class BadAttributes(Framework.TestCase): with self.assertRaises(github.BadAttributeException) as raisedexp: hook.events self.assertEqual(raisedexp.exception.actual_value, ["push", 42]) - self.assertEqual(raisedexp.exception.expected_type, [(str, unicode)]) + self.assertEqual(raisedexp.exception.expected_type, [(str, six.text_type)]) self.assertEqual(raisedexp.exception.transformation_exception, None) def testBadAttributeInClassAttribute(self): @@ -99,7 +101,7 @@ class BadAttributes(Framework.TestCase): with self.assertRaises(github.BadAttributeException) as raisedexp: gist.files self.assertEqual(raisedexp.exception.actual_value, {"test.py": 42}) - self.assertEqual(raisedexp.exception.expected_type, {(str, unicode): dict}) + self.assertEqual(raisedexp.exception.expected_type, {(str, six.text_type): dict}) self.assertEqual(raisedexp.exception.transformation_exception, None) def testIssue195(self): @@ -115,5 +117,5 @@ class BadAttributes(Framework.TestCase): with self.assertRaises(github.BadAttributeException) as raisedexp: hook.events self.assertEqual(raisedexp.exception.actual_value, [["commit_comment", "create", "delete", "download", "follow", "fork", "fork_apply", "gist", "gollum", "issue_comment", "issues", "member", "public", "pull_request", "pull_request_review_comment", "push", "status", "team_add", "watch"]]) - self.assertEqual(raisedexp.exception.expected_type, [(str, unicode)]) + self.assertEqual(raisedexp.exception.expected_type, [(str, six.text_type)]) self.assertEqual(raisedexp.exception.transformation_exception, None) diff --git a/tests/Branch.py b/tests/Branch.py index 0764a043..f86a689a 100644 --- a/tests/Branch.py +++ b/tests/Branch.py @@ -30,7 +30,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import github diff --git a/tests/BranchProtection.py b/tests/BranchProtection.py index 19a655d4..d5f19351 100644 --- a/tests/BranchProtection.py +++ b/tests/BranchProtection.py @@ -22,7 +22,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class BranchProtection(Framework.TestCase): diff --git a/tests/Commit.py b/tests/Commit.py index 82e5e971..ea863046 100644 --- a/tests/Commit.py +++ b/tests/Commit.py @@ -29,7 +29,9 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework +import six class Commit(Framework.TestCase): @@ -48,7 +50,7 @@ class Commit(Framework.TestCase): 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.assertTrue(isinstance(self.commit.files[0].patch, (str, six.text_type))) 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") diff --git a/tests/CommitCombinedStatus.py b/tests/CommitCombinedStatus.py index 1ed79167..e3adbd46 100644 --- a/tests/CommitCombinedStatus.py +++ b/tests/CommitCombinedStatus.py @@ -26,7 +26,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/CommitComment.py b/tests/CommitComment.py index 48106326..5cbb3cbc 100644 --- a/tests/CommitComment.py +++ b/tests/CommitComment.py @@ -29,7 +29,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/CommitStatus.py b/tests/CommitStatus.py index 60baad67..50be17ae 100644 --- a/tests/CommitStatus.py +++ b/tests/CommitStatus.py @@ -30,7 +30,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/ConditionalRequestUpdate.py b/tests/ConditionalRequestUpdate.py index 01ea2cf2..799a30ce 100644 --- a/tests/ConditionalRequestUpdate.py +++ b/tests/ConditionalRequestUpdate.py @@ -27,7 +27,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class ConditionalRequestUpdate(Framework.TestCase): diff --git a/tests/ContentFile.py b/tests/ContentFile.py index 18b02805..a5d903d8 100644 --- a/tests/ContentFile.py +++ b/tests/ContentFile.py @@ -30,7 +30,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class ContentFile(Framework.TestCase): diff --git a/tests/Download.py b/tests/Download.py index 9b224276..11072f10 100644 --- a/tests/Download.py +++ b/tests/Download.py @@ -28,7 +28,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/Enterprise.py b/tests/Enterprise.py index 5e538429..81e441fe 100644 --- a/tests/Enterprise.py +++ b/tests/Enterprise.py @@ -27,9 +27,10 @@ # # ################################################################################ +from __future__ import absolute_import import github -import Framework +from . import Framework # Replay data for this test case is forged, because I don't have access to a real Github Enterprise install diff --git a/tests/Equality.py b/tests/Equality.py index b4e6347e..9b11d6df 100755 --- a/tests/Equality.py +++ b/tests/Equality.py @@ -25,7 +25,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Equality(Framework.TestCase): diff --git a/tests/Event.py b/tests/Event.py index 8b37bc1b..5cb4ec6a 100644 --- a/tests/Event.py +++ b/tests/Event.py @@ -28,7 +28,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/Exceptions.py b/tests/Exceptions.py index e3902550..07fe936a 100644 --- a/tests/Exceptions.py +++ b/tests/Exceptions.py @@ -31,11 +31,13 @@ # # ################################################################################ +from __future__ import absolute_import import github import sys import pickle -import Framework +from . import Framework +from six.moves import range atMostPython2 = sys.hexversion < 0x03000000 diff --git a/tests/ExposeAllAttributes.py b/tests/ExposeAllAttributes.py index 9e93c572..22161deb 100644 --- a/tests/ExposeAllAttributes.py +++ b/tests/ExposeAllAttributes.py @@ -25,7 +25,10 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from __future__ import print_function +from . import Framework +import six class ExposeAllAttributes(Framework.TestCase): @@ -128,9 +131,9 @@ class ExposeAllAttributes(Framework.TestCase): # userKey, # Security issue if put as-is in ReplayData ]) - for className, attributesMissingInClass in sorted(missingAttributes.iteritems()): - for attrName, value in sorted(attributesMissingInClass.iteritems()): - print className, attrName, "->", repr(value) + for className, attributesMissingInClass in sorted(six.iteritems(missingAttributes)): + for attrName, value in sorted(six.iteritems(attributesMissingInClass)): + print(className, attrName, "->", repr(value)) self.assertEqual(sum(len(attrs) for attrs in missingAttributes.values()), 0) diff --git a/tests/Framework.py b/tests/Framework.py index a3553305..8e19f267 100644 --- a/tests/Framework.py +++ b/tests/Framework.py @@ -36,6 +36,8 @@ # # ################################################################################ +from __future__ import absolute_import +from __future__ import print_function import json import os import sys @@ -46,6 +48,7 @@ from requests.structures import CaseInsensitiveDict from urllib3.util import Url import github +import six python2 = sys.hexversion < 0x03000000 atLeastPython3 = sys.hexversion >= 0x03000000 @@ -96,7 +99,7 @@ class RecordingConnection: # pragma no cover (Class useful only when recording self.__cnx = self._realConnection(host, port, *args, **kwds) def request(self, verb, url, input, headers): - print verb, url, input, headers, + print(verb, url, input, headers, end=' ') self.__cnx.request(verb, url, input, headers) # fixAuthorizationHeader changes the parameter directly to remove Authorization token. # however, this is the real dictionary that *will be sent* by "requests", @@ -119,7 +122,7 @@ class RecordingConnection: # pragma no cover (Class useful only when recording res = self.__cnx.getresponse() status = res.status - print "=>", status + print("=>", status) headers = res.getheaders() output = res.read() @@ -191,7 +194,7 @@ class ReplayingConnection: self.__testCase.assertEqual(self.__splitUrl(url), self.__splitUrl(readLine(self.__file))) self.__testCase.assertEqual(headers, eval(readLine(self.__file))) expectedInput = readLine(self.__file) - if isinstance(input, (str, unicode)): + if isinstance(input, (str, six.text_type)): if input.startswith("{"): self.__testCase.assertEqual(json.loads(input.replace('\n', '').replace('\r', '')), json.loads(expectedInput)) elif python2: # @todo Test in all cases, including Python 3.4+ diff --git a/tests/Gist.py b/tests/Gist.py index 1849f5ad..0685b545 100644 --- a/tests/Gist.py +++ b/tests/Gist.py @@ -28,7 +28,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import github import datetime @@ -40,7 +41,7 @@ class Gist(Framework.TestCase): self.assertEqual(gist.comments, 0) self.assertEqual(gist.created_at, datetime.datetime(2013, 8, 21, 16, 28, 24)) self.assertEqual(gist.description, "Github API") - self.assertEqual(gist.files.keys(), ["GithubAPI.lua"]) + self.assertEqual(list(gist.files.keys()), ["GithubAPI.lua"]) self.assertEqual(gist.files["GithubAPI.lua"].size, 21229) self.assertEqual(gist.files["GithubAPI.lua"].filename, "GithubAPI.lua") self.assertEqual(gist.files["GithubAPI.lua"].language, "Lua") @@ -90,13 +91,13 @@ class Gist(Framework.TestCase): gist = self.g.get_gist("5339374") self.assertEqual(sorted(gist.files.keys()), ["bar.txt", "foo.txt"]) gist.edit(files={"foo.txt": None}) - self.assertEqual(gist.files.keys(), ["bar.txt"]) + self.assertEqual(list(gist.files.keys()), ["bar.txt"]) def testRenameFile(self): gist = self.g.get_gist("5339374") - self.assertEqual(gist.files.keys(), ["bar.txt"]) + self.assertEqual(list(gist.files.keys()), ["bar.txt"]) gist.edit(files={"bar.txt": github.InputFileContent(gist.files["bar.txt"].content, new_name="baz.txt")}) - self.assertEqual(gist.files.keys(), ["baz.txt"]) + self.assertEqual(list(gist.files.keys()), ["baz.txt"]) def testCreateComment(self): gist = self.g.get_gist("2729810") diff --git a/tests/GistComment.py b/tests/GistComment.py index 5d751e11..2d57dc38 100644 --- a/tests/GistComment.py +++ b/tests/GistComment.py @@ -28,7 +28,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/GitBlob.py b/tests/GitBlob.py index 06369b60..69caa9b3 100644 --- a/tests/GitBlob.py +++ b/tests/GitBlob.py @@ -29,7 +29,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class GitBlob(Framework.TestCase): diff --git a/tests/GitCommit.py b/tests/GitCommit.py index 4ed79e68..db7d5123 100644 --- a/tests/GitCommit.py +++ b/tests/GitCommit.py @@ -29,9 +29,10 @@ # # ################################################################################ +from __future__ import absolute_import import datetime -import Framework +from . import Framework class GitCommit(Framework.TestCase): diff --git a/tests/GitRef.py b/tests/GitRef.py index 44b43cc5..84590727 100644 --- a/tests/GitRef.py +++ b/tests/GitRef.py @@ -28,7 +28,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class GitRef(Framework.TestCase): diff --git a/tests/GitRelease.py b/tests/GitRelease.py index bb861c64..c1cb4f03 100644 --- a/tests/GitRelease.py +++ b/tests/GitRelease.py @@ -34,10 +34,11 @@ # # ################################################################################ +from __future__ import absolute_import import os import zipfile import datetime -import Framework +from . import Framework class Release(Framework.TestCase): diff --git a/tests/GitReleaseAsset.py b/tests/GitReleaseAsset.py index 0ba71ee5..9a76aede 100644 --- a/tests/GitReleaseAsset.py +++ b/tests/GitReleaseAsset.py @@ -24,8 +24,9 @@ # # ################################################################################ +from __future__ import absolute_import import datetime -import Framework +from . import Framework class ReleaseAsset(Framework.TestCase): diff --git a/tests/GitTag.py b/tests/GitTag.py index 2246a08e..a22133ab 100644 --- a/tests/GitTag.py +++ b/tests/GitTag.py @@ -29,9 +29,10 @@ # # ################################################################################ +from __future__ import absolute_import import datetime -import Framework +from . import Framework class GitTag(Framework.TestCase): diff --git a/tests/GitTree.py b/tests/GitTree.py index 7f12066b..cd38b7f5 100644 --- a/tests/GitTree.py +++ b/tests/GitTree.py @@ -29,7 +29,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class GitTree(Framework.TestCase): diff --git a/tests/GithubIntegration.py b/tests/GithubIntegration.py index 28f13fdc..e8c1f85a 100644 --- a/tests/GithubIntegration.py +++ b/tests/GithubIntegration.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import jwt import json import time # NOQA diff --git a/tests/Github_.py b/tests/Github_.py index 484a3424..5bf97f2f 100644 --- a/tests/Github_.py +++ b/tests/Github_.py @@ -32,11 +32,12 @@ # # ################################################################################ +from __future__ import absolute_import import datetime -import Framework +from . import Framework -import Time +from . import Time import github diff --git a/tests/Hook.py b/tests/Hook.py index cd48f543..8631f2e0 100644 --- a/tests/Hook.py +++ b/tests/Hook.py @@ -29,7 +29,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/Issue.py b/tests/Issue.py index 54097ae1..d212607d 100644 --- a/tests/Issue.py +++ b/tests/Issue.py @@ -32,7 +32,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/Issue131.py b/tests/Issue131.py index fef68929..76dac6ec 100644 --- a/tests/Issue131.py +++ b/tests/Issue131.py @@ -25,7 +25,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue131(Framework.TestCase): # https://github.com/jacquev6/PyGithub/pull/133 diff --git a/tests/Issue133.py b/tests/Issue133.py index 94ecd768..4b92359b 100644 --- a/tests/Issue133.py +++ b/tests/Issue133.py @@ -25,7 +25,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue133(Framework.TestCase): # https://github.com/jacquev6/PyGithub/pull/133 diff --git a/tests/Issue134.py b/tests/Issue134.py index a66ec153..3a820034 100644 --- a/tests/Issue134.py +++ b/tests/Issue134.py @@ -26,7 +26,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import github diff --git a/tests/Issue139.py b/tests/Issue139.py index bf9be293..1196bdb6 100644 --- a/tests/Issue139.py +++ b/tests/Issue139.py @@ -25,7 +25,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue139(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issues/139 diff --git a/tests/Issue140.py b/tests/Issue140.py index 23935adf..a9c061b7 100644 --- a/tests/Issue140.py +++ b/tests/Issue140.py @@ -25,7 +25,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue140(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issues/140 diff --git a/tests/Issue142.py b/tests/Issue142.py index d32904e8..0bf555ec 100644 --- a/tests/Issue142.py +++ b/tests/Issue142.py @@ -25,6 +25,7 @@ # # ################################################################################ +from __future__ import absolute_import import unittest import github diff --git a/tests/Issue158.py b/tests/Issue158.py index 63acaf22..e0b3ff45 100644 --- a/tests/Issue158.py +++ b/tests/Issue158.py @@ -25,7 +25,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import github diff --git a/tests/Issue174.py b/tests/Issue174.py index 852eb072..cec6beaa 100644 --- a/tests/Issue174.py +++ b/tests/Issue174.py @@ -25,7 +25,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue174(Framework.TestCase): diff --git a/tests/Issue214.py b/tests/Issue214.py index 1144c1d4..7753357f 100644 --- a/tests/Issue214.py +++ b/tests/Issue214.py @@ -25,7 +25,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue214(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issues/214 diff --git a/tests/Issue216.py b/tests/Issue216.py index 6f734c1b..04e2d959 100644 --- a/tests/Issue216.py +++ b/tests/Issue216.py @@ -25,7 +25,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework # Replay data forged by capitalizing headers from PaginatedList.setUp.txt and PaginatedList.testIteration.txt diff --git a/tests/Issue278.py b/tests/Issue278.py index 92c17d74..be3217c5 100644 --- a/tests/Issue278.py +++ b/tests/Issue278.py @@ -24,7 +24,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework # Replay data forged by adding nulls to PaginatedList.setUp.txt and PaginatedList.testIteration.txt diff --git a/tests/Issue33.py b/tests/Issue33.py index 7ce5c3bd..175321ed 100644 --- a/tests/Issue33.py +++ b/tests/Issue33.py @@ -27,7 +27,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue33(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issues/33 diff --git a/tests/Issue494.py b/tests/Issue494.py index 28340612..0d59087d 100644 --- a/tests/Issue494.py +++ b/tests/Issue494.py @@ -23,7 +23,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue494(Framework.TestCase): diff --git a/tests/Issue50.py b/tests/Issue50.py index 66bc1ab3..f9bb2894 100644 --- a/tests/Issue50.py +++ b/tests/Issue50.py @@ -27,7 +27,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue50(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issues/50 diff --git a/tests/Issue54.py b/tests/Issue54.py index e92ced02..89ce8651 100644 --- a/tests/Issue54.py +++ b/tests/Issue54.py @@ -27,9 +27,10 @@ # # ################################################################################ +from __future__ import absolute_import import datetime -import Framework +from . import Framework class Issue54(Framework.TestCase): diff --git a/tests/Issue572.py b/tests/Issue572.py index a52cf497..85bbd9ae 100644 --- a/tests/Issue572.py +++ b/tests/Issue572.py @@ -22,7 +22,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import github diff --git a/tests/Issue80.py b/tests/Issue80.py index 2741f703..f1850a6e 100644 --- a/tests/Issue80.py +++ b/tests/Issue80.py @@ -27,9 +27,10 @@ # # ################################################################################ +from __future__ import absolute_import import github -import Framework +from . import Framework class Issue80(Framework.BasicTestCase): # https://github.com/jacquev6/PyGithub/issues/80 diff --git a/tests/Issue823.py b/tests/Issue823.py index 352b1f37..d4145b9d 100644 --- a/tests/Issue823.py +++ b/tests/Issue823.py @@ -25,7 +25,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue823(Framework.TestCase): diff --git a/tests/Issue87.py b/tests/Issue87.py index 93cab3b2..11b8ee0f 100644 --- a/tests/Issue87.py +++ b/tests/Issue87.py @@ -27,7 +27,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue87(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issues/87 diff --git a/tests/Issue937.py b/tests/Issue937.py index d5d3fa19..88e91bc1 100644 --- a/tests/Issue937.py +++ b/tests/Issue937.py @@ -21,7 +21,8 @@ # along with PyGithub. If not, see . # # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue937(Framework.TestCase): diff --git a/tests/Issue945.py b/tests/Issue945.py index ee758a74..1fd49351 100644 --- a/tests/Issue945.py +++ b/tests/Issue945.py @@ -22,7 +22,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Issue945(Framework.TestCase): # https://github.com/PyGithub/PyGithub/issues/945 diff --git a/tests/IssueComment.py b/tests/IssueComment.py index bfee2078..c0059de4 100644 --- a/tests/IssueComment.py +++ b/tests/IssueComment.py @@ -29,7 +29,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/IssueEvent.py b/tests/IssueEvent.py index 03f2d877..ff628586 100644 --- a/tests/IssueEvent.py +++ b/tests/IssueEvent.py @@ -29,7 +29,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/Label.py b/tests/Label.py index 81d4f091..0628c7ea 100644 --- a/tests/Label.py +++ b/tests/Label.py @@ -29,7 +29,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Label(Framework.TestCase): diff --git a/tests/License.py b/tests/License.py index 1ad851f7..03b35390 100644 --- a/tests/License.py +++ b/tests/License.py @@ -22,7 +22,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class License(Framework.TestCase): diff --git a/tests/Logging_.py b/tests/Logging_.py index 887286d1..7bbc6199 100644 --- a/tests/Logging_.py +++ b/tests/Logging_.py @@ -29,12 +29,13 @@ # # ################################################################################ +from __future__ import absolute_import import logging import sys import github -import Framework +from . import Framework python2 = sys.hexversion < 0x03000000 diff --git a/tests/Markdown.py b/tests/Markdown.py index 722b81ba..733f611c 100644 --- a/tests/Markdown.py +++ b/tests/Markdown.py @@ -27,7 +27,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Markdown(Framework.TestCase): diff --git a/tests/Migration.py b/tests/Migration.py index c28f1e24..0d71507f 100644 --- a/tests/Migration.py +++ b/tests/Migration.py @@ -47,7 +47,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import github import datetime diff --git a/tests/Milestone.py b/tests/Milestone.py index 4654569f..5af992a8 100644 --- a/tests/Milestone.py +++ b/tests/Milestone.py @@ -28,7 +28,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/NamedUser.py b/tests/NamedUser.py index 6ac953c0..650eb68b 100644 --- a/tests/NamedUser.py +++ b/tests/NamedUser.py @@ -31,7 +31,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/Notification.py b/tests/Notification.py index 84b623e2..103b7c75 100644 --- a/tests/Notification.py +++ b/tests/Notification.py @@ -28,7 +28,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Notification(Framework.TestCase): diff --git a/tests/Organization.py b/tests/Organization.py index db55939f..be8bf2ac 100644 --- a/tests/Organization.py +++ b/tests/Organization.py @@ -34,9 +34,10 @@ # # ################################################################################ +from __future__ import absolute_import import github -import Framework +from . import Framework import datetime diff --git a/tests/OrganizationHasInMembers.py b/tests/OrganizationHasInMembers.py index 384cfb2a..270d36c8 100644 --- a/tests/OrganizationHasInMembers.py +++ b/tests/OrganizationHasInMembers.py @@ -23,7 +23,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class OrganizationHasInMembers(Framework.TestCase): diff --git a/tests/PaginatedList.py b/tests/PaginatedList.py index 48f22906..4c66f559 100644 --- a/tests/PaginatedList.py +++ b/tests/PaginatedList.py @@ -29,7 +29,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework from github.PaginatedList import PaginatedList as PaginatedListImpl @@ -135,7 +136,7 @@ class PaginatedList(Framework.TestCase): self.assertEqual(len(list(self.repo.get_issues())), 456) def testCustomPerPageWithNoUrlParams(self): - import CommitComment # Don't polute github.tests namespace, it would conflict with github.tests.CommitComment + from . import CommitComment # Don't polute github.tests namespace, it would conflict with github.tests.CommitComment self.g.per_page = 100 PaginatedListImpl( CommitComment.CommitComment, diff --git a/tests/Persistence.py b/tests/Persistence.py index ddf939df..4a9d8bfc 100644 --- a/tests/Persistence.py +++ b/tests/Persistence.py @@ -26,7 +26,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import github from io import BytesIO as IO diff --git a/tests/Project.py b/tests/Project.py index ed9030f8..a7c5e629 100644 --- a/tests/Project.py +++ b/tests/Project.py @@ -22,7 +22,8 @@ # # # ############################################################################## -import Framework +from __future__ import absolute_import +from . import Framework import github diff --git a/tests/PullRequest.py b/tests/PullRequest.py index b691079b..4559372c 100644 --- a/tests/PullRequest.py +++ b/tests/PullRequest.py @@ -31,7 +31,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/PullRequestComment.py b/tests/PullRequestComment.py index 735cbc42..ea74ea94 100644 --- a/tests/PullRequestComment.py +++ b/tests/PullRequestComment.py @@ -29,7 +29,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/PullRequestFile.py b/tests/PullRequestFile.py index 502d08fe..92cc090e 100644 --- a/tests/PullRequestFile.py +++ b/tests/PullRequestFile.py @@ -28,7 +28,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class PullRequestFile(Framework.TestCase): diff --git a/tests/PullRequestReview.py b/tests/PullRequestReview.py index 4349889f..397c9bd7 100644 --- a/tests/PullRequestReview.py +++ b/tests/PullRequestReview.py @@ -26,7 +26,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/RateLimiting.py b/tests/RateLimiting.py index 2b75f9b6..958c6aad 100644 --- a/tests/RateLimiting.py +++ b/tests/RateLimiting.py @@ -28,9 +28,10 @@ # # ################################################################################ +from __future__ import absolute_import import datetime -import Framework +from . import Framework class RateLimiting(Framework.TestCase): diff --git a/tests/RawData.py b/tests/RawData.py index fca9dc63..6e578d2b 100644 --- a/tests/RawData.py +++ b/tests/RawData.py @@ -25,7 +25,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import github.NamedUser diff --git a/tests/Reaction.py b/tests/Reaction.py index f301c879..e7244e5a 100644 --- a/tests/Reaction.py +++ b/tests/Reaction.py @@ -23,7 +23,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/Repository.py b/tests/Repository.py index 86ce1649..af77ed64 100644 --- a/tests/Repository.py +++ b/tests/Repository.py @@ -47,7 +47,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import github import datetime diff --git a/tests/RepositoryKey.py b/tests/RepositoryKey.py index 6f6e09ae..866c1c1d 100644 --- a/tests/RepositoryKey.py +++ b/tests/RepositoryKey.py @@ -31,7 +31,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/RequiredPullRequestReviews.py b/tests/RequiredPullRequestReviews.py index aa253e1f..501be3b4 100644 --- a/tests/RequiredPullRequestReviews.py +++ b/tests/RequiredPullRequestReviews.py @@ -22,7 +22,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class RequiredPullRequestReviews(Framework.TestCase): diff --git a/tests/RequiredStatusChecks.py b/tests/RequiredStatusChecks.py index c1a7634f..47a3141e 100644 --- a/tests/RequiredStatusChecks.py +++ b/tests/RequiredStatusChecks.py @@ -22,7 +22,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class RequiredStatusChecks(Framework.TestCase): diff --git a/tests/Retry.py b/tests/Retry.py index 79e6f284..1d5e2486 100644 --- a/tests/Retry.py +++ b/tests/Retry.py @@ -25,10 +25,11 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from __future__ import absolute_import import urllib3 from httpretty import httpretty -import Framework +from . import Framework import requests diff --git a/tests/Search.py b/tests/Search.py index 8d45b6f2..31553fe3 100644 --- a/tests/Search.py +++ b/tests/Search.py @@ -26,7 +26,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import sys atLeastPython3 = sys.hexversion >= 0x03000000 diff --git a/tests/SourceImport.py b/tests/SourceImport.py index 0c2c7c56..355eed86 100644 --- a/tests/SourceImport.py +++ b/tests/SourceImport.py @@ -22,7 +22,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class SourceImport(Framework.TestCase): diff --git a/tests/Tag.py b/tests/Tag.py index 589a3d0e..ca0f3ffe 100644 --- a/tests/Tag.py +++ b/tests/Tag.py @@ -28,7 +28,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Tag(Framework.TestCase): diff --git a/tests/Team.py b/tests/Team.py index a96f0372..c14f2e40 100644 --- a/tests/Team.py +++ b/tests/Team.py @@ -34,7 +34,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class Team(Framework.TestCase): diff --git a/tests/Time.py b/tests/Time.py index 4743eaa3..a63f7986 100644 --- a/tests/Time.py +++ b/tests/Time.py @@ -20,6 +20,7 @@ # # ################################################################################ +from __future__ import absolute_import from datetime import timedelta, tzinfo diff --git a/tests/Traffic.py b/tests/Traffic.py index 9fc398d3..431a1215 100644 --- a/tests/Traffic.py +++ b/tests/Traffic.py @@ -26,7 +26,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework import datetime diff --git a/tests/UserKey.py b/tests/UserKey.py index c51249b5..4c583c70 100644 --- a/tests/UserKey.py +++ b/tests/UserKey.py @@ -29,7 +29,8 @@ # # ################################################################################ -import Framework +from __future__ import absolute_import +from . import Framework class UserKey(Framework.TestCase): diff --git a/tests/__main__.py b/tests/__main__.py index cdd9dcbc..132a5d94 100644 --- a/tests/__main__.py +++ b/tests/__main__.py @@ -28,10 +28,11 @@ # # ################################################################################ +from __future__ import absolute_import import sys import unittest -import Framework -import AllTests +from . import Framework +from . import AllTests def main(argv):