diff --git a/github/AuthenticatedUser.py b/github/AuthenticatedUser.py index 87c5a193..bf36ec2f 100644 --- a/github/AuthenticatedUser.py +++ b/github/AuthenticatedUser.py @@ -1066,110 +1066,74 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "avatar_url" in attributes: # pragma no branch - assert attributes["avatar_url"] is None or isinstance(attributes["avatar_url"], (str, unicode)), attributes["avatar_url"] - self._avatar_url = github.GithubObject.ValuedAttribute(attributes["avatar_url"]) + self._avatar_url = self._makeStringAttribute(attributes["avatar_url"]) if "bio" in attributes: # pragma no branch - assert attributes["bio"] is None or isinstance(attributes["bio"], (str, unicode)), attributes["bio"] - self._bio = github.GithubObject.ValuedAttribute(attributes["bio"]) + self._bio = self._makeStringAttribute(attributes["bio"]) if "blog" in attributes: # pragma no branch - assert attributes["blog"] is None or isinstance(attributes["blog"], (str, unicode)), attributes["blog"] - self._blog = github.GithubObject.ValuedAttribute(attributes["blog"]) + self._blog = self._makeStringAttribute(attributes["blog"]) if "collaborators" in attributes: # pragma no branch - assert attributes["collaborators"] is None or isinstance(attributes["collaborators"], (int, long)), attributes["collaborators"] - self._collaborators = github.GithubObject.ValuedAttribute(attributes["collaborators"]) + self._collaborators = self._makeIntAttribute(attributes["collaborators"]) if "company" in attributes: # pragma no branch - assert attributes["company"] is None or isinstance(attributes["company"], (str, unicode)), attributes["company"] - self._company = github.GithubObject.ValuedAttribute(attributes["company"]) + self._company = self._makeStringAttribute(attributes["company"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "disk_usage" in attributes: # pragma no branch - assert attributes["disk_usage"] is None or isinstance(attributes["disk_usage"], (int, long)), attributes["disk_usage"] - self._disk_usage = github.GithubObject.ValuedAttribute(attributes["disk_usage"]) + self._disk_usage = self._makeIntAttribute(attributes["disk_usage"]) if "email" in attributes: # pragma no branch - assert attributes["email"] is None or isinstance(attributes["email"], (str, unicode)), attributes["email"] - self._email = github.GithubObject.ValuedAttribute(attributes["email"]) + self._email = self._makeStringAttribute(attributes["email"]) if "events_url" in attributes: # pragma no branch - assert attributes["events_url"] is None or isinstance(attributes["events_url"], (str, unicode)), attributes["events_url"] - self._events_url = github.GithubObject.ValuedAttribute(attributes["events_url"]) + self._events_url = self._makeStringAttribute(attributes["events_url"]) if "followers" in attributes: # pragma no branch - assert attributes["followers"] is None or isinstance(attributes["followers"], (int, long)), attributes["followers"] - self._followers = github.GithubObject.ValuedAttribute(attributes["followers"]) + self._followers = self._makeIntAttribute(attributes["followers"]) if "followers_url" in attributes: # pragma no branch - assert attributes["followers_url"] is None or isinstance(attributes["followers_url"], (str, unicode)), attributes["followers_url"] - self._followers_url = github.GithubObject.ValuedAttribute(attributes["followers_url"]) + self._followers_url = self._makeStringAttribute(attributes["followers_url"]) if "following" in attributes: # pragma no branch - assert attributes["following"] is None or isinstance(attributes["following"], (int, long)), attributes["following"] - self._following = github.GithubObject.ValuedAttribute(attributes["following"]) + self._following = self._makeIntAttribute(attributes["following"]) if "following_url" in attributes: # pragma no branch - assert attributes["following_url"] is None or isinstance(attributes["following_url"], (str, unicode)), attributes["following_url"] - self._following_url = github.GithubObject.ValuedAttribute(attributes["following_url"]) + self._following_url = self._makeStringAttribute(attributes["following_url"]) if "gists_url" in attributes: # pragma no branch - assert attributes["gists_url"] is None or isinstance(attributes["gists_url"], (str, unicode)), attributes["gists_url"] - self._gists_url = github.GithubObject.ValuedAttribute(attributes["gists_url"]) + self._gists_url = self._makeStringAttribute(attributes["gists_url"]) if "gravatar_id" in attributes: # pragma no branch - assert attributes["gravatar_id"] is None or isinstance(attributes["gravatar_id"], (str, unicode)), attributes["gravatar_id"] - self._gravatar_id = github.GithubObject.ValuedAttribute(attributes["gravatar_id"]) + self._gravatar_id = self._makeStringAttribute(attributes["gravatar_id"]) if "hireable" in attributes: # pragma no branch - assert attributes["hireable"] is None or isinstance(attributes["hireable"], bool), attributes["hireable"] - self._hireable = github.GithubObject.ValuedAttribute(attributes["hireable"]) + self._hireable = self._makeBoolAttribute(attributes["hireable"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "location" in attributes: # pragma no branch - assert attributes["location"] is None or isinstance(attributes["location"], (str, unicode)), attributes["location"] - self._location = github.GithubObject.ValuedAttribute(attributes["location"]) + self._location = self._makeStringAttribute(attributes["location"]) if "login" in attributes: # pragma no branch - assert attributes["login"] is None or isinstance(attributes["login"], (str, unicode)), attributes["login"] - self._login = github.GithubObject.ValuedAttribute(attributes["login"]) + self._login = self._makeStringAttribute(attributes["login"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "organizations_url" in attributes: # pragma no branch - assert attributes["organizations_url"] is None or isinstance(attributes["organizations_url"], (str, unicode)), attributes["organizations_url"] - self._organizations_url = github.GithubObject.ValuedAttribute(attributes["organizations_url"]) + self._organizations_url = self._makeStringAttribute(attributes["organizations_url"]) if "owned_private_repos" in attributes: # pragma no branch - assert attributes["owned_private_repos"] is None or isinstance(attributes["owned_private_repos"], (int, long)), attributes["owned_private_repos"] - self._owned_private_repos = github.GithubObject.ValuedAttribute(attributes["owned_private_repos"]) + self._owned_private_repos = self._makeIntAttribute(attributes["owned_private_repos"]) if "plan" in attributes: # pragma no branch - assert attributes["plan"] is None or isinstance(attributes["plan"], dict), attributes["plan"] - self._plan = github.GithubObject.ValuedAttribute(None if attributes["plan"] is None else github.Plan.Plan(self._requester, self._headers, attributes["plan"], completed=False)) + self._plan = self._makeClassAttribute(github.Plan.Plan, attributes["plan"]) if "private_gists" in attributes: # pragma no branch - assert attributes["private_gists"] is None or isinstance(attributes["private_gists"], (int, long)), attributes["private_gists"] - self._private_gists = github.GithubObject.ValuedAttribute(attributes["private_gists"]) + self._private_gists = self._makeIntAttribute(attributes["private_gists"]) if "public_gists" in attributes: # pragma no branch - assert attributes["public_gists"] is None or isinstance(attributes["public_gists"], (int, long)), attributes["public_gists"] - self._public_gists = github.GithubObject.ValuedAttribute(attributes["public_gists"]) + self._public_gists = self._makeIntAttribute(attributes["public_gists"]) if "public_repos" in attributes: # pragma no branch - assert attributes["public_repos"] is None or isinstance(attributes["public_repos"], (int, long)), attributes["public_repos"] - self._public_repos = github.GithubObject.ValuedAttribute(attributes["public_repos"]) + self._public_repos = self._makeIntAttribute(attributes["public_repos"]) if "received_events_url" in attributes: # pragma no branch - assert attributes["received_events_url"] is None or isinstance(attributes["received_events_url"], (str, unicode)), attributes["received_events_url"] - self._received_events_url = github.GithubObject.ValuedAttribute(attributes["received_events_url"]) + self._received_events_url = self._makeStringAttribute(attributes["received_events_url"]) if "repos_url" in attributes: # pragma no branch - assert attributes["repos_url"] is None or isinstance(attributes["repos_url"], (str, unicode)), attributes["repos_url"] - self._repos_url = github.GithubObject.ValuedAttribute(attributes["repos_url"]) + self._repos_url = self._makeStringAttribute(attributes["repos_url"]) if "site_admin" in attributes: # pragma no branch - assert attributes["site_admin"] is None or isinstance(attributes["site_admin"], bool), attributes["site_admin"] - self._site_admin = github.GithubObject.ValuedAttribute(attributes["site_admin"]) + self._site_admin = self._makeBoolAttribute(attributes["site_admin"]) if "starred_url" in attributes: # pragma no branch - assert attributes["starred_url"] is None or isinstance(attributes["starred_url"], (str, unicode)), attributes["starred_url"] - self._starred_url = github.GithubObject.ValuedAttribute(attributes["starred_url"]) + self._starred_url = self._makeStringAttribute(attributes["starred_url"]) if "subscriptions_url" in attributes: # pragma no branch - assert attributes["subscriptions_url"] is None or isinstance(attributes["subscriptions_url"], (str, unicode)), attributes["subscriptions_url"] - self._subscriptions_url = github.GithubObject.ValuedAttribute(attributes["subscriptions_url"]) + self._subscriptions_url = self._makeStringAttribute(attributes["subscriptions_url"]) if "total_private_repos" in attributes: # pragma no branch - assert attributes["total_private_repos"] is None or isinstance(attributes["total_private_repos"], (int, long)), attributes["total_private_repos"] - self._total_private_repos = github.GithubObject.ValuedAttribute(attributes["total_private_repos"]) + self._total_private_repos = self._makeIntAttribute(attributes["total_private_repos"]) if "type" in attributes: # pragma no branch - assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"] - self._type = github.GithubObject.ValuedAttribute(attributes["type"]) + self._type = self._makeStringAttribute(attributes["type"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/Authorization.py b/github/Authorization.py index 4f8d6b3e..6214e753 100644 --- a/github/Authorization.py +++ b/github/Authorization.py @@ -162,29 +162,20 @@ class Authorization(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "app" in attributes: # pragma no branch - assert attributes["app"] is None or isinstance(attributes["app"], dict), attributes["app"] - self._app = github.GithubObject.ValuedAttribute(None if attributes["app"] is None else github.AuthorizationApplication.AuthorizationApplication(self._requester, self._headers, attributes["app"], completed=False)) + self._app = self._makeClassAttribute(github.AuthorizationApplication.AuthorizationApplication, attributes["app"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "note" in attributes: # pragma no branch - assert attributes["note"] is None or isinstance(attributes["note"], (str, unicode)), attributes["note"] - self._note = github.GithubObject.ValuedAttribute(attributes["note"]) + self._note = self._makeStringAttribute(attributes["note"]) if "note_url" in attributes: # pragma no branch - assert attributes["note_url"] is None or isinstance(attributes["note_url"], (str, unicode)), attributes["note_url"] - self._note_url = github.GithubObject.ValuedAttribute(attributes["note_url"]) + self._note_url = self._makeStringAttribute(attributes["note_url"]) if "scopes" in attributes: # pragma no branch - assert attributes["scopes"] is None or all(isinstance(element, (str, unicode)) for element in attributes["scopes"]), attributes["scopes"] - self._scopes = github.GithubObject.ValuedAttribute(attributes["scopes"]) + self._scopes = self._makeListOfStringsAttribute(attributes["scopes"]) if "token" in attributes: # pragma no branch - assert attributes["token"] is None or isinstance(attributes["token"], (str, unicode)), attributes["token"] - self._token = github.GithubObject.ValuedAttribute(attributes["token"]) + self._token = self._makeStringAttribute(attributes["token"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/AuthorizationApplication.py b/github/AuthorizationApplication.py index 04830b45..a90b162e 100644 --- a/github/AuthorizationApplication.py +++ b/github/AuthorizationApplication.py @@ -54,8 +54,6 @@ class AuthorizationApplication(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/Branch.py b/github/Branch.py index 3d5d0316..68a34e69 100644 --- a/github/Branch.py +++ b/github/Branch.py @@ -55,8 +55,6 @@ class Branch(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "commit" in attributes: # pragma no branch - assert attributes["commit"] is None or isinstance(attributes["commit"], dict), attributes["commit"] - self._commit = github.GithubObject.ValuedAttribute(None if attributes["commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["commit"], completed=False)) + self._commit = self._makeClassAttribute(github.Commit.Commit, attributes["commit"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) diff --git a/github/Commit.py b/github/Commit.py index 8b16a1d0..15760dda 100644 --- a/github/Commit.py +++ b/github/Commit.py @@ -217,38 +217,22 @@ class Commit(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch - assert attributes["author"] is None or isinstance(attributes["author"], dict), attributes["author"] - self._author = github.GithubObject.ValuedAttribute(None if attributes["author"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["author"], completed=False)) + self._author = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["author"]) if "comments_url" in attributes: # pragma no branch - assert attributes["comments_url"] is None or isinstance(attributes["comments_url"], (str, unicode)), attributes["comments_url"] - self._comments_url = github.GithubObject.ValuedAttribute(attributes["comments_url"]) + self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commit" in attributes: # pragma no branch - assert attributes["commit"] is None or isinstance(attributes["commit"], dict), attributes["commit"] - self._commit = github.GithubObject.ValuedAttribute(None if attributes["commit"] is None else github.GitCommit.GitCommit(self._requester, self._headers, attributes["commit"], completed=False)) + self._commit = self._makeClassAttribute(github.GitCommit.GitCommit, attributes["commit"]) if "committer" in attributes: # pragma no branch - assert attributes["committer"] is None or isinstance(attributes["committer"], dict), attributes["committer"] - self._committer = github.GithubObject.ValuedAttribute(None if attributes["committer"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["committer"], completed=False)) + self._committer = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["committer"]) if "files" in attributes: # pragma no branch - assert attributes["files"] is None or all(isinstance(element, dict) for element in attributes["files"]), attributes["files"] - self._files = github.GithubObject.ValuedAttribute(None if attributes["files"] is None else [ - github.File.File(self._requester, self._headers, element, completed=False) - for element in attributes["files"] - ]) + self._files = self._makeListOfClassesAttribute(github.File.File, attributes["files"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "parents" in attributes: # pragma no branch - assert attributes["parents"] is None or all(isinstance(element, dict) for element in attributes["parents"]), attributes["parents"] - self._parents = github.GithubObject.ValuedAttribute(None if attributes["parents"] is None else [ - Commit(self._requester, self._headers, element, completed=False) - for element in attributes["parents"] - ]) + self._parents = self._makeListOfClassesAttribute(Commit, attributes["parents"]) if "sha" in attributes: # pragma no branch - assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] - self._sha = github.GithubObject.ValuedAttribute(attributes["sha"]) + self._sha = self._makeStringAttribute(attributes["sha"]) if "stats" in attributes: # pragma no branch - assert attributes["stats"] is None or isinstance(attributes["stats"], dict), attributes["stats"] - self._stats = github.GithubObject.ValuedAttribute(None if attributes["stats"] is None else github.CommitStats.CommitStats(self._requester, self._headers, attributes["stats"], completed=False)) + self._stats = self._makeClassAttribute(github.CommitStats.CommitStats, attributes["stats"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/CommitComment.py b/github/CommitComment.py index 3f412115..ff7efaef 100644 --- a/github/CommitComment.py +++ b/github/CommitComment.py @@ -164,35 +164,24 @@ class CommitComment(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "body" in attributes: # pragma no branch - assert attributes["body"] is None or isinstance(attributes["body"], (str, unicode)), attributes["body"] - self._body = github.GithubObject.ValuedAttribute(attributes["body"]) + self._body = self._makeStringAttribute(attributes["body"]) if "commit_id" in attributes: # pragma no branch - assert attributes["commit_id"] is None or isinstance(attributes["commit_id"], (str, unicode)), attributes["commit_id"] - self._commit_id = github.GithubObject.ValuedAttribute(attributes["commit_id"]) + self._commit_id = self._makeStringAttribute(attributes["commit_id"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "line" in attributes: # pragma no branch - assert attributes["line"] is None or isinstance(attributes["line"], (int, long)), attributes["line"] - self._line = github.GithubObject.ValuedAttribute(attributes["line"]) + self._line = self._makeIntAttribute(attributes["line"]) if "path" in attributes: # pragma no branch - assert attributes["path"] is None or isinstance(attributes["path"], (str, unicode)), attributes["path"] - self._path = github.GithubObject.ValuedAttribute(attributes["path"]) + self._path = self._makeStringAttribute(attributes["path"]) if "position" in attributes: # pragma no branch - assert attributes["position"] is None or isinstance(attributes["position"], (int, long)), attributes["position"] - self._position = github.GithubObject.ValuedAttribute(attributes["position"]) + self._position = self._makeIntAttribute(attributes["position"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch - assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = github.GithubObject.ValuedAttribute(None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/CommitStats.py b/github/CommitStats.py index ac1ab8fd..11aefb3d 100644 --- a/github/CommitStats.py +++ b/github/CommitStats.py @@ -60,11 +60,8 @@ class CommitStats(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "additions" in attributes: # pragma no branch - assert attributes["additions"] is None or isinstance(attributes["additions"], (int, long)), attributes["additions"] - self._additions = github.GithubObject.ValuedAttribute(attributes["additions"]) + self._additions = self._makeIntAttribute(attributes["additions"]) if "deletions" in attributes: # pragma no branch - assert attributes["deletions"] is None or isinstance(attributes["deletions"], (int, long)), attributes["deletions"] - self._deletions = github.GithubObject.ValuedAttribute(attributes["deletions"]) + self._deletions = self._makeIntAttribute(attributes["deletions"]) if "total" in attributes: # pragma no branch - assert attributes["total"] is None or isinstance(attributes["total"], (int, long)), attributes["total"] - self._total = github.GithubObject.ValuedAttribute(attributes["total"]) + self._total = self._makeIntAttribute(attributes["total"]) diff --git a/github/CommitStatus.py b/github/CommitStatus.py index af06386f..f9dbbe94 100644 --- a/github/CommitStatus.py +++ b/github/CommitStatus.py @@ -102,26 +102,18 @@ class CommitStatus(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch - assert attributes["creator"] is None or isinstance(attributes["creator"], dict), attributes["creator"] - self._creator = github.GithubObject.ValuedAttribute(None if attributes["creator"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["creator"], completed=False)) + self._creator = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["creator"]) if "description" in attributes: # pragma no branch - assert attributes["description"] is None or isinstance(attributes["description"], (str, unicode)), attributes["description"] - self._description = github.GithubObject.ValuedAttribute(attributes["description"]) + self._description = self._makeStringAttribute(attributes["description"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "state" in attributes: # pragma no branch - assert attributes["state"] is None or isinstance(attributes["state"], (str, unicode)), attributes["state"] - self._state = github.GithubObject.ValuedAttribute(attributes["state"]) + self._state = self._makeStringAttribute(attributes["state"]) if "target_url" in attributes: # pragma no branch - assert attributes["target_url"] is None or isinstance(attributes["target_url"], (str, unicode)), attributes["target_url"] - self._target_url = github.GithubObject.ValuedAttribute(attributes["target_url"]) + self._target_url = self._makeStringAttribute(attributes["target_url"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/Comparison.py b/github/Comparison.py index abbcc312..e635ab60 100644 --- a/github/Comparison.py +++ b/github/Comparison.py @@ -156,47 +156,28 @@ class Comparison(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "ahead_by" in attributes: # pragma no branch - assert attributes["ahead_by"] is None or isinstance(attributes["ahead_by"], (int, long)), attributes["ahead_by"] - self._ahead_by = github.GithubObject.ValuedAttribute(attributes["ahead_by"]) + self._ahead_by = self._makeIntAttribute(attributes["ahead_by"]) if "base_commit" in attributes: # pragma no branch - assert attributes["base_commit"] is None or isinstance(attributes["base_commit"], dict), attributes["base_commit"] - self._base_commit = github.GithubObject.ValuedAttribute(None if attributes["base_commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["base_commit"], completed=False)) + self._base_commit = self._makeClassAttribute(github.Commit.Commit, attributes["base_commit"]) if "behind_by" in attributes: # pragma no branch - assert attributes["behind_by"] is None or isinstance(attributes["behind_by"], (int, long)), attributes["behind_by"] - self._behind_by = github.GithubObject.ValuedAttribute(attributes["behind_by"]) + self._behind_by = self._makeIntAttribute(attributes["behind_by"]) if "commits" in attributes: # pragma no branch - assert attributes["commits"] is None or all(isinstance(element, dict) for element in attributes["commits"]), attributes["commits"] - self._commits = github.GithubObject.ValuedAttribute(None if attributes["commits"] is None else [ - github.Commit.Commit(self._requester, self._headers, element, completed=False) - for element in attributes["commits"] - ]) + self._commits = self._makeListOfClassesAttribute(github.Commit.Commit, attributes["commits"]) if "diff_url" in attributes: # pragma no branch - assert attributes["diff_url"] is None or isinstance(attributes["diff_url"], (str, unicode)), attributes["diff_url"] - self._diff_url = github.GithubObject.ValuedAttribute(attributes["diff_url"]) + self._diff_url = self._makeStringAttribute(attributes["diff_url"]) if "files" in attributes: # pragma no branch - assert attributes["files"] is None or all(isinstance(element, dict) for element in attributes["files"]), attributes["files"] - self._files = github.GithubObject.ValuedAttribute(None if attributes["files"] is None else [ - github.File.File(self._requester, self._headers, element, completed=False) - for element in attributes["files"] - ]) + self._files = self._makeListOfClassesAttribute(github.File.File, attributes["files"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "merge_base_commit" in attributes: # pragma no branch - assert attributes["merge_base_commit"] is None or isinstance(attributes["merge_base_commit"], dict), attributes["merge_base_commit"] - self._merge_base_commit = github.GithubObject.ValuedAttribute(None if attributes["merge_base_commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["merge_base_commit"], completed=False)) + self._merge_base_commit = self._makeClassAttribute(github.Commit.Commit, attributes["merge_base_commit"]) if "patch_url" in attributes: # pragma no branch - assert attributes["patch_url"] is None or isinstance(attributes["patch_url"], (str, unicode)), attributes["patch_url"] - self._patch_url = github.GithubObject.ValuedAttribute(attributes["patch_url"]) + self._patch_url = self._makeStringAttribute(attributes["patch_url"]) if "permalink_url" in attributes: # pragma no branch - assert attributes["permalink_url"] is None or isinstance(attributes["permalink_url"], (str, unicode)), attributes["permalink_url"] - self._permalink_url = github.GithubObject.ValuedAttribute(attributes["permalink_url"]) + self._permalink_url = self._makeStringAttribute(attributes["permalink_url"]) if "status" in attributes: # pragma no branch - assert attributes["status"] is None or isinstance(attributes["status"], (str, unicode)), attributes["status"] - self._status = github.GithubObject.ValuedAttribute(attributes["status"]) + self._status = self._makeStringAttribute(attributes["status"]) if "total_commits" in attributes: # pragma no branch - assert attributes["total_commits"] is None or isinstance(attributes["total_commits"], (int, long)), attributes["total_commits"] - self._total_commits = github.GithubObject.ValuedAttribute(attributes["total_commits"]) + self._total_commits = self._makeIntAttribute(attributes["total_commits"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/ContentFile.py b/github/ContentFile.py index e9ac272f..626fa904 100644 --- a/github/ContentFile.py +++ b/github/ContentFile.py @@ -125,32 +125,22 @@ class ContentFile(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "content" in attributes: # pragma no branch - assert attributes["content"] is None or isinstance(attributes["content"], (str, unicode)), attributes["content"] - self._content = github.GithubObject.ValuedAttribute(attributes["content"]) + self._content = self._makeStringAttribute(attributes["content"]) if "encoding" in attributes: # pragma no branch - assert attributes["encoding"] is None or isinstance(attributes["encoding"], (str, unicode)), attributes["encoding"] - self._encoding = github.GithubObject.ValuedAttribute(attributes["encoding"]) + self._encoding = self._makeStringAttribute(attributes["encoding"]) if "git_url" in attributes: # pragma no branch - assert attributes["git_url"] is None or isinstance(attributes["git_url"], (str, unicode)), attributes["git_url"] - self._git_url = github.GithubObject.ValuedAttribute(attributes["git_url"]) + self._git_url = self._makeStringAttribute(attributes["git_url"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "path" in attributes: # pragma no branch - assert attributes["path"] is None or isinstance(attributes["path"], (str, unicode)), attributes["path"] - self._path = github.GithubObject.ValuedAttribute(attributes["path"]) + self._path = self._makeStringAttribute(attributes["path"]) if "sha" in attributes: # pragma no branch - assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] - self._sha = github.GithubObject.ValuedAttribute(attributes["sha"]) + self._sha = self._makeStringAttribute(attributes["sha"]) if "size" in attributes: # pragma no branch - assert attributes["size"] is None or isinstance(attributes["size"], (int, long)), attributes["size"] - self._size = github.GithubObject.ValuedAttribute(attributes["size"]) + self._size = self._makeIntAttribute(attributes["size"]) if "type" in attributes: # pragma no branch - assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"] - self._type = github.GithubObject.ValuedAttribute(attributes["type"]) + self._type = self._makeStringAttribute(attributes["type"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/Download.py b/github/Download.py index e5347999..89b5544c 100644 --- a/github/Download.py +++ b/github/Download.py @@ -226,62 +226,42 @@ class Download(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "accesskeyid" in attributes: # pragma no branch - assert attributes["accesskeyid"] is None or isinstance(attributes["accesskeyid"], (str, unicode)), attributes["accesskeyid"] - self._accesskeyid = github.GithubObject.ValuedAttribute(attributes["accesskeyid"]) + self._accesskeyid = self._makeStringAttribute(attributes["accesskeyid"]) if "acl" in attributes: # pragma no branch - assert attributes["acl"] is None or isinstance(attributes["acl"], (str, unicode)), attributes["acl"] - self._acl = github.GithubObject.ValuedAttribute(attributes["acl"]) + self._acl = self._makeStringAttribute(attributes["acl"]) if "bucket" in attributes: # pragma no branch - assert attributes["bucket"] is None or isinstance(attributes["bucket"], (str, unicode)), attributes["bucket"] - self._bucket = github.GithubObject.ValuedAttribute(attributes["bucket"]) + self._bucket = self._makeStringAttribute(attributes["bucket"]) if "content_type" in attributes: # pragma no branch - assert attributes["content_type"] is None or isinstance(attributes["content_type"], (str, unicode)), attributes["content_type"] - self._content_type = github.GithubObject.ValuedAttribute(attributes["content_type"]) + self._content_type = self._makeStringAttribute(attributes["content_type"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "description" in attributes: # pragma no branch - assert attributes["description"] is None or isinstance(attributes["description"], (str, unicode)), attributes["description"] - self._description = github.GithubObject.ValuedAttribute(attributes["description"]) + self._description = self._makeStringAttribute(attributes["description"]) if "download_count" in attributes: # pragma no branch - assert attributes["download_count"] is None or isinstance(attributes["download_count"], (int, long)), attributes["download_count"] - self._download_count = github.GithubObject.ValuedAttribute(attributes["download_count"]) + self._download_count = self._makeIntAttribute(attributes["download_count"]) if "expirationdate" in attributes: # pragma no branch - assert attributes["expirationdate"] is None or isinstance(attributes["expirationdate"], (str, unicode)), attributes["expirationdate"] - self._expirationdate = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["expirationdate"])) + self._expirationdate = self._makeDatetimeAttribute(attributes["expirationdate"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "mime_type" in attributes: # pragma no branch - assert attributes["mime_type"] is None or isinstance(attributes["mime_type"], (str, unicode)), attributes["mime_type"] - self._mime_type = github.GithubObject.ValuedAttribute(attributes["mime_type"]) + self._mime_type = self._makeStringAttribute(attributes["mime_type"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "path" in attributes: # pragma no branch - assert attributes["path"] is None or isinstance(attributes["path"], (str, unicode)), attributes["path"] - self._path = github.GithubObject.ValuedAttribute(attributes["path"]) + self._path = self._makeStringAttribute(attributes["path"]) if "policy" in attributes: # pragma no branch - assert attributes["policy"] is None or isinstance(attributes["policy"], (str, unicode)), attributes["policy"] - self._policy = github.GithubObject.ValuedAttribute(attributes["policy"]) + self._policy = self._makeStringAttribute(attributes["policy"]) if "prefix" in attributes: # pragma no branch - assert attributes["prefix"] is None or isinstance(attributes["prefix"], (str, unicode)), attributes["prefix"] - self._prefix = github.GithubObject.ValuedAttribute(attributes["prefix"]) + self._prefix = self._makeStringAttribute(attributes["prefix"]) if "redirect" in attributes: # pragma no branch - assert attributes["redirect"] is None or isinstance(attributes["redirect"], bool), attributes["redirect"] - self._redirect = github.GithubObject.ValuedAttribute(attributes["redirect"]) + self._redirect = self._makeBoolAttribute(attributes["redirect"]) if "s3_url" in attributes: # pragma no branch - assert attributes["s3_url"] is None or isinstance(attributes["s3_url"], (str, unicode)), attributes["s3_url"] - self._s3_url = github.GithubObject.ValuedAttribute(attributes["s3_url"]) + self._s3_url = self._makeStringAttribute(attributes["s3_url"]) if "signature" in attributes: # pragma no branch - assert attributes["signature"] is None or isinstance(attributes["signature"], (str, unicode)), attributes["signature"] - self._signature = github.GithubObject.ValuedAttribute(attributes["signature"]) + self._signature = self._makeStringAttribute(attributes["signature"]) if "size" in attributes: # pragma no branch - assert attributes["size"] is None or isinstance(attributes["size"], (int, long)), attributes["size"] - self._size = github.GithubObject.ValuedAttribute(attributes["size"]) + self._size = self._makeIntAttribute(attributes["size"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/Event.py b/github/Event.py index 5c6edea7..7741fae0 100644 --- a/github/Event.py +++ b/github/Event.py @@ -105,26 +105,18 @@ class Event(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "actor" in attributes: # pragma no branch - assert attributes["actor"] is None or isinstance(attributes["actor"], dict), attributes["actor"] - self._actor = github.GithubObject.ValuedAttribute(None if attributes["actor"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["actor"], completed=False)) + self._actor = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["actor"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (str, unicode)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeStringAttribute(attributes["id"]) if "org" in attributes: # pragma no branch - assert attributes["org"] is None or isinstance(attributes["org"], dict), attributes["org"] - self._org = github.GithubObject.ValuedAttribute(None if attributes["org"] is None else github.Organization.Organization(self._requester, self._headers, attributes["org"], completed=False)) + self._org = self._makeClassAttribute(github.Organization.Organization, attributes["org"]) if "payload" in attributes: # pragma no branch - assert attributes["payload"] is None or isinstance(attributes["payload"], dict), attributes["payload"] - self._payload = github.GithubObject.ValuedAttribute(attributes["payload"]) + self._payload = self._makeDictAttribute(attributes["payload"]) if "public" in attributes: # pragma no branch - assert attributes["public"] is None or isinstance(attributes["public"], bool), attributes["public"] - self._public = github.GithubObject.ValuedAttribute(attributes["public"]) + self._public = self._makeBoolAttribute(attributes["public"]) if "repo" in attributes: # pragma no branch - assert attributes["repo"] is None or isinstance(attributes["repo"], dict), attributes["repo"] - self._repo = github.GithubObject.ValuedAttribute(None if attributes["repo"] is None else github.Repository.Repository(self._requester, self._headers, attributes["repo"], completed=False)) + self._repo = self._makeClassAttribute(github.Repository.Repository, attributes["repo"]) if "type" in attributes: # pragma no branch - assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"] - self._type = github.GithubObject.ValuedAttribute(attributes["type"]) + self._type = self._makeStringAttribute(attributes["type"]) diff --git a/github/File.py b/github/File.py index ce9f0df8..16f07b68 100644 --- a/github/File.py +++ b/github/File.py @@ -116,32 +116,22 @@ class File(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "additions" in attributes: # pragma no branch - assert attributes["additions"] is None or isinstance(attributes["additions"], (int, long)), attributes["additions"] - self._additions = github.GithubObject.ValuedAttribute(attributes["additions"]) + self._additions = self._makeIntAttribute(attributes["additions"]) if "blob_url" in attributes: # pragma no branch - assert attributes["blob_url"] is None or isinstance(attributes["blob_url"], (str, unicode)), attributes["blob_url"] - self._blob_url = github.GithubObject.ValuedAttribute(attributes["blob_url"]) + self._blob_url = self._makeStringAttribute(attributes["blob_url"]) if "changes" in attributes: # pragma no branch - assert attributes["changes"] is None or isinstance(attributes["changes"], (int, long)), attributes["changes"] - self._changes = github.GithubObject.ValuedAttribute(attributes["changes"]) + self._changes = self._makeIntAttribute(attributes["changes"]) if "contents_url" in attributes: # pragma no branch - assert attributes["contents_url"] is None or isinstance(attributes["contents_url"], (str, unicode)), attributes["contents_url"] - self._contents_url = github.GithubObject.ValuedAttribute(attributes["contents_url"]) + self._contents_url = self._makeStringAttribute(attributes["contents_url"]) if "deletions" in attributes: # pragma no branch - assert attributes["deletions"] is None or isinstance(attributes["deletions"], (int, long)), attributes["deletions"] - self._deletions = github.GithubObject.ValuedAttribute(attributes["deletions"]) + self._deletions = self._makeIntAttribute(attributes["deletions"]) if "filename" in attributes: # pragma no branch - assert attributes["filename"] is None or isinstance(attributes["filename"], (str, unicode)), attributes["filename"] - self._filename = github.GithubObject.ValuedAttribute(attributes["filename"]) + self._filename = self._makeStringAttribute(attributes["filename"]) if "patch" in attributes: # pragma no branch - assert attributes["patch"] is None or isinstance(attributes["patch"], (str, unicode)), attributes["patch"] - self._patch = github.GithubObject.ValuedAttribute(attributes["patch"]) + self._patch = self._makeStringAttribute(attributes["patch"]) if "raw_url" in attributes: # pragma no branch - assert attributes["raw_url"] is None or isinstance(attributes["raw_url"], (str, unicode)), attributes["raw_url"] - self._raw_url = github.GithubObject.ValuedAttribute(attributes["raw_url"]) + self._raw_url = self._makeStringAttribute(attributes["raw_url"]) if "sha" in attributes: # pragma no branch - assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] - self._sha = github.GithubObject.ValuedAttribute(attributes["sha"]) + self._sha = self._makeStringAttribute(attributes["sha"]) if "status" in attributes: # pragma no branch - assert attributes["status"] is None or isinstance(attributes["status"], (str, unicode)), attributes["status"] - self._status = github.GithubObject.ValuedAttribute(attributes["status"]) + self._status = self._makeStringAttribute(attributes["status"]) diff --git a/github/Gist.py b/github/Gist.py index e91d9350..e332359e 100644 --- a/github/Gist.py +++ b/github/Gist.py @@ -320,65 +320,38 @@ class Gist(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "comments" in attributes: # pragma no branch - assert attributes["comments"] is None or isinstance(attributes["comments"], (int, long)), attributes["comments"] - self._comments = github.GithubObject.ValuedAttribute(attributes["comments"]) + self._comments = self._makeIntAttribute(attributes["comments"]) if "comments_url" in attributes: # pragma no branch - assert attributes["comments_url"] is None or isinstance(attributes["comments_url"], (str, unicode)), attributes["comments_url"] - self._comments_url = github.GithubObject.ValuedAttribute(attributes["comments_url"]) + self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commits_url" in attributes: # pragma no branch - assert attributes["commits_url"] is None or isinstance(attributes["commits_url"], (str, unicode)), attributes["commits_url"] - self._commits_url = github.GithubObject.ValuedAttribute(attributes["commits_url"]) + self._commits_url = self._makeStringAttribute(attributes["commits_url"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "description" in attributes: # pragma no branch - assert attributes["description"] is None or isinstance(attributes["description"], (str, unicode)), attributes["description"] - self._description = github.GithubObject.ValuedAttribute(attributes["description"]) + self._description = self._makeStringAttribute(attributes["description"]) if "files" in attributes: # pragma no branch - assert attributes["files"] is None or all(isinstance(element, dict) for element in attributes["files"].itervalues()), attributes["files"] - self._files = github.GithubObject.ValuedAttribute(None if attributes["files"] is None else dict( - (key, github.GistFile.GistFile(self._requester, self._headers, element, completed=False)) - for key, element in attributes["files"].iteritems() - )) + self._files = self._makeDictOfStringsToClassesAttribute(github.GistFile.GistFile, attributes["files"]) if "fork_of" in attributes: # pragma no branch - assert attributes["fork_of"] is None or isinstance(attributes["fork_of"], dict), attributes["fork_of"] - self._fork_of = github.GithubObject.ValuedAttribute(None if attributes["fork_of"] is None else Gist(self._requester, self._headers, attributes["fork_of"], completed=False)) + self._fork_of = self._makeClassAttribute(Gist, attributes["fork_of"]) if "forks" in attributes: # pragma no branch - assert attributes["forks"] is None or all(isinstance(element, dict) for element in attributes["forks"]), attributes["forks"] - self._forks = github.GithubObject.ValuedAttribute(None if attributes["forks"] is None else [ - Gist(self._requester, self._headers, element, completed=False) - for element in attributes["forks"] - ]) + self._forks = self._makeListOfClassesAttribute(Gist, attributes["forks"]) if "forks_url" in attributes: # pragma no branch - assert attributes["forks_url"] is None or isinstance(attributes["forks_url"], (str, unicode)), attributes["forks_url"] - self._forks_url = github.GithubObject.ValuedAttribute(attributes["forks_url"]) + self._forks_url = self._makeStringAttribute(attributes["forks_url"]) if "git_pull_url" in attributes: # pragma no branch - assert attributes["git_pull_url"] is None or isinstance(attributes["git_pull_url"], (str, unicode)), attributes["git_pull_url"] - self._git_pull_url = github.GithubObject.ValuedAttribute(attributes["git_pull_url"]) + self._git_pull_url = self._makeStringAttribute(attributes["git_pull_url"]) if "git_push_url" in attributes: # pragma no branch - assert attributes["git_push_url"] is None or isinstance(attributes["git_push_url"], (str, unicode)), attributes["git_push_url"] - self._git_push_url = github.GithubObject.ValuedAttribute(attributes["git_push_url"]) + self._git_push_url = self._makeStringAttribute(attributes["git_push_url"]) if "history" in attributes: # pragma no branch - assert attributes["history"] is None or all(isinstance(element, dict) for element in attributes["history"]), attributes["history"] - self._history = github.GithubObject.ValuedAttribute(None if attributes["history"] is None else [ - github.GistHistoryState.GistHistoryState(self._requester, self._headers, element, completed=False) - for element in attributes["history"] - ]) + self._history = self._makeListOfClassesAttribute(github.GistHistoryState.GistHistoryState, attributes["history"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (str, unicode)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeStringAttribute(attributes["id"]) if "public" in attributes: # pragma no branch - assert attributes["public"] is None or isinstance(attributes["public"], bool), attributes["public"] - self._public = github.GithubObject.ValuedAttribute(attributes["public"]) + self._public = self._makeBoolAttribute(attributes["public"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch - assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = github.GithubObject.ValuedAttribute(None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/GistComment.py b/github/GistComment.py index 5a4819e8..8e064367 100644 --- a/github/GistComment.py +++ b/github/GistComment.py @@ -119,20 +119,14 @@ class GistComment(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "body" in attributes: # pragma no branch - assert attributes["body"] is None or isinstance(attributes["body"], (str, unicode)), attributes["body"] - self._body = github.GithubObject.ValuedAttribute(attributes["body"]) + self._body = self._makeStringAttribute(attributes["body"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch - assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = github.GithubObject.ValuedAttribute(None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/GistFile.py b/github/GistFile.py index 3570dc47..bab927a7 100644 --- a/github/GistFile.py +++ b/github/GistFile.py @@ -84,20 +84,14 @@ class GistFile(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "content" in attributes: # pragma no branch - assert attributes["content"] is None or isinstance(attributes["content"], (str, unicode)), attributes["content"] - self._content = github.GithubObject.ValuedAttribute(attributes["content"]) + self._content = self._makeStringAttribute(attributes["content"]) if "filename" in attributes: # pragma no branch - assert attributes["filename"] is None or isinstance(attributes["filename"], (str, unicode)), attributes["filename"] - self._filename = github.GithubObject.ValuedAttribute(attributes["filename"]) + self._filename = self._makeStringAttribute(attributes["filename"]) if "language" in attributes: # pragma no branch - assert attributes["language"] is None or isinstance(attributes["language"], (str, unicode)), attributes["language"] - self._language = github.GithubObject.ValuedAttribute(attributes["language"]) + self._language = self._makeStringAttribute(attributes["language"]) if "raw_url" in attributes: # pragma no branch - assert attributes["raw_url"] is None or isinstance(attributes["raw_url"], (str, unicode)), attributes["raw_url"] - self._raw_url = github.GithubObject.ValuedAttribute(attributes["raw_url"]) + self._raw_url = self._makeStringAttribute(attributes["raw_url"]) if "size" in attributes: # pragma no branch - assert attributes["size"] is None or isinstance(attributes["size"], (int, long)), attributes["size"] - self._size = github.GithubObject.ValuedAttribute(attributes["size"]) + self._size = self._makeIntAttribute(attributes["size"]) if "type" in attributes: # pragma no branch - assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"] - self._type = github.GithubObject.ValuedAttribute(attributes["type"]) + self._type = self._makeStringAttribute(attributes["type"]) diff --git a/github/GistHistoryState.py b/github/GistHistoryState.py index 8e2c2836..b253aebb 100644 --- a/github/GistHistoryState.py +++ b/github/GistHistoryState.py @@ -220,71 +220,42 @@ class GistHistoryState(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "change_status" in attributes: # pragma no branch - assert attributes["change_status"] is None or isinstance(attributes["change_status"], dict), attributes["change_status"] - self._change_status = github.GithubObject.ValuedAttribute(None if attributes["change_status"] is None else github.CommitStats.CommitStats(self._requester, self._headers, attributes["change_status"], completed=False)) + self._change_status = self._makeClassAttribute(github.CommitStats.CommitStats, attributes["change_status"]) if "comments" in attributes: # pragma no branch - assert attributes["comments"] is None or isinstance(attributes["comments"], (int, long)), attributes["comments"] - self._comments = github.GithubObject.ValuedAttribute(attributes["comments"]) + self._comments = self._makeIntAttribute(attributes["comments"]) if "comments_url" in attributes: # pragma no branch - assert attributes["comments_url"] is None or isinstance(attributes["comments_url"], (str, unicode)), attributes["comments_url"] - self._comments_url = github.GithubObject.ValuedAttribute(attributes["comments_url"]) + self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commits_url" in attributes: # pragma no branch - assert attributes["commits_url"] is None or isinstance(attributes["commits_url"], (str, unicode)), attributes["commits_url"] - self._commits_url = github.GithubObject.ValuedAttribute(attributes["commits_url"]) + self._commits_url = self._makeStringAttribute(attributes["commits_url"]) if "committed_at" in attributes: # pragma no branch - assert attributes["committed_at"] is None or isinstance(attributes["committed_at"], (str, unicode)), attributes["committed_at"] - self._committed_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["committed_at"])) + self._committed_at = self._makeDatetimeAttribute(attributes["committed_at"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "description" in attributes: # pragma no branch - assert attributes["description"] is None or isinstance(attributes["description"], (str, unicode)), attributes["description"] - self._description = github.GithubObject.ValuedAttribute(attributes["description"]) + self._description = self._makeStringAttribute(attributes["description"]) if "files" in attributes: # pragma no branch - assert attributes["files"] is None or all(isinstance(element, dict) for element in attributes["files"].itervalues()), attributes["files"] - self._files = github.GithubObject.ValuedAttribute(None if attributes["files"] is None else dict( - (key, github.GistFile.GistFile(self._requester, self._headers, element, completed=False)) - for key, element in attributes["files"].iteritems() - )) + self._files = self._makeDictOfStringsToClassesAttribute(github.GistFile.GistFile, attributes["files"]) if "forks" in attributes: # pragma no branch - assert attributes["forks"] is None or all(isinstance(element, dict) for element in attributes["forks"]), attributes["forks"] - self._forks = github.GithubObject.ValuedAttribute(None if attributes["forks"] is None else [ - github.Gist.Gist(self._requester, self._headers, element, completed=False) - for element in attributes["forks"] - ]) + self._forks = self._makeListOfClassesAttribute(github.Gist.Gist, attributes["forks"]) if "forks_url" in attributes: # pragma no branch - assert attributes["forks_url"] is None or isinstance(attributes["forks_url"], (str, unicode)), attributes["forks_url"] - self._forks_url = github.GithubObject.ValuedAttribute(attributes["forks_url"]) + self._forks_url = self._makeStringAttribute(attributes["forks_url"]) if "git_pull_url" in attributes: # pragma no branch - assert attributes["git_pull_url"] is None or isinstance(attributes["git_pull_url"], (str, unicode)), attributes["git_pull_url"] - self._git_pull_url = github.GithubObject.ValuedAttribute(attributes["git_pull_url"]) + self._git_pull_url = self._makeStringAttribute(attributes["git_pull_url"]) if "git_push_url" in attributes: # pragma no branch - assert attributes["git_push_url"] is None or isinstance(attributes["git_push_url"], (str, unicode)), attributes["git_push_url"] - self._git_push_url = github.GithubObject.ValuedAttribute(attributes["git_push_url"]) + self._git_push_url = self._makeStringAttribute(attributes["git_push_url"]) if "history" in attributes: # pragma no branch - assert attributes["history"] is None or all(isinstance(element, dict) for element in attributes["history"]), attributes["history"] - self._history = github.GithubObject.ValuedAttribute(None if attributes["history"] is None else [ - GistHistoryState(self._requester, self._headers, element, completed=False) - for element in attributes["history"] - ]) + self._history = self._makeListOfClassesAttribute(GistHistoryState, attributes["history"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (str, unicode)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeStringAttribute(attributes["id"]) if "public" in attributes: # pragma no branch - assert attributes["public"] is None or isinstance(attributes["public"], bool), attributes["public"] - self._public = github.GithubObject.ValuedAttribute(attributes["public"]) + self._public = self._makeBoolAttribute(attributes["public"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch - assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = github.GithubObject.ValuedAttribute(None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) if "version" in attributes: # pragma no branch - assert attributes["version"] is None or isinstance(attributes["version"], (str, unicode)), attributes["version"] - self._version = github.GithubObject.ValuedAttribute(attributes["version"]) + self._version = self._makeStringAttribute(attributes["version"]) diff --git a/github/GitAuthor.py b/github/GitAuthor.py index 4c63ac51..2ef70925 100644 --- a/github/GitAuthor.py +++ b/github/GitAuthor.py @@ -60,11 +60,8 @@ class GitAuthor(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "date" in attributes: # pragma no branch - assert attributes["date"] is None or isinstance(attributes["date"], (str, unicode)), attributes["date"] - self._date = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["date"])) + self._date = self._makeDatetimeAttribute(attributes["date"]) if "email" in attributes: # pragma no branch - assert attributes["email"] is None or isinstance(attributes["email"], (str, unicode)), attributes["email"] - self._email = github.GithubObject.ValuedAttribute(attributes["email"]) + self._email = self._makeStringAttribute(attributes["email"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) diff --git a/github/GitBlob.py b/github/GitBlob.py index 1fa4df49..5c375ab2 100644 --- a/github/GitBlob.py +++ b/github/GitBlob.py @@ -81,17 +81,12 @@ class GitBlob(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "content" in attributes: # pragma no branch - assert attributes["content"] is None or isinstance(attributes["content"], (str, unicode)), attributes["content"] - self._content = github.GithubObject.ValuedAttribute(attributes["content"]) + self._content = self._makeStringAttribute(attributes["content"]) if "encoding" in attributes: # pragma no branch - assert attributes["encoding"] is None or isinstance(attributes["encoding"], (str, unicode)), attributes["encoding"] - self._encoding = github.GithubObject.ValuedAttribute(attributes["encoding"]) + self._encoding = self._makeStringAttribute(attributes["encoding"]) if "sha" in attributes: # pragma no branch - assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] - self._sha = github.GithubObject.ValuedAttribute(attributes["sha"]) + self._sha = self._makeStringAttribute(attributes["sha"]) if "size" in attributes: # pragma no branch - assert attributes["size"] is None or isinstance(attributes["size"], (int, long)), attributes["size"] - self._size = github.GithubObject.ValuedAttribute(attributes["size"]) + self._size = self._makeIntAttribute(attributes["size"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/GitCommit.py b/github/GitCommit.py index d18bf64c..4ded57e6 100644 --- a/github/GitCommit.py +++ b/github/GitCommit.py @@ -115,29 +115,18 @@ class GitCommit(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch - assert attributes["author"] is None or isinstance(attributes["author"], dict), attributes["author"] - self._author = github.GithubObject.ValuedAttribute(None if attributes["author"] is None else github.GitAuthor.GitAuthor(self._requester, self._headers, attributes["author"], completed=False)) + self._author = self._makeClassAttribute(github.GitAuthor.GitAuthor, attributes["author"]) if "committer" in attributes: # pragma no branch - assert attributes["committer"] is None or isinstance(attributes["committer"], dict), attributes["committer"] - self._committer = github.GithubObject.ValuedAttribute(None if attributes["committer"] is None else github.GitAuthor.GitAuthor(self._requester, self._headers, attributes["committer"], completed=False)) + self._committer = self._makeClassAttribute(github.GitAuthor.GitAuthor, attributes["committer"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "message" in attributes: # pragma no branch - assert attributes["message"] is None or isinstance(attributes["message"], (str, unicode)), attributes["message"] - self._message = github.GithubObject.ValuedAttribute(attributes["message"]) + self._message = self._makeStringAttribute(attributes["message"]) if "parents" in attributes: # pragma no branch - assert attributes["parents"] is None or all(isinstance(element, dict) for element in attributes["parents"]), attributes["parents"] - self._parents = github.GithubObject.ValuedAttribute(None if attributes["parents"] is None else [ - GitCommit(self._requester, self._headers, element, completed=False) - for element in attributes["parents"] - ]) + self._parents = self._makeListOfClassesAttribute(GitCommit, attributes["parents"]) if "sha" in attributes: # pragma no branch - assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] - self._sha = github.GithubObject.ValuedAttribute(attributes["sha"]) + self._sha = self._makeStringAttribute(attributes["sha"]) if "tree" in attributes: # pragma no branch - assert attributes["tree"] is None or isinstance(attributes["tree"], dict), attributes["tree"] - self._tree = github.GithubObject.ValuedAttribute(None if attributes["tree"] is None else github.GitTree.GitTree(self._requester, self._headers, attributes["tree"], completed=False)) + self._tree = self._makeClassAttribute(github.GitTree.GitTree, attributes["tree"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/GitObject.py b/github/GitObject.py index 28b474cb..e60f29f8 100644 --- a/github/GitObject.py +++ b/github/GitObject.py @@ -60,11 +60,8 @@ class GitObject(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "sha" in attributes: # pragma no branch - assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] - self._sha = github.GithubObject.ValuedAttribute(attributes["sha"]) + self._sha = self._makeStringAttribute(attributes["sha"]) if "type" in attributes: # pragma no branch - assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"] - self._type = github.GithubObject.ValuedAttribute(attributes["type"]) + self._type = self._makeStringAttribute(attributes["type"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/GitRef.py b/github/GitRef.py index b71411aa..e68e790c 100644 --- a/github/GitRef.py +++ b/github/GitRef.py @@ -96,11 +96,8 @@ class GitRef(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "object" in attributes: # pragma no branch - assert attributes["object"] is None or isinstance(attributes["object"], dict), attributes["object"] - self._object = github.GithubObject.ValuedAttribute(None if attributes["object"] is None else github.GitObject.GitObject(self._requester, self._headers, attributes["object"], completed=False)) + self._object = self._makeClassAttribute(github.GitObject.GitObject, attributes["object"]) if "ref" in attributes: # pragma no branch - assert attributes["ref"] is None or isinstance(attributes["ref"], (str, unicode)), attributes["ref"] - self._ref = github.GithubObject.ValuedAttribute(attributes["ref"]) + self._ref = self._makeStringAttribute(attributes["ref"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/GitTag.py b/github/GitTag.py index 03334d6b..5c5cf48d 100644 --- a/github/GitTag.py +++ b/github/GitTag.py @@ -93,20 +93,14 @@ class GitTag(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "message" in attributes: # pragma no branch - assert attributes["message"] is None or isinstance(attributes["message"], (str, unicode)), attributes["message"] - self._message = github.GithubObject.ValuedAttribute(attributes["message"]) + self._message = self._makeStringAttribute(attributes["message"]) if "object" in attributes: # pragma no branch - assert attributes["object"] is None or isinstance(attributes["object"], dict), attributes["object"] - self._object = github.GithubObject.ValuedAttribute(None if attributes["object"] is None else github.GitObject.GitObject(self._requester, self._headers, attributes["object"], completed=False)) + self._object = self._makeClassAttribute(github.GitObject.GitObject, attributes["object"]) if "sha" in attributes: # pragma no branch - assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] - self._sha = github.GithubObject.ValuedAttribute(attributes["sha"]) + self._sha = self._makeStringAttribute(attributes["sha"]) if "tag" in attributes: # pragma no branch - assert attributes["tag"] is None or isinstance(attributes["tag"], (str, unicode)), attributes["tag"] - self._tag = github.GithubObject.ValuedAttribute(attributes["tag"]) + self._tag = self._makeStringAttribute(attributes["tag"]) if "tagger" in attributes: # pragma no branch - assert attributes["tagger"] is None or isinstance(attributes["tagger"], dict), attributes["tagger"] - self._tagger = github.GithubObject.ValuedAttribute(None if attributes["tagger"] is None else github.GitAuthor.GitAuthor(self._requester, self._headers, attributes["tagger"], completed=False)) + self._tagger = self._makeClassAttribute(github.GitAuthor.GitAuthor, attributes["tagger"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/GitTree.py b/github/GitTree.py index 8ceefdea..ef73a13d 100644 --- a/github/GitTree.py +++ b/github/GitTree.py @@ -69,14 +69,8 @@ class GitTree(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "sha" in attributes: # pragma no branch - assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] - self._sha = github.GithubObject.ValuedAttribute(attributes["sha"]) + self._sha = self._makeStringAttribute(attributes["sha"]) if "tree" in attributes: # pragma no branch - assert attributes["tree"] is None or all(isinstance(element, dict) for element in attributes["tree"]), attributes["tree"] - self._tree = github.GithubObject.ValuedAttribute(None if attributes["tree"] is None else [ - github.GitTreeElement.GitTreeElement(self._requester, self._headers, element, completed=False) - for element in attributes["tree"] - ]) + self._tree = self._makeListOfClassesAttribute(github.GitTreeElement.GitTreeElement, attributes["tree"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/GitTreeElement.py b/github/GitTreeElement.py index e0638198..962bca3d 100644 --- a/github/GitTreeElement.py +++ b/github/GitTreeElement.py @@ -84,20 +84,14 @@ class GitTreeElement(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "mode" in attributes: # pragma no branch - assert attributes["mode"] is None or isinstance(attributes["mode"], (str, unicode)), attributes["mode"] - self._mode = github.GithubObject.ValuedAttribute(attributes["mode"]) + self._mode = self._makeStringAttribute(attributes["mode"]) if "path" in attributes: # pragma no branch - assert attributes["path"] is None or isinstance(attributes["path"], (str, unicode)), attributes["path"] - self._path = github.GithubObject.ValuedAttribute(attributes["path"]) + self._path = self._makeStringAttribute(attributes["path"]) if "sha" in attributes: # pragma no branch - assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] - self._sha = github.GithubObject.ValuedAttribute(attributes["sha"]) + self._sha = self._makeStringAttribute(attributes["sha"]) if "size" in attributes: # pragma no branch - assert attributes["size"] is None or isinstance(attributes["size"], (int, long)), attributes["size"] - self._size = github.GithubObject.ValuedAttribute(attributes["size"]) + self._size = self._makeIntAttribute(attributes["size"]) if "type" in attributes: # pragma no branch - assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"] - self._type = github.GithubObject.ValuedAttribute(attributes["type"]) + self._type = self._makeStringAttribute(attributes["type"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/GithubObject.py b/github/GithubObject.py index 7467f6e7..bb41097d 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -95,7 +95,80 @@ class GithubObject(object): return "/".join(url.split("/")[: -1]) @staticmethod - def _parseDatetime(s): + def _makeStringAttribute(value): + assert value is None or isinstance(value, (str, unicode)), (value, "should be a string") + return ValuedAttribute(value) + + @staticmethod + def _makeIntAttribute(value): + assert value is None or isinstance(value, (int, long)), (value, "should be an int") + return ValuedAttribute(value) + + @staticmethod + def _makeBoolAttribute(value): + assert value is None or isinstance(value, bool), (value, "should be an bool") + return ValuedAttribute(value) + + @staticmethod + def _makeDictAttribute(value): + assert value is None or isinstance(value, dict), (value, "should be an dict") + return ValuedAttribute(value) + + @staticmethod + def _makeTimestampAttribute(value): + assert value is None or isinstance(value, (int, long)), (value, "should be a timestamp") + if value is None: + return ValuedAttribute(None) + else: + return ValuedAttribute(datetime.datetime.utcfromtimestamp(value)) + + @staticmethod + def _makeDatetimeAttribute(value): + assert value is None or isinstance(value, (str, unicode)), (value, "should be a string parsable as a date") + if value is None: + return ValuedAttribute(None) + else: + return ValuedAttribute(GithubObject.__parseDatetime(value)) + + def _makeClassAttribute(self, klass, value): + assert value is None or isinstance(value, dict), (value, "should be an dict") + if value is None: + return ValuedAttribute(None) + else: + return ValuedAttribute(klass(self._requester, self._headers, value, completed=False)) + + @staticmethod + def _makeListOfStringsAttribute(value): + assert value is None or isinstance(value, list) and all(isinstance(element, (str, unicode)) for element in value), (value, "should be a list of strings") + if value is None: + return ValuedAttribute(None) + else: + return ValuedAttribute(value) + + @staticmethod + def _makeListOfListOfStringsAttribute(value): + assert value is None or isinstance(value, list) and all(all(isinstance(sub, (str, unicode)) for sub in element) for element in value), (value, "should be a list of list of strings") + if value is None: + return ValuedAttribute(None) + else: + return ValuedAttribute(value) + + def _makeListOfClassesAttribute(self, klass, value): + assert value is None or isinstance(value, list) and all(isinstance(element, dict) for element in value), (value, "should be a list of dicts") + if value is None: + return ValuedAttribute(None) + else: + return ValuedAttribute([klass(self._requester, self._headers, element, completed=False) for element in value]) + + def _makeDictOfStringsToClassesAttribute(self, klass, value): + assert value is None or isinstance(value, dict) and all(isinstance(key, (str, unicode)) and isinstance(element, dict) for key, element in value.iteritems()), (value, "should be a dict of strings to dicts") + if value is None: + return ValuedAttribute(None) + else: + return ValuedAttribute(dict((key, klass(self._requester, self._headers, element, completed=False)) for key, element in value.iteritems())) + + @staticmethod + def __parseDatetime(s): if s is None: return None elif len(s) == 24: diff --git a/github/GitignoreTemplate.py b/github/GitignoreTemplate.py index c0496e49..8f1050f0 100644 --- a/github/GitignoreTemplate.py +++ b/github/GitignoreTemplate.py @@ -51,8 +51,6 @@ class GitignoreTemplate(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "source" in attributes: # pragma no branch - assert attributes["source"] is None or isinstance(attributes["source"], (str, unicode)), attributes["source"] - self._source = github.GithubObject.ValuedAttribute(attributes["source"]) + self._source = self._makeStringAttribute(attributes["source"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) diff --git a/github/Hook.py b/github/Hook.py index 42387adb..ffb85541 100644 --- a/github/Hook.py +++ b/github/Hook.py @@ -184,32 +184,22 @@ class Hook(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "active" in attributes: # pragma no branch - assert attributes["active"] is None or isinstance(attributes["active"], bool), attributes["active"] - self._active = github.GithubObject.ValuedAttribute(attributes["active"]) + self._active = self._makeBoolAttribute(attributes["active"]) if "config" in attributes: # pragma no branch - assert attributes["config"] is None or isinstance(attributes["config"], dict), attributes["config"] - self._config = github.GithubObject.ValuedAttribute(attributes["config"]) + self._config = self._makeDictAttribute(attributes["config"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "events" in attributes: # pragma no branch - assert attributes["events"] is None or all(isinstance(element, (str, unicode)) for element in attributes["events"]), attributes["events"] - self._events = github.GithubObject.ValuedAttribute(attributes["events"]) + self._events = self._makeListOfStringsAttribute(attributes["events"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "last_response" in attributes: # pragma no branch - assert attributes["last_response"] is None or isinstance(attributes["last_response"], dict), attributes["last_response"] - self._last_response = github.GithubObject.ValuedAttribute(None if attributes["last_response"] is None else github.HookResponse.HookResponse(self._requester, self._headers, attributes["last_response"], completed=False)) + self._last_response = self._makeClassAttribute(github.HookResponse.HookResponse, attributes["last_response"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "test_url" in attributes: # pragma no branch - assert attributes["test_url"] is None or isinstance(attributes["test_url"], (str, unicode)), attributes["test_url"] - self._test_url = github.GithubObject.ValuedAttribute(attributes["test_url"]) + self._test_url = self._makeStringAttribute(attributes["test_url"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/HookDescription.py b/github/HookDescription.py index 16927306..493ab179 100644 --- a/github/HookDescription.py +++ b/github/HookDescription.py @@ -68,14 +68,10 @@ class HookDescription(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "events" in attributes: # pragma no branch - assert attributes["events"] is None or all(isinstance(element, (str, unicode)) for element in attributes["events"]), attributes["events"] - self._events = github.GithubObject.ValuedAttribute(attributes["events"]) + self._events = self._makeListOfStringsAttribute(attributes["events"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "schema" in attributes: # pragma no branch - assert attributes["schema"] is None or all(isinstance(element, list) for element in attributes["schema"]), attributes["schema"] - self._schema = github.GithubObject.ValuedAttribute(attributes["schema"]) + self._schema = self._makeListOfListOfStringsAttribute(attributes["schema"]) if "supported_events" in attributes: # pragma no branch - assert attributes["supported_events"] is None or all(isinstance(element, (str, unicode)) for element in attributes["supported_events"]), attributes["supported_events"] - self._supported_events = github.GithubObject.ValuedAttribute(attributes["supported_events"]) + self._supported_events = self._makeListOfStringsAttribute(attributes["supported_events"]) diff --git a/github/HookResponse.py b/github/HookResponse.py index b8b04e53..e6d0ef9b 100644 --- a/github/HookResponse.py +++ b/github/HookResponse.py @@ -60,11 +60,8 @@ class HookResponse(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "code" in attributes: # pragma no branch - assert attributes["code"] is None or isinstance(attributes["code"], (int, long)), attributes["code"] - self._code = github.GithubObject.ValuedAttribute(attributes["code"]) + self._code = self._makeIntAttribute(attributes["code"]) if "message" in attributes: # pragma no branch - assert attributes["message"] is None or isinstance(attributes["message"], (str, unicode)), attributes["message"] - self._message = github.GithubObject.ValuedAttribute(attributes["message"]) + self._message = self._makeStringAttribute(attributes["message"]) if "status" in attributes: # pragma no branch - assert attributes["status"] is None or isinstance(attributes["status"], (str, unicode)), attributes["status"] - self._status = github.GithubObject.ValuedAttribute(attributes["status"]) + self._status = self._makeStringAttribute(attributes["status"]) diff --git a/github/Issue.py b/github/Issue.py index 1f95a929..878dcaa2 100644 --- a/github/Issue.py +++ b/github/Issue.py @@ -398,68 +398,44 @@ class Issue(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "assignee" in attributes: # pragma no branch - assert attributes["assignee"] is None or isinstance(attributes["assignee"], dict), attributes["assignee"] - self._assignee = github.GithubObject.ValuedAttribute(None if attributes["assignee"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["assignee"], completed=False)) + self._assignee = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["assignee"]) if "body" in attributes: # pragma no branch - assert attributes["body"] is None or isinstance(attributes["body"], (str, unicode)), attributes["body"] - self._body = github.GithubObject.ValuedAttribute(attributes["body"]) + self._body = self._makeStringAttribute(attributes["body"]) if "closed_at" in attributes: # pragma no branch - assert attributes["closed_at"] is None or isinstance(attributes["closed_at"], (str, unicode)), attributes["closed_at"] - self._closed_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["closed_at"])) + self._closed_at = self._makeDatetimeAttribute(attributes["closed_at"]) if "closed_by" in attributes: # pragma no branch - assert attributes["closed_by"] is None or isinstance(attributes["closed_by"], dict), attributes["closed_by"] - self._closed_by = github.GithubObject.ValuedAttribute(None if attributes["closed_by"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["closed_by"], completed=False)) + self._closed_by = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["closed_by"]) if "comments" in attributes: # pragma no branch - assert attributes["comments"] is None or isinstance(attributes["comments"], (int, long)), attributes["comments"] - self._comments = github.GithubObject.ValuedAttribute(attributes["comments"]) + self._comments = self._makeIntAttribute(attributes["comments"]) if "comments_url" in attributes: # pragma no branch - assert attributes["comments_url"] is None or isinstance(attributes["comments_url"], (str, unicode)), attributes["comments_url"] - self._comments_url = github.GithubObject.ValuedAttribute(attributes["comments_url"]) + self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "events_url" in attributes: # pragma no branch - assert attributes["events_url"] is None or isinstance(attributes["events_url"], (str, unicode)), attributes["events_url"] - self._events_url = github.GithubObject.ValuedAttribute(attributes["events_url"]) + self._events_url = self._makeStringAttribute(attributes["events_url"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "labels" in attributes: # pragma no branch - assert attributes["labels"] is None or all(isinstance(element, dict) for element in attributes["labels"]), attributes["labels"] - self._labels = github.GithubObject.ValuedAttribute(None if attributes["labels"] is None else [ - github.Label.Label(self._requester, self._headers, element, completed=False) - for element in attributes["labels"] - ]) + self._labels = self._makeListOfClassesAttribute(github.Label.Label, attributes["labels"]) if "labels_url" in attributes: # pragma no branch - assert attributes["labels_url"] is None or isinstance(attributes["labels_url"], (str, unicode)), attributes["labels_url"] - self._labels_url = github.GithubObject.ValuedAttribute(attributes["labels_url"]) + self._labels_url = self._makeStringAttribute(attributes["labels_url"]) if "milestone" in attributes: # pragma no branch - assert attributes["milestone"] is None or isinstance(attributes["milestone"], dict), attributes["milestone"] - self._milestone = github.GithubObject.ValuedAttribute(None if attributes["milestone"] is None else github.Milestone.Milestone(self._requester, self._headers, attributes["milestone"], completed=False)) + self._milestone = self._makeClassAttribute(github.Milestone.Milestone, attributes["milestone"]) if "number" in attributes: # pragma no branch - assert attributes["number"] is None or isinstance(attributes["number"], (int, long)), attributes["number"] - self._number = github.GithubObject.ValuedAttribute(attributes["number"]) + self._number = self._makeIntAttribute(attributes["number"]) if "pull_request" in attributes: # pragma no branch - assert attributes["pull_request"] is None or isinstance(attributes["pull_request"], dict), attributes["pull_request"] - self._pull_request = github.GithubObject.ValuedAttribute(None if attributes["pull_request"] is None else github.IssuePullRequest.IssuePullRequest(self._requester, self._headers, attributes["pull_request"], completed=False)) + self._pull_request = self._makeClassAttribute(github.IssuePullRequest.IssuePullRequest, attributes["pull_request"]) if "repository" in attributes: # pragma no branch - assert attributes["repository"] is None or isinstance(attributes["repository"], dict), attributes["repository"] - self._repository = github.GithubObject.ValuedAttribute(None if attributes["repository"] is None else github.Repository.Repository(self._requester, self._headers, attributes["repository"], completed=False)) + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) if "state" in attributes: # pragma no branch - assert attributes["state"] is None or isinstance(attributes["state"], (str, unicode)), attributes["state"] - self._state = github.GithubObject.ValuedAttribute(attributes["state"]) + self._state = self._makeStringAttribute(attributes["state"]) if "title" in attributes: # pragma no branch - assert attributes["title"] is None or isinstance(attributes["title"], (str, unicode)), attributes["title"] - self._title = github.GithubObject.ValuedAttribute(attributes["title"]) + self._title = self._makeStringAttribute(attributes["title"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch - assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = github.GithubObject.ValuedAttribute(None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/IssueComment.py b/github/IssueComment.py index c5739592..77300ceb 100644 --- a/github/IssueComment.py +++ b/github/IssueComment.py @@ -138,26 +138,18 @@ class IssueComment(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "body" in attributes: # pragma no branch - assert attributes["body"] is None or isinstance(attributes["body"], (str, unicode)), attributes["body"] - self._body = github.GithubObject.ValuedAttribute(attributes["body"]) + self._body = self._makeStringAttribute(attributes["body"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "issue_url" in attributes: # pragma no branch - assert attributes["issue_url"] is None or isinstance(attributes["issue_url"], (str, unicode)), attributes["issue_url"] - self._issue_url = github.GithubObject.ValuedAttribute(attributes["issue_url"]) + self._issue_url = self._makeStringAttribute(attributes["issue_url"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "user" in attributes: # pragma no branch - assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = github.GithubObject.ValuedAttribute(None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/IssueEvent.py b/github/IssueEvent.py index c95f5a87..39ece438 100644 --- a/github/IssueEvent.py +++ b/github/IssueEvent.py @@ -102,23 +102,16 @@ class IssueEvent(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "actor" in attributes: # pragma no branch - assert attributes["actor"] is None or isinstance(attributes["actor"], dict), attributes["actor"] - self._actor = github.GithubObject.ValuedAttribute(None if attributes["actor"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["actor"], completed=False)) + self._actor = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["actor"]) if "commit_id" in attributes: # pragma no branch - assert attributes["commit_id"] is None or isinstance(attributes["commit_id"], (str, unicode)), attributes["commit_id"] - self._commit_id = github.GithubObject.ValuedAttribute(attributes["commit_id"]) + self._commit_id = self._makeStringAttribute(attributes["commit_id"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "event" in attributes: # pragma no branch - assert attributes["event"] is None or isinstance(attributes["event"], (str, unicode)), attributes["event"] - self._event = github.GithubObject.ValuedAttribute(attributes["event"]) + self._event = self._makeStringAttribute(attributes["event"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "issue" in attributes: # pragma no branch - assert attributes["issue"] is None or isinstance(attributes["issue"], dict), attributes["issue"] - self._issue = github.GithubObject.ValuedAttribute(None if attributes["issue"] is None else github.Issue.Issue(self._requester, self._headers, attributes["issue"], completed=False)) + self._issue = self._makeClassAttribute(github.Issue.Issue, attributes["issue"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/IssuePullRequest.py b/github/IssuePullRequest.py index e7652ea7..604f0563 100644 --- a/github/IssuePullRequest.py +++ b/github/IssuePullRequest.py @@ -60,11 +60,8 @@ class IssuePullRequest(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "diff_url" in attributes: # pragma no branch - assert attributes["diff_url"] is None or isinstance(attributes["diff_url"], (str, unicode)), attributes["diff_url"] - self._diff_url = github.GithubObject.ValuedAttribute(attributes["diff_url"]) + self._diff_url = self._makeStringAttribute(attributes["diff_url"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "patch_url" in attributes: # pragma no branch - assert attributes["patch_url"] is None or isinstance(attributes["patch_url"], (str, unicode)), attributes["patch_url"] - self._patch_url = github.GithubObject.ValuedAttribute(attributes["patch_url"]) + self._patch_url = self._makeStringAttribute(attributes["patch_url"]) diff --git a/github/Label.py b/github/Label.py index 646443e0..112fa3aa 100644 --- a/github/Label.py +++ b/github/Label.py @@ -100,11 +100,8 @@ class Label(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "color" in attributes: # pragma no branch - assert attributes["color"] is None or isinstance(attributes["color"], (str, unicode)), attributes["color"] - self._color = github.GithubObject.ValuedAttribute(attributes["color"]) + self._color = self._makeStringAttribute(attributes["color"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/Milestone.py b/github/Milestone.py index e7920ca3..430da40b 100644 --- a/github/Milestone.py +++ b/github/Milestone.py @@ -215,41 +215,28 @@ class Milestone(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "closed_issues" in attributes: # pragma no branch - assert attributes["closed_issues"] is None or isinstance(attributes["closed_issues"], (int, long)), attributes["closed_issues"] - self._closed_issues = github.GithubObject.ValuedAttribute(attributes["closed_issues"]) + self._closed_issues = self._makeIntAttribute(attributes["closed_issues"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch - assert attributes["creator"] is None or isinstance(attributes["creator"], dict), attributes["creator"] - self._creator = github.GithubObject.ValuedAttribute(None if attributes["creator"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["creator"], completed=False)) + self._creator = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["creator"]) if "description" in attributes: # pragma no branch - assert attributes["description"] is None or isinstance(attributes["description"], (str, unicode)), attributes["description"] - self._description = github.GithubObject.ValuedAttribute(attributes["description"]) + self._description = self._makeStringAttribute(attributes["description"]) if "due_on" in attributes: # pragma no branch - assert attributes["due_on"] is None or isinstance(attributes["due_on"], (str, unicode)), attributes["due_on"] - self._due_on = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["due_on"])) + self._due_on = self._makeDatetimeAttribute(attributes["due_on"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "labels_url" in attributes: # pragma no branch - assert attributes["labels_url"] is None or isinstance(attributes["labels_url"], (str, unicode)), attributes["labels_url"] - self._labels_url = github.GithubObject.ValuedAttribute(attributes["labels_url"]) + self._labels_url = self._makeStringAttribute(attributes["labels_url"]) if "number" in attributes: # pragma no branch - assert attributes["number"] is None or isinstance(attributes["number"], (int, long)), attributes["number"] - self._number = github.GithubObject.ValuedAttribute(attributes["number"]) + self._number = self._makeIntAttribute(attributes["number"]) if "open_issues" in attributes: # pragma no branch - assert attributes["open_issues"] is None or isinstance(attributes["open_issues"], (int, long)), attributes["open_issues"] - self._open_issues = github.GithubObject.ValuedAttribute(attributes["open_issues"]) + self._open_issues = self._makeIntAttribute(attributes["open_issues"]) if "state" in attributes: # pragma no branch - assert attributes["state"] is None or isinstance(attributes["state"], (str, unicode)), attributes["state"] - self._state = github.GithubObject.ValuedAttribute(attributes["state"]) + self._state = self._makeStringAttribute(attributes["state"]) if "title" in attributes: # pragma no branch - assert attributes["title"] is None or isinstance(attributes["title"], (str, unicode)), attributes["title"] - self._title = github.GithubObject.ValuedAttribute(attributes["title"]) + self._title = self._makeStringAttribute(attributes["title"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/NamedUser.py b/github/NamedUser.py index 95b7463d..a64ab047 100644 --- a/github/NamedUser.py +++ b/github/NamedUser.py @@ -585,110 +585,74 @@ class NamedUser(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "avatar_url" in attributes: # pragma no branch - assert attributes["avatar_url"] is None or isinstance(attributes["avatar_url"], (str, unicode)), attributes["avatar_url"] - self._avatar_url = github.GithubObject.ValuedAttribute(attributes["avatar_url"]) + self._avatar_url = self._makeStringAttribute(attributes["avatar_url"]) if "bio" in attributes: # pragma no branch - assert attributes["bio"] is None or isinstance(attributes["bio"], (str, unicode)), attributes["bio"] - self._bio = github.GithubObject.ValuedAttribute(attributes["bio"]) + self._bio = self._makeStringAttribute(attributes["bio"]) if "blog" in attributes: # pragma no branch - assert attributes["blog"] is None or isinstance(attributes["blog"], (str, unicode)), attributes["blog"] - self._blog = github.GithubObject.ValuedAttribute(attributes["blog"]) + self._blog = self._makeStringAttribute(attributes["blog"]) if "collaborators" in attributes: # pragma no branch - assert attributes["collaborators"] is None or isinstance(attributes["collaborators"], (int, long)), attributes["collaborators"] - self._collaborators = github.GithubObject.ValuedAttribute(attributes["collaborators"]) + self._collaborators = self._makeIntAttribute(attributes["collaborators"]) if "company" in attributes: # pragma no branch - assert attributes["company"] is None or isinstance(attributes["company"], (str, unicode)), attributes["company"] - self._company = github.GithubObject.ValuedAttribute(attributes["company"]) + self._company = self._makeStringAttribute(attributes["company"]) if "contributions" in attributes: # pragma no branch - assert attributes["contributions"] is None or isinstance(attributes["contributions"], (int, long)), attributes["contributions"] - self._contributions = github.GithubObject.ValuedAttribute(attributes["contributions"]) + self._contributions = self._makeIntAttribute(attributes["contributions"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "disk_usage" in attributes: # pragma no branch - assert attributes["disk_usage"] is None or isinstance(attributes["disk_usage"], (int, long)), attributes["disk_usage"] - self._disk_usage = github.GithubObject.ValuedAttribute(attributes["disk_usage"]) + self._disk_usage = self._makeIntAttribute(attributes["disk_usage"]) if "email" in attributes: # pragma no branch - assert attributes["email"] is None or isinstance(attributes["email"], (str, unicode)), attributes["email"] - self._email = github.GithubObject.ValuedAttribute(attributes["email"]) + self._email = self._makeStringAttribute(attributes["email"]) if "events_url" in attributes: # pragma no branch - assert attributes["events_url"] is None or isinstance(attributes["events_url"], (str, unicode)), attributes["events_url"] - self._events_url = github.GithubObject.ValuedAttribute(attributes["events_url"]) + self._events_url = self._makeStringAttribute(attributes["events_url"]) if "followers" in attributes: # pragma no branch - assert attributes["followers"] is None or isinstance(attributes["followers"], (int, long)), attributes["followers"] - self._followers = github.GithubObject.ValuedAttribute(attributes["followers"]) + self._followers = self._makeIntAttribute(attributes["followers"]) if "followers_url" in attributes: # pragma no branch - assert attributes["followers_url"] is None or isinstance(attributes["followers_url"], (str, unicode)), attributes["followers_url"] - self._followers_url = github.GithubObject.ValuedAttribute(attributes["followers_url"]) + self._followers_url = self._makeStringAttribute(attributes["followers_url"]) if "following" in attributes: # pragma no branch - assert attributes["following"] is None or isinstance(attributes["following"], (int, long)), attributes["following"] - self._following = github.GithubObject.ValuedAttribute(attributes["following"]) + self._following = self._makeIntAttribute(attributes["following"]) if "following_url" in attributes: # pragma no branch - assert attributes["following_url"] is None or isinstance(attributes["following_url"], (str, unicode)), attributes["following_url"] - self._following_url = github.GithubObject.ValuedAttribute(attributes["following_url"]) + self._following_url = self._makeStringAttribute(attributes["following_url"]) if "gists_url" in attributes: # pragma no branch - assert attributes["gists_url"] is None or isinstance(attributes["gists_url"], (str, unicode)), attributes["gists_url"] - self._gists_url = github.GithubObject.ValuedAttribute(attributes["gists_url"]) + self._gists_url = self._makeStringAttribute(attributes["gists_url"]) if "gravatar_id" in attributes: # pragma no branch - assert attributes["gravatar_id"] is None or isinstance(attributes["gravatar_id"], (str, unicode)), attributes["gravatar_id"] - self._gravatar_id = github.GithubObject.ValuedAttribute(attributes["gravatar_id"]) + self._gravatar_id = self._makeStringAttribute(attributes["gravatar_id"]) if "hireable" in attributes: # pragma no branch - assert attributes["hireable"] is None or isinstance(attributes["hireable"], bool), attributes["hireable"] - self._hireable = github.GithubObject.ValuedAttribute(attributes["hireable"]) + self._hireable = self._makeBoolAttribute(attributes["hireable"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "location" in attributes: # pragma no branch - assert attributes["location"] is None or isinstance(attributes["location"], (str, unicode)), attributes["location"] - self._location = github.GithubObject.ValuedAttribute(attributes["location"]) + self._location = self._makeStringAttribute(attributes["location"]) if "login" in attributes: # pragma no branch - assert attributes["login"] is None or isinstance(attributes["login"], (str, unicode)), attributes["login"] - self._login = github.GithubObject.ValuedAttribute(attributes["login"]) + self._login = self._makeStringAttribute(attributes["login"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "organizations_url" in attributes: # pragma no branch - assert attributes["organizations_url"] is None or isinstance(attributes["organizations_url"], (str, unicode)), attributes["organizations_url"] - self._organizations_url = github.GithubObject.ValuedAttribute(attributes["organizations_url"]) + self._organizations_url = self._makeStringAttribute(attributes["organizations_url"]) if "owned_private_repos" in attributes: # pragma no branch - assert attributes["owned_private_repos"] is None or isinstance(attributes["owned_private_repos"], (int, long)), attributes["owned_private_repos"] - self._owned_private_repos = github.GithubObject.ValuedAttribute(attributes["owned_private_repos"]) + self._owned_private_repos = self._makeIntAttribute(attributes["owned_private_repos"]) if "plan" in attributes: # pragma no branch - assert attributes["plan"] is None or isinstance(attributes["plan"], dict), attributes["plan"] - self._plan = github.GithubObject.ValuedAttribute(None if attributes["plan"] is None else github.Plan.Plan(self._requester, self._headers, attributes["plan"], completed=False)) + self._plan = self._makeClassAttribute(github.Plan.Plan, attributes["plan"]) if "private_gists" in attributes: # pragma no branch - assert attributes["private_gists"] is None or isinstance(attributes["private_gists"], (int, long)), attributes["private_gists"] - self._private_gists = github.GithubObject.ValuedAttribute(attributes["private_gists"]) + self._private_gists = self._makeIntAttribute(attributes["private_gists"]) if "public_gists" in attributes: # pragma no branch - assert attributes["public_gists"] is None or isinstance(attributes["public_gists"], (int, long)), attributes["public_gists"] - self._public_gists = github.GithubObject.ValuedAttribute(attributes["public_gists"]) + self._public_gists = self._makeIntAttribute(attributes["public_gists"]) if "public_repos" in attributes: # pragma no branch - assert attributes["public_repos"] is None or isinstance(attributes["public_repos"], (int, long)), attributes["public_repos"] - self._public_repos = github.GithubObject.ValuedAttribute(attributes["public_repos"]) + self._public_repos = self._makeIntAttribute(attributes["public_repos"]) if "received_events_url" in attributes: # pragma no branch - assert attributes["received_events_url"] is None or isinstance(attributes["received_events_url"], (str, unicode)), attributes["received_events_url"] - self._received_events_url = github.GithubObject.ValuedAttribute(attributes["received_events_url"]) + self._received_events_url = self._makeStringAttribute(attributes["received_events_url"]) if "repos_url" in attributes: # pragma no branch - assert attributes["repos_url"] is None or isinstance(attributes["repos_url"], (str, unicode)), attributes["repos_url"] - self._repos_url = github.GithubObject.ValuedAttribute(attributes["repos_url"]) + self._repos_url = self._makeStringAttribute(attributes["repos_url"]) if "starred_url" in attributes: # pragma no branch - assert attributes["starred_url"] is None or isinstance(attributes["starred_url"], (str, unicode)), attributes["starred_url"] - self._starred_url = github.GithubObject.ValuedAttribute(attributes["starred_url"]) + self._starred_url = self._makeStringAttribute(attributes["starred_url"]) if "subscriptions_url" in attributes: # pragma no branch - assert attributes["subscriptions_url"] is None or isinstance(attributes["subscriptions_url"], (str, unicode)), attributes["subscriptions_url"] - self._subscriptions_url = github.GithubObject.ValuedAttribute(attributes["subscriptions_url"]) + self._subscriptions_url = self._makeStringAttribute(attributes["subscriptions_url"]) if "total_private_repos" in attributes: # pragma no branch - assert attributes["total_private_repos"] is None or isinstance(attributes["total_private_repos"], (int, long)), attributes["total_private_repos"] - self._total_private_repos = github.GithubObject.ValuedAttribute(attributes["total_private_repos"]) + self._total_private_repos = self._makeIntAttribute(attributes["total_private_repos"]) if "type" in attributes: # pragma no branch - assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"] - self._type = github.GithubObject.ValuedAttribute(attributes["type"]) + self._type = self._makeStringAttribute(attributes["type"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/Notification.py b/github/Notification.py index 7f100840..6f8f04dd 100644 --- a/github/Notification.py +++ b/github/Notification.py @@ -119,29 +119,20 @@ class Notification(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (str, unicode)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeStringAttribute(attributes["id"]) if "last_read_at" in attributes: # pragma no branch - assert attributes["last_read_at"] is None or isinstance(attributes["last_read_at"], (str, unicode)), attributes["last_read_at"] - self._last_read_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["last_read_at"])) + self._last_read_at = self._makeDatetimeAttribute(attributes["last_read_at"]) if "repository" in attributes: # pragma no branch - assert attributes["repository"] is None or isinstance(attributes["repository"], dict), attributes["repository"] - self._repository = github.GithubObject.ValuedAttribute(None if attributes["repository"] is None else github.Repository.Repository(self._requester, self._headers, attributes["repository"], completed=False)) + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) if "subject" in attributes: # pragma no branch - assert attributes["subject"] is None or isinstance(attributes["subject"], dict), attributes["subject"] - self._subject = github.GithubObject.ValuedAttribute(None if attributes["subject"] is None else github.NotificationSubject.NotificationSubject(self._requester, self._headers, attributes["subject"], completed=False)) + self._subject = self._makeClassAttribute(github.NotificationSubject.NotificationSubject, attributes["subject"]) if "reason" in attributes: # pragma no branch - assert attributes["reason"] is None or isinstance(attributes["reason"], (str, unicode)), attributes["reason"] - self._reason = github.GithubObject.ValuedAttribute(attributes["reason"]) + self._reason = self._makeStringAttribute(attributes["reason"]) if "subscription_url" in attributes: # pragma no branch - assert attributes["subscription_url"] is None or isinstance(attributes["subscription_url"], (str, unicode)), attributes["subscription_url"] - self._subscription_url = github.GithubObject.ValuedAttribute(attributes["subscription_url"]) + self._subscription_url = self._makeStringAttribute(attributes["subscription_url"]) if "unread" in attributes: # pragma no branch - assert attributes["unread"] is None or isinstance(attributes["unread"], bool), attributes["unread"] - self._unread = github.GithubObject.ValuedAttribute(attributes["unread"]) + self._unread = self._makeBoolAttribute(attributes["unread"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/NotificationSubject.py b/github/NotificationSubject.py index bb9f7d5c..2d1cd03a 100644 --- a/github/NotificationSubject.py +++ b/github/NotificationSubject.py @@ -66,14 +66,10 @@ class NotificationSubject(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "title" in attributes: # pragma no branch - assert attributes["title"] is None or isinstance(attributes["title"], (str, unicode)), attributes["title"] - self._title = github.GithubObject.ValuedAttribute(attributes["title"]) + self._title = self._makeStringAttribute(attributes["title"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) if "latest_comment_url" in attributes: # pragma no branch - assert attributes["latest_comment_url"] is None or isinstance(attributes["latest_comment_url"], (str, unicode)), attributes["latest_comment_url"] - self._latest_comment_url = github.GithubObject.ValuedAttribute(attributes["latest_comment_url"]) + self._latest_comment_url = self._makeStringAttribute(attributes["latest_comment_url"]) if "type" in attributes: # pragma no branch - assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"] - self._type = github.GithubObject.ValuedAttribute(attributes["type"]) + self._type = self._makeStringAttribute(attributes["type"]) diff --git a/github/Organization.py b/github/Organization.py index c23ec55e..2f378a36 100644 --- a/github/Organization.py +++ b/github/Organization.py @@ -631,89 +631,60 @@ class Organization(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "avatar_url" in attributes: # pragma no branch - assert attributes["avatar_url"] is None or isinstance(attributes["avatar_url"], (str, unicode)), attributes["avatar_url"] - self._avatar_url = github.GithubObject.ValuedAttribute(attributes["avatar_url"]) + self._avatar_url = self._makeStringAttribute(attributes["avatar_url"]) if "billing_email" in attributes: # pragma no branch - assert attributes["billing_email"] is None or isinstance(attributes["billing_email"], (str, unicode)), attributes["billing_email"] - self._billing_email = github.GithubObject.ValuedAttribute(attributes["billing_email"]) + self._billing_email = self._makeStringAttribute(attributes["billing_email"]) if "blog" in attributes: # pragma no branch - assert attributes["blog"] is None or isinstance(attributes["blog"], (str, unicode)), attributes["blog"] - self._blog = github.GithubObject.ValuedAttribute(attributes["blog"]) + self._blog = self._makeStringAttribute(attributes["blog"]) if "collaborators" in attributes: # pragma no branch - assert attributes["collaborators"] is None or isinstance(attributes["collaborators"], (int, long)), attributes["collaborators"] - self._collaborators = github.GithubObject.ValuedAttribute(attributes["collaborators"]) + self._collaborators = self._makeIntAttribute(attributes["collaborators"]) if "company" in attributes: # pragma no branch - assert attributes["company"] is None or isinstance(attributes["company"], (str, unicode)), attributes["company"] - self._company = github.GithubObject.ValuedAttribute(attributes["company"]) + self._company = self._makeStringAttribute(attributes["company"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "disk_usage" in attributes: # pragma no branch - assert attributes["disk_usage"] is None or isinstance(attributes["disk_usage"], (int, long)), attributes["disk_usage"] - self._disk_usage = github.GithubObject.ValuedAttribute(attributes["disk_usage"]) + self._disk_usage = self._makeIntAttribute(attributes["disk_usage"]) if "email" in attributes: # pragma no branch - assert attributes["email"] is None or isinstance(attributes["email"], (str, unicode)), attributes["email"] - self._email = github.GithubObject.ValuedAttribute(attributes["email"]) + self._email = self._makeStringAttribute(attributes["email"]) if "events_url" in attributes: # pragma no branch - assert attributes["events_url"] is None or isinstance(attributes["events_url"], (str, unicode)), attributes["events_url"] - self._events_url = github.GithubObject.ValuedAttribute(attributes["events_url"]) + self._events_url = self._makeStringAttribute(attributes["events_url"]) if "followers" in attributes: # pragma no branch - assert attributes["followers"] is None or isinstance(attributes["followers"], (int, long)), attributes["followers"] - self._followers = github.GithubObject.ValuedAttribute(attributes["followers"]) + self._followers = self._makeIntAttribute(attributes["followers"]) if "following" in attributes: # pragma no branch - assert attributes["following"] is None or isinstance(attributes["following"], (int, long)), attributes["following"] - self._following = github.GithubObject.ValuedAttribute(attributes["following"]) + self._following = self._makeIntAttribute(attributes["following"]) if "gravatar_id" in attributes: # pragma no branch - assert attributes["gravatar_id"] is None or isinstance(attributes["gravatar_id"], (str, unicode)), attributes["gravatar_id"] - self._gravatar_id = github.GithubObject.ValuedAttribute(attributes["gravatar_id"]) + self._gravatar_id = self._makeStringAttribute(attributes["gravatar_id"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "location" in attributes: # pragma no branch - assert attributes["location"] is None or isinstance(attributes["location"], (str, unicode)), attributes["location"] - self._location = github.GithubObject.ValuedAttribute(attributes["location"]) + self._location = self._makeStringAttribute(attributes["location"]) if "login" in attributes: # pragma no branch - assert attributes["login"] is None or isinstance(attributes["login"], (str, unicode)), attributes["login"] - self._login = github.GithubObject.ValuedAttribute(attributes["login"]) + self._login = self._makeStringAttribute(attributes["login"]) if "members_url" in attributes: # pragma no branch - assert attributes["members_url"] is None or isinstance(attributes["members_url"], (str, unicode)), attributes["members_url"] - self._members_url = github.GithubObject.ValuedAttribute(attributes["members_url"]) + self._members_url = self._makeStringAttribute(attributes["members_url"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "owned_private_repos" in attributes: # pragma no branch - assert attributes["owned_private_repos"] is None or isinstance(attributes["owned_private_repos"], (int, long)), attributes["owned_private_repos"] - self._owned_private_repos = github.GithubObject.ValuedAttribute(attributes["owned_private_repos"]) + self._owned_private_repos = self._makeIntAttribute(attributes["owned_private_repos"]) if "plan" in attributes: # pragma no branch - assert attributes["plan"] is None or isinstance(attributes["plan"], dict), attributes["plan"] - self._plan = github.GithubObject.ValuedAttribute(None if attributes["plan"] is None else github.Plan.Plan(self._requester, self._headers, attributes["plan"], completed=False)) + self._plan = self._makeClassAttribute(github.Plan.Plan, attributes["plan"]) if "private_gists" in attributes: # pragma no branch - assert attributes["private_gists"] is None or isinstance(attributes["private_gists"], (int, long)), attributes["private_gists"] - self._private_gists = github.GithubObject.ValuedAttribute(attributes["private_gists"]) + self._private_gists = self._makeIntAttribute(attributes["private_gists"]) if "public_gists" in attributes: # pragma no branch - assert attributes["public_gists"] is None or isinstance(attributes["public_gists"], (int, long)), attributes["public_gists"] - self._public_gists = github.GithubObject.ValuedAttribute(attributes["public_gists"]) + self._public_gists = self._makeIntAttribute(attributes["public_gists"]) if "public_members_url" in attributes: # pragma no branch - assert attributes["public_members_url"] is None or isinstance(attributes["public_members_url"], (str, unicode)), attributes["public_members_url"] - self._public_members_url = github.GithubObject.ValuedAttribute(attributes["public_members_url"]) + self._public_members_url = self._makeStringAttribute(attributes["public_members_url"]) if "public_repos" in attributes: # pragma no branch - assert attributes["public_repos"] is None or isinstance(attributes["public_repos"], (int, long)), attributes["public_repos"] - self._public_repos = github.GithubObject.ValuedAttribute(attributes["public_repos"]) + self._public_repos = self._makeIntAttribute(attributes["public_repos"]) if "repos_url" in attributes: # pragma no branch - assert attributes["repos_url"] is None or isinstance(attributes["repos_url"], (str, unicode)), attributes["repos_url"] - self._repos_url = github.GithubObject.ValuedAttribute(attributes["repos_url"]) + self._repos_url = self._makeStringAttribute(attributes["repos_url"]) if "total_private_repos" in attributes: # pragma no branch - assert attributes["total_private_repos"] is None or isinstance(attributes["total_private_repos"], (int, long)), attributes["total_private_repos"] - self._total_private_repos = github.GithubObject.ValuedAttribute(attributes["total_private_repos"]) + self._total_private_repos = self._makeIntAttribute(attributes["total_private_repos"]) if "type" in attributes: # pragma no branch - assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"] - self._type = github.GithubObject.ValuedAttribute(attributes["type"]) + self._type = self._makeStringAttribute(attributes["type"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/Permissions.py b/github/Permissions.py index 68016a15..e41561d4 100644 --- a/github/Permissions.py +++ b/github/Permissions.py @@ -60,11 +60,8 @@ class Permissions(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "admin" in attributes: # pragma no branch - assert attributes["admin"] is None or isinstance(attributes["admin"], bool), attributes["admin"] - self._admin = github.GithubObject.ValuedAttribute(attributes["admin"]) + self._admin = self._makeBoolAttribute(attributes["admin"]) if "pull" in attributes: # pragma no branch - assert attributes["pull"] is None or isinstance(attributes["pull"], bool), attributes["pull"] - self._pull = github.GithubObject.ValuedAttribute(attributes["pull"]) + self._pull = self._makeBoolAttribute(attributes["pull"]) if "push" in attributes: # pragma no branch - assert attributes["push"] is None or isinstance(attributes["push"], bool), attributes["push"] - self._push = github.GithubObject.ValuedAttribute(attributes["push"]) + self._push = self._makeBoolAttribute(attributes["push"]) diff --git a/github/Plan.py b/github/Plan.py index 2a6d83f4..0582876a 100644 --- a/github/Plan.py +++ b/github/Plan.py @@ -68,14 +68,10 @@ class Plan(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "collaborators" in attributes: # pragma no branch - assert attributes["collaborators"] is None or isinstance(attributes["collaborators"], (int, long)), attributes["collaborators"] - self._collaborators = github.GithubObject.ValuedAttribute(attributes["collaborators"]) + self._collaborators = self._makeIntAttribute(attributes["collaborators"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "private_repos" in attributes: # pragma no branch - assert attributes["private_repos"] is None or isinstance(attributes["private_repos"], (int, long)), attributes["private_repos"] - self._private_repos = github.GithubObject.ValuedAttribute(attributes["private_repos"]) + self._private_repos = self._makeIntAttribute(attributes["private_repos"]) if "space" in attributes: # pragma no branch - assert attributes["space"] is None or isinstance(attributes["space"], (int, long)), attributes["space"] - self._space = github.GithubObject.ValuedAttribute(attributes["space"]) + self._space = self._makeIntAttribute(attributes["space"]) diff --git a/github/PullRequest.py b/github/PullRequest.py index 06214044..cc13f294 100644 --- a/github/PullRequest.py +++ b/github/PullRequest.py @@ -549,104 +549,70 @@ class PullRequest(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "additions" in attributes: # pragma no branch - assert attributes["additions"] is None or isinstance(attributes["additions"], (int, long)), attributes["additions"] - self._additions = github.GithubObject.ValuedAttribute(attributes["additions"]) + self._additions = self._makeIntAttribute(attributes["additions"]) if "assignee" in attributes: # pragma no branch - assert attributes["assignee"] is None or isinstance(attributes["assignee"], dict), attributes["assignee"] - self._assignee = github.GithubObject.ValuedAttribute(None if attributes["assignee"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["assignee"], completed=False)) + self._assignee = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["assignee"]) if "base" in attributes: # pragma no branch - assert attributes["base"] is None or isinstance(attributes["base"], dict), attributes["base"] - self._base = github.GithubObject.ValuedAttribute(None if attributes["base"] is None else github.PullRequestPart.PullRequestPart(self._requester, self._headers, attributes["base"], completed=False)) + self._base = self._makeClassAttribute(github.PullRequestPart.PullRequestPart, attributes["base"]) if "body" in attributes: # pragma no branch - assert attributes["body"] is None or isinstance(attributes["body"], (str, unicode)), attributes["body"] - self._body = github.GithubObject.ValuedAttribute(attributes["body"]) + self._body = self._makeStringAttribute(attributes["body"]) if "changed_files" in attributes: # pragma no branch - assert attributes["changed_files"] is None or isinstance(attributes["changed_files"], (int, long)), attributes["changed_files"] - self._changed_files = github.GithubObject.ValuedAttribute(attributes["changed_files"]) + self._changed_files = self._makeIntAttribute(attributes["changed_files"]) if "closed_at" in attributes: # pragma no branch - assert attributes["closed_at"] is None or isinstance(attributes["closed_at"], (str, unicode)), attributes["closed_at"] - self._closed_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["closed_at"])) + self._closed_at = self._makeDatetimeAttribute(attributes["closed_at"]) if "comments" in attributes: # pragma no branch - assert attributes["comments"] is None or isinstance(attributes["comments"], (int, long)), attributes["comments"] - self._comments = github.GithubObject.ValuedAttribute(attributes["comments"]) + self._comments = self._makeIntAttribute(attributes["comments"]) if "comments_url" in attributes: # pragma no branch - assert attributes["comments_url"] is None or isinstance(attributes["comments_url"], (str, unicode)), attributes["comments_url"] - self._comments_url = github.GithubObject.ValuedAttribute(attributes["comments_url"]) + self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commits" in attributes: # pragma no branch - assert attributes["commits"] is None or isinstance(attributes["commits"], (int, long)), attributes["commits"] - self._commits = github.GithubObject.ValuedAttribute(attributes["commits"]) + self._commits = self._makeIntAttribute(attributes["commits"]) if "commits_url" in attributes: # pragma no branch - assert attributes["commits_url"] is None or isinstance(attributes["commits_url"], (str, unicode)), attributes["commits_url"] - self._commits_url = github.GithubObject.ValuedAttribute(attributes["commits_url"]) + self._commits_url = self._makeStringAttribute(attributes["commits_url"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "deletions" in attributes: # pragma no branch - assert attributes["deletions"] is None or isinstance(attributes["deletions"], (int, long)), attributes["deletions"] - self._deletions = github.GithubObject.ValuedAttribute(attributes["deletions"]) + self._deletions = self._makeIntAttribute(attributes["deletions"]) if "diff_url" in attributes: # pragma no branch - assert attributes["diff_url"] is None or isinstance(attributes["diff_url"], (str, unicode)), attributes["diff_url"] - self._diff_url = github.GithubObject.ValuedAttribute(attributes["diff_url"]) + self._diff_url = self._makeStringAttribute(attributes["diff_url"]) if "head" in attributes: # pragma no branch - assert attributes["head"] is None or isinstance(attributes["head"], dict), attributes["head"] - self._head = github.GithubObject.ValuedAttribute(None if attributes["head"] is None else github.PullRequestPart.PullRequestPart(self._requester, self._headers, attributes["head"], completed=False)) + self._head = self._makeClassAttribute(github.PullRequestPart.PullRequestPart, attributes["head"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "issue_url" in attributes: # pragma no branch - assert attributes["issue_url"] is None or isinstance(attributes["issue_url"], (str, unicode)), attributes["issue_url"] - self._issue_url = github.GithubObject.ValuedAttribute(attributes["issue_url"]) + self._issue_url = self._makeStringAttribute(attributes["issue_url"]) if "merge_commit_sha" in attributes: # pragma no branch - assert attributes["merge_commit_sha"] is None or isinstance(attributes["merge_commit_sha"], (str, unicode)), attributes["merge_commit_sha"] - self._merge_commit_sha = github.GithubObject.ValuedAttribute(attributes["merge_commit_sha"]) + self._merge_commit_sha = self._makeStringAttribute(attributes["merge_commit_sha"]) if "mergeable" in attributes: # pragma no branch - assert attributes["mergeable"] is None or isinstance(attributes["mergeable"], bool), attributes["mergeable"] - self._mergeable = github.GithubObject.ValuedAttribute(attributes["mergeable"]) + self._mergeable = self._makeBoolAttribute(attributes["mergeable"]) if "mergeable_state" in attributes: # pragma no branch - assert attributes["mergeable_state"] is None or isinstance(attributes["mergeable_state"], (str, unicode)), attributes["mergeable_state"] - self._mergeable_state = github.GithubObject.ValuedAttribute(attributes["mergeable_state"]) + self._mergeable_state = self._makeStringAttribute(attributes["mergeable_state"]) if "merged" in attributes: # pragma no branch - assert attributes["merged"] is None or isinstance(attributes["merged"], bool), attributes["merged"] - self._merged = github.GithubObject.ValuedAttribute(attributes["merged"]) + self._merged = self._makeBoolAttribute(attributes["merged"]) if "merged_at" in attributes: # pragma no branch - assert attributes["merged_at"] is None or isinstance(attributes["merged_at"], (str, unicode)), attributes["merged_at"] - self._merged_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["merged_at"])) + self._merged_at = self._makeDatetimeAttribute(attributes["merged_at"]) if "merged_by" in attributes: # pragma no branch - assert attributes["merged_by"] is None or isinstance(attributes["merged_by"], dict), attributes["merged_by"] - self._merged_by = github.GithubObject.ValuedAttribute(None if attributes["merged_by"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["merged_by"], completed=False)) + self._merged_by = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["merged_by"]) if "milestone" in attributes: # pragma no branch - assert attributes["milestone"] is None or isinstance(attributes["milestone"], dict), attributes["milestone"] - self._milestone = github.GithubObject.ValuedAttribute(None if attributes["milestone"] is None else github.Milestone.Milestone(self._requester, self._headers, attributes["milestone"], completed=False)) + self._milestone = self._makeClassAttribute(github.Milestone.Milestone, attributes["milestone"]) if "number" in attributes: # pragma no branch - assert attributes["number"] is None or isinstance(attributes["number"], (int, long)), attributes["number"] - self._number = github.GithubObject.ValuedAttribute(attributes["number"]) + self._number = self._makeIntAttribute(attributes["number"]) if "patch_url" in attributes: # pragma no branch - assert attributes["patch_url"] is None or isinstance(attributes["patch_url"], (str, unicode)), attributes["patch_url"] - self._patch_url = github.GithubObject.ValuedAttribute(attributes["patch_url"]) + self._patch_url = self._makeStringAttribute(attributes["patch_url"]) if "review_comment_url" in attributes: # pragma no branch - assert attributes["review_comment_url"] is None or isinstance(attributes["review_comment_url"], (str, unicode)), attributes["review_comment_url"] - self._review_comment_url = github.GithubObject.ValuedAttribute(attributes["review_comment_url"]) + self._review_comment_url = self._makeStringAttribute(attributes["review_comment_url"]) if "review_comments" in attributes: # pragma no branch - assert attributes["review_comments"] is None or isinstance(attributes["review_comments"], (int, long)), attributes["review_comments"] - self._review_comments = github.GithubObject.ValuedAttribute(attributes["review_comments"]) + self._review_comments = self._makeIntAttribute(attributes["review_comments"]) if "review_comments_url" in attributes: # pragma no branch - assert attributes["review_comments_url"] is None or isinstance(attributes["review_comments_url"], (str, unicode)), attributes["review_comments_url"] - self._review_comments_url = github.GithubObject.ValuedAttribute(attributes["review_comments_url"]) + self._review_comments_url = self._makeStringAttribute(attributes["review_comments_url"]) if "state" in attributes: # pragma no branch - assert attributes["state"] is None or isinstance(attributes["state"], (str, unicode)), attributes["state"] - self._state = github.GithubObject.ValuedAttribute(attributes["state"]) + self._state = self._makeStringAttribute(attributes["state"]) if "title" in attributes: # pragma no branch - assert attributes["title"] is None or isinstance(attributes["title"], (str, unicode)), attributes["title"] - self._title = github.GithubObject.ValuedAttribute(attributes["title"]) + self._title = self._makeStringAttribute(attributes["title"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch - assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = github.GithubObject.ValuedAttribute(None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/PullRequestComment.py b/github/PullRequestComment.py index b8f1e018..b86c9000 100644 --- a/github/PullRequestComment.py +++ b/github/PullRequestComment.py @@ -193,44 +193,30 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "body" in attributes: # pragma no branch - assert attributes["body"] is None or isinstance(attributes["body"], (str, unicode)), attributes["body"] - self._body = github.GithubObject.ValuedAttribute(attributes["body"]) + self._body = self._makeStringAttribute(attributes["body"]) if "commit_id" in attributes: # pragma no branch - assert attributes["commit_id"] is None or isinstance(attributes["commit_id"], (str, unicode)), attributes["commit_id"] - self._commit_id = github.GithubObject.ValuedAttribute(attributes["commit_id"]) + self._commit_id = self._makeStringAttribute(attributes["commit_id"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "diff_hunk" in attributes: # pragma no branch - assert attributes["diff_hunk"] is None or isinstance(attributes["diff_hunk"], (str, unicode)), attributes["diff_hunk"] - self._diff_hunk = github.GithubObject.ValuedAttribute(attributes["diff_hunk"]) + self._diff_hunk = self._makeStringAttribute(attributes["diff_hunk"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "original_commit_id" in attributes: # pragma no branch - assert attributes["original_commit_id"] is None or isinstance(attributes["original_commit_id"], (str, unicode)), attributes["original_commit_id"] - self._original_commit_id = github.GithubObject.ValuedAttribute(attributes["original_commit_id"]) + self._original_commit_id = self._makeStringAttribute(attributes["original_commit_id"]) if "original_position" in attributes: # pragma no branch - assert attributes["original_position"] is None or isinstance(attributes["original_position"], (int, long)), attributes["original_position"] - self._original_position = github.GithubObject.ValuedAttribute(attributes["original_position"]) + self._original_position = self._makeIntAttribute(attributes["original_position"]) if "path" in attributes: # pragma no branch - assert attributes["path"] is None or isinstance(attributes["path"], (str, unicode)), attributes["path"] - self._path = github.GithubObject.ValuedAttribute(attributes["path"]) + self._path = self._makeStringAttribute(attributes["path"]) if "position" in attributes: # pragma no branch - assert attributes["position"] is None or isinstance(attributes["position"], (int, long)), attributes["position"] - self._position = github.GithubObject.ValuedAttribute(attributes["position"]) + self._position = self._makeIntAttribute(attributes["position"]) if "pull_request_url" in attributes: # pragma no branch - assert attributes["pull_request_url"] is None or isinstance(attributes["pull_request_url"], (str, unicode)), attributes["pull_request_url"] - self._pull_request_url = github.GithubObject.ValuedAttribute(attributes["pull_request_url"]) + self._pull_request_url = self._makeStringAttribute(attributes["pull_request_url"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "user" in attributes: # pragma no branch - assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = github.GithubObject.ValuedAttribute(None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/PullRequestMergeStatus.py b/github/PullRequestMergeStatus.py index 4f1cef0a..8e3e8a20 100644 --- a/github/PullRequestMergeStatus.py +++ b/github/PullRequestMergeStatus.py @@ -61,11 +61,8 @@ class PullRequestMergeStatus(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "merged" in attributes: # pragma no branch - assert attributes["merged"] is None or isinstance(attributes["merged"], bool), attributes["merged"] - self._merged = github.GithubObject.ValuedAttribute(attributes["merged"]) + self._merged = self._makeBoolAttribute(attributes["merged"]) if "message" in attributes: # pragma no branch - assert attributes["message"] is None or isinstance(attributes["message"], (str, unicode)), attributes["message"] - self._message = github.GithubObject.ValuedAttribute(attributes["message"]) + self._message = self._makeStringAttribute(attributes["message"]) if "sha" in attributes: # pragma no branch - assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] - self._sha = github.GithubObject.ValuedAttribute(attributes["sha"]) + self._sha = self._makeStringAttribute(attributes["sha"]) diff --git a/github/PullRequestPart.py b/github/PullRequestPart.py index 754bcb09..1b559535 100644 --- a/github/PullRequestPart.py +++ b/github/PullRequestPart.py @@ -79,17 +79,12 @@ class PullRequestPart(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "label" in attributes: # pragma no branch - assert attributes["label"] is None or isinstance(attributes["label"], (str, unicode)), attributes["label"] - self._label = github.GithubObject.ValuedAttribute(attributes["label"]) + self._label = self._makeStringAttribute(attributes["label"]) if "ref" in attributes: # pragma no branch - assert attributes["ref"] is None or isinstance(attributes["ref"], (str, unicode)), attributes["ref"] - self._ref = github.GithubObject.ValuedAttribute(attributes["ref"]) + self._ref = self._makeStringAttribute(attributes["ref"]) if "repo" in attributes: # pragma no branch - assert attributes["repo"] is None or isinstance(attributes["repo"], dict), attributes["repo"] - self._repo = github.GithubObject.ValuedAttribute(None if attributes["repo"] is None else github.Repository.Repository(self._requester, self._headers, attributes["repo"], completed=False)) + self._repo = self._makeClassAttribute(github.Repository.Repository, attributes["repo"]) if "sha" in attributes: # pragma no branch - assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] - self._sha = github.GithubObject.ValuedAttribute(attributes["sha"]) + self._sha = self._makeStringAttribute(attributes["sha"]) if "user" in attributes: # pragma no branch - assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = github.GithubObject.ValuedAttribute(None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False)) + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/github/Rate.py b/github/Rate.py index eb4592e8..1a1b1fe0 100644 --- a/github/Rate.py +++ b/github/Rate.py @@ -58,11 +58,8 @@ class Rate(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "limit" in attributes: # pragma no branch - assert attributes["limit"] is None or isinstance(attributes["limit"], (int, long)), attributes["limit"] - self._limit = github.GithubObject.ValuedAttribute(attributes["limit"]) + self._limit = self._makeIntAttribute(attributes["limit"]) if "remaining" in attributes: # pragma no branch - assert attributes["remaining"] is None or isinstance(attributes["remaining"], (int, long)), attributes["remaining"] - self._remaining = github.GithubObject.ValuedAttribute(attributes["remaining"]) + self._remaining = self._makeIntAttribute(attributes["remaining"]) if "reset" in attributes: # pragma no branch - assert attributes["reset"] is None or isinstance(attributes["reset"], (int, long)), attributes["reset"] - self._reset = github.GithubObject.ValuedAttribute(datetime.datetime.utcfromtimestamp(attributes["reset"])) + self._reset = self._makeTimestampAttribute(attributes["reset"]) diff --git a/github/RateLimit.py b/github/RateLimit.py index 39b2d860..cd174557 100644 --- a/github/RateLimit.py +++ b/github/RateLimit.py @@ -42,5 +42,4 @@ class RateLimit(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "rate" in attributes: # pragma no branch - assert attributes["rate"] is None or isinstance(attributes["rate"], dict), attributes["rate"] - self._rate = github.GithubObject.ValuedAttribute(None if attributes["rate"] is None else github.Rate.Rate(self._requester, self._headers, attributes["rate"], completed=False)) + self._rate = self._makeClassAttribute(github.Rate.Rate, attributes["rate"]) diff --git a/github/Repository.py b/github/Repository.py index 7541620d..8abf7886 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -1960,212 +1960,142 @@ class Repository(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "archive_url" in attributes: # pragma no branch - assert attributes["archive_url"] is None or isinstance(attributes["archive_url"], (str, unicode)), attributes["archive_url"] - self._archive_url = github.GithubObject.ValuedAttribute(attributes["archive_url"]) + self._archive_url = self._makeStringAttribute(attributes["archive_url"]) if "assignees_url" in attributes: # pragma no branch - assert attributes["assignees_url"] is None or isinstance(attributes["assignees_url"], (str, unicode)), attributes["assignees_url"] - self._assignees_url = github.GithubObject.ValuedAttribute(attributes["assignees_url"]) + self._assignees_url = self._makeStringAttribute(attributes["assignees_url"]) if "blobs_url" in attributes: # pragma no branch - assert attributes["blobs_url"] is None or isinstance(attributes["blobs_url"], (str, unicode)), attributes["blobs_url"] - self._blobs_url = github.GithubObject.ValuedAttribute(attributes["blobs_url"]) + self._blobs_url = self._makeStringAttribute(attributes["blobs_url"]) if "branches_url" in attributes: # pragma no branch - assert attributes["branches_url"] is None or isinstance(attributes["branches_url"], (str, unicode)), attributes["branches_url"] - self._branches_url = github.GithubObject.ValuedAttribute(attributes["branches_url"]) + self._branches_url = self._makeStringAttribute(attributes["branches_url"]) if "clone_url" in attributes: # pragma no branch - assert attributes["clone_url"] is None or isinstance(attributes["clone_url"], (str, unicode)), attributes["clone_url"] - self._clone_url = github.GithubObject.ValuedAttribute(attributes["clone_url"]) + self._clone_url = self._makeStringAttribute(attributes["clone_url"]) if "collaborators_url" in attributes: # pragma no branch - assert attributes["collaborators_url"] is None or isinstance(attributes["collaborators_url"], (str, unicode)), attributes["collaborators_url"] - self._collaborators_url = github.GithubObject.ValuedAttribute(attributes["collaborators_url"]) + self._collaborators_url = self._makeStringAttribute(attributes["collaborators_url"]) if "comments_url" in attributes: # pragma no branch - assert attributes["comments_url"] is None or isinstance(attributes["comments_url"], (str, unicode)), attributes["comments_url"] - self._comments_url = github.GithubObject.ValuedAttribute(attributes["comments_url"]) + self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commits_url" in attributes: # pragma no branch - assert attributes["commits_url"] is None or isinstance(attributes["commits_url"], (str, unicode)), attributes["commits_url"] - self._commits_url = github.GithubObject.ValuedAttribute(attributes["commits_url"]) + self._commits_url = self._makeStringAttribute(attributes["commits_url"]) if "compare_url" in attributes: # pragma no branch - assert attributes["compare_url"] is None or isinstance(attributes["compare_url"], (str, unicode)), attributes["compare_url"] - self._compare_url = github.GithubObject.ValuedAttribute(attributes["compare_url"]) + self._compare_url = self._makeStringAttribute(attributes["compare_url"]) if "contents_url" in attributes: # pragma no branch - assert attributes["contents_url"] is None or isinstance(attributes["contents_url"], (str, unicode)), attributes["contents_url"] - self._contents_url = github.GithubObject.ValuedAttribute(attributes["contents_url"]) + self._contents_url = self._makeStringAttribute(attributes["contents_url"]) if "contributors_url" in attributes: # pragma no branch - assert attributes["contributors_url"] is None or isinstance(attributes["contributors_url"], (str, unicode)), attributes["contributors_url"] - self._contributors_url = github.GithubObject.ValuedAttribute(attributes["contributors_url"]) + self._contributors_url = self._makeStringAttribute(attributes["contributors_url"]) if "created_at" in attributes: # pragma no branch - assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] - self._created_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_at"])) + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "default_branch" in attributes: # pragma no branch - assert attributes["default_branch"] is None or isinstance(attributes["default_branch"], (str, unicode)), attributes["default_branch"] - self._default_branch = github.GithubObject.ValuedAttribute(attributes["default_branch"]) + self._default_branch = self._makeStringAttribute(attributes["default_branch"]) if "description" in attributes: # pragma no branch - assert attributes["description"] is None or isinstance(attributes["description"], (str, unicode)), attributes["description"] - self._description = github.GithubObject.ValuedAttribute(attributes["description"]) + self._description = self._makeStringAttribute(attributes["description"]) if "downloads_url" in attributes: # pragma no branch - assert attributes["downloads_url"] is None or isinstance(attributes["downloads_url"], (str, unicode)), attributes["downloads_url"] - self._downloads_url = github.GithubObject.ValuedAttribute(attributes["downloads_url"]) + self._downloads_url = self._makeStringAttribute(attributes["downloads_url"]) if "events_url" in attributes: # pragma no branch - assert attributes["events_url"] is None or isinstance(attributes["events_url"], (str, unicode)), attributes["events_url"] - self._events_url = github.GithubObject.ValuedAttribute(attributes["events_url"]) + self._events_url = self._makeStringAttribute(attributes["events_url"]) if "fork" in attributes: # pragma no branch - assert attributes["fork"] is None or isinstance(attributes["fork"], bool), attributes["fork"] - self._fork = github.GithubObject.ValuedAttribute(attributes["fork"]) + self._fork = self._makeBoolAttribute(attributes["fork"]) if "forks" in attributes: # pragma no branch - assert attributes["forks"] is None or isinstance(attributes["forks"], (int, long)), attributes["forks"] - self._forks = github.GithubObject.ValuedAttribute(attributes["forks"]) + self._forks = self._makeIntAttribute(attributes["forks"]) if "forks_count" in attributes: # pragma no branch - assert attributes["forks_count"] is None or isinstance(attributes["forks_count"], (int, long)), attributes["forks_count"] - self._forks_count = github.GithubObject.ValuedAttribute(attributes["forks_count"]) + self._forks_count = self._makeIntAttribute(attributes["forks_count"]) if "forks_url" in attributes: # pragma no branch - assert attributes["forks_url"] is None or isinstance(attributes["forks_url"], (str, unicode)), attributes["forks_url"] - self._forks_url = github.GithubObject.ValuedAttribute(attributes["forks_url"]) + self._forks_url = self._makeStringAttribute(attributes["forks_url"]) if "full_name" in attributes: # pragma no branch - assert attributes["full_name"] is None or isinstance(attributes["full_name"], (str, unicode)), attributes["full_name"] - self._full_name = github.GithubObject.ValuedAttribute(attributes["full_name"]) + self._full_name = self._makeStringAttribute(attributes["full_name"]) if "git_commits_url" in attributes: # pragma no branch - assert attributes["git_commits_url"] is None or isinstance(attributes["git_commits_url"], (str, unicode)), attributes["git_commits_url"] - self._git_commits_url = github.GithubObject.ValuedAttribute(attributes["git_commits_url"]) + self._git_commits_url = self._makeStringAttribute(attributes["git_commits_url"]) if "git_refs_url" in attributes: # pragma no branch - assert attributes["git_refs_url"] is None or isinstance(attributes["git_refs_url"], (str, unicode)), attributes["git_refs_url"] - self._git_refs_url = github.GithubObject.ValuedAttribute(attributes["git_refs_url"]) + self._git_refs_url = self._makeStringAttribute(attributes["git_refs_url"]) if "git_tags_url" in attributes: # pragma no branch - assert attributes["git_tags_url"] is None or isinstance(attributes["git_tags_url"], (str, unicode)), attributes["git_tags_url"] - self._git_tags_url = github.GithubObject.ValuedAttribute(attributes["git_tags_url"]) + self._git_tags_url = self._makeStringAttribute(attributes["git_tags_url"]) if "git_url" in attributes: # pragma no branch - assert attributes["git_url"] is None or isinstance(attributes["git_url"], (str, unicode)), attributes["git_url"] - self._git_url = github.GithubObject.ValuedAttribute(attributes["git_url"]) + self._git_url = self._makeStringAttribute(attributes["git_url"]) if "has_downloads" in attributes: # pragma no branch - assert attributes["has_downloads"] is None or isinstance(attributes["has_downloads"], bool), attributes["has_downloads"] - self._has_downloads = github.GithubObject.ValuedAttribute(attributes["has_downloads"]) + self._has_downloads = self._makeBoolAttribute(attributes["has_downloads"]) if "has_issues" in attributes: # pragma no branch - assert attributes["has_issues"] is None or isinstance(attributes["has_issues"], bool), attributes["has_issues"] - self._has_issues = github.GithubObject.ValuedAttribute(attributes["has_issues"]) + self._has_issues = self._makeBoolAttribute(attributes["has_issues"]) if "has_wiki" in attributes: # pragma no branch - assert attributes["has_wiki"] is None or isinstance(attributes["has_wiki"], bool), attributes["has_wiki"] - self._has_wiki = github.GithubObject.ValuedAttribute(attributes["has_wiki"]) + self._has_wiki = self._makeBoolAttribute(attributes["has_wiki"]) if "homepage" in attributes: # pragma no branch - assert attributes["homepage"] is None or isinstance(attributes["homepage"], (str, unicode)), attributes["homepage"] - self._homepage = github.GithubObject.ValuedAttribute(attributes["homepage"]) + self._homepage = self._makeStringAttribute(attributes["homepage"]) if "hooks_url" in attributes: # pragma no branch - assert attributes["hooks_url"] is None or isinstance(attributes["hooks_url"], (str, unicode)), attributes["hooks_url"] - self._hooks_url = github.GithubObject.ValuedAttribute(attributes["hooks_url"]) + self._hooks_url = self._makeStringAttribute(attributes["hooks_url"]) if "html_url" in attributes: # pragma no branch - assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] - self._html_url = github.GithubObject.ValuedAttribute(attributes["html_url"]) + self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "issue_comment_url" in attributes: # pragma no branch - assert attributes["issue_comment_url"] is None or isinstance(attributes["issue_comment_url"], (str, unicode)), attributes["issue_comment_url"] - self._issue_comment_url = github.GithubObject.ValuedAttribute(attributes["issue_comment_url"]) + self._issue_comment_url = self._makeStringAttribute(attributes["issue_comment_url"]) if "issue_events_url" in attributes: # pragma no branch - assert attributes["issue_events_url"] is None or isinstance(attributes["issue_events_url"], (str, unicode)), attributes["issue_events_url"] - self._issue_events_url = github.GithubObject.ValuedAttribute(attributes["issue_events_url"]) + self._issue_events_url = self._makeStringAttribute(attributes["issue_events_url"]) if "issues_url" in attributes: # pragma no branch - assert attributes["issues_url"] is None or isinstance(attributes["issues_url"], (str, unicode)), attributes["issues_url"] - self._issues_url = github.GithubObject.ValuedAttribute(attributes["issues_url"]) + self._issues_url = self._makeStringAttribute(attributes["issues_url"]) if "keys_url" in attributes: # pragma no branch - assert attributes["keys_url"] is None or isinstance(attributes["keys_url"], (str, unicode)), attributes["keys_url"] - self._keys_url = github.GithubObject.ValuedAttribute(attributes["keys_url"]) + self._keys_url = self._makeStringAttribute(attributes["keys_url"]) if "labels_url" in attributes: # pragma no branch - assert attributes["labels_url"] is None or isinstance(attributes["labels_url"], (str, unicode)), attributes["labels_url"] - self._labels_url = github.GithubObject.ValuedAttribute(attributes["labels_url"]) + self._labels_url = self._makeStringAttribute(attributes["labels_url"]) if "language" in attributes: # pragma no branch - assert attributes["language"] is None or isinstance(attributes["language"], (str, unicode)), attributes["language"] - self._language = github.GithubObject.ValuedAttribute(attributes["language"]) + self._language = self._makeStringAttribute(attributes["language"]) if "languages_url" in attributes: # pragma no branch - assert attributes["languages_url"] is None or isinstance(attributes["languages_url"], (str, unicode)), attributes["languages_url"] - self._languages_url = github.GithubObject.ValuedAttribute(attributes["languages_url"]) + self._languages_url = self._makeStringAttribute(attributes["languages_url"]) if "master_branch" in attributes: # pragma no branch - assert attributes["master_branch"] is None or isinstance(attributes["master_branch"], (str, unicode)), attributes["master_branch"] - self._master_branch = github.GithubObject.ValuedAttribute(attributes["master_branch"]) + self._master_branch = self._makeStringAttribute(attributes["master_branch"]) if "merges_url" in attributes: # pragma no branch - assert attributes["merges_url"] is None or isinstance(attributes["merges_url"], (str, unicode)), attributes["merges_url"] - self._merges_url = github.GithubObject.ValuedAttribute(attributes["merges_url"]) + self._merges_url = self._makeStringAttribute(attributes["merges_url"]) if "milestones_url" in attributes: # pragma no branch - assert attributes["milestones_url"] is None or isinstance(attributes["milestones_url"], (str, unicode)), attributes["milestones_url"] - self._milestones_url = github.GithubObject.ValuedAttribute(attributes["milestones_url"]) + self._milestones_url = self._makeStringAttribute(attributes["milestones_url"]) if "mirror_url" in attributes: # pragma no branch - assert attributes["mirror_url"] is None or isinstance(attributes["mirror_url"], (str, unicode)), attributes["mirror_url"] - self._mirror_url = github.GithubObject.ValuedAttribute(attributes["mirror_url"]) + self._mirror_url = self._makeStringAttribute(attributes["mirror_url"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "network_count" in attributes: # pragma no branch - assert attributes["network_count"] is None or isinstance(attributes["network_count"], (int, long)), attributes["network_count"] - self._network_count = github.GithubObject.ValuedAttribute(attributes["network_count"]) + self._network_count = self._makeIntAttribute(attributes["network_count"]) if "notifications_url" in attributes: # pragma no branch - assert attributes["notifications_url"] is None or isinstance(attributes["notifications_url"], (str, unicode)), attributes["notifications_url"] - self._notifications_url = github.GithubObject.ValuedAttribute(attributes["notifications_url"]) + self._notifications_url = self._makeStringAttribute(attributes["notifications_url"]) if "open_issues" in attributes: # pragma no branch - assert attributes["open_issues"] is None or isinstance(attributes["open_issues"], (int, long)), attributes["open_issues"] - self._open_issues = github.GithubObject.ValuedAttribute(attributes["open_issues"]) + self._open_issues = self._makeIntAttribute(attributes["open_issues"]) if "open_issues_count" in attributes: # pragma no branch - assert attributes["open_issues_count"] is None or isinstance(attributes["open_issues_count"], (int, long)), attributes["open_issues_count"] - self._open_issues_count = github.GithubObject.ValuedAttribute(attributes["open_issues_count"]) + self._open_issues_count = self._makeIntAttribute(attributes["open_issues_count"]) if "organization" in attributes: # pragma no branch - assert attributes["organization"] is None or isinstance(attributes["organization"], dict), attributes["organization"] - self._organization = github.GithubObject.ValuedAttribute(None if attributes["organization"] is None else github.Organization.Organization(self._requester, self._headers, attributes["organization"], completed=False)) + self._organization = self._makeClassAttribute(github.Organization.Organization, attributes["organization"]) if "owner" in attributes: # pragma no branch - assert attributes["owner"] is None or isinstance(attributes["owner"], dict), attributes["owner"] - self._owner = github.GithubObject.ValuedAttribute(None if attributes["owner"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["owner"], completed=False)) + self._owner = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["owner"]) if "parent" in attributes: # pragma no branch - assert attributes["parent"] is None or isinstance(attributes["parent"], dict), attributes["parent"] - self._parent = github.GithubObject.ValuedAttribute(None if attributes["parent"] is None else Repository(self._requester, self._headers, attributes["parent"], completed=False)) + self._parent = self._makeClassAttribute(Repository, attributes["parent"]) if "permissions" in attributes: # pragma no branch - assert attributes["permissions"] is None or isinstance(attributes["permissions"], dict), attributes["permissions"] - self._permissions = github.GithubObject.ValuedAttribute(None if attributes["permissions"] is None else github.Permissions.Permissions(self._requester, self._headers, attributes["permissions"], completed=False)) + self._permissions = self._makeClassAttribute(github.Permissions.Permissions, attributes["permissions"]) if "private" in attributes: # pragma no branch - assert attributes["private"] is None or isinstance(attributes["private"], bool), attributes["private"] - self._private = github.GithubObject.ValuedAttribute(attributes["private"]) + self._private = self._makeBoolAttribute(attributes["private"]) if "pulls_url" in attributes: # pragma no branch - assert attributes["pulls_url"] is None or isinstance(attributes["pulls_url"], (str, unicode)), attributes["pulls_url"] - self._pulls_url = github.GithubObject.ValuedAttribute(attributes["pulls_url"]) + self._pulls_url = self._makeStringAttribute(attributes["pulls_url"]) if "pushed_at" in attributes: # pragma no branch - assert attributes["pushed_at"] is None or isinstance(attributes["pushed_at"], (str, unicode)), attributes["pushed_at"] - self._pushed_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["pushed_at"])) + self._pushed_at = self._makeDatetimeAttribute(attributes["pushed_at"]) if "size" in attributes: # pragma no branch - assert attributes["size"] is None or isinstance(attributes["size"], (int, long)), attributes["size"] - self._size = github.GithubObject.ValuedAttribute(attributes["size"]) + self._size = self._makeIntAttribute(attributes["size"]) if "source" in attributes: # pragma no branch - assert attributes["source"] is None or isinstance(attributes["source"], dict), attributes["source"] - self._source = github.GithubObject.ValuedAttribute(None if attributes["source"] is None else Repository(self._requester, self._headers, attributes["source"], completed=False)) + self._source = self._makeClassAttribute(Repository, attributes["source"]) if "ssh_url" in attributes: # pragma no branch - assert attributes["ssh_url"] is None or isinstance(attributes["ssh_url"], (str, unicode)), attributes["ssh_url"] - self._ssh_url = github.GithubObject.ValuedAttribute(attributes["ssh_url"]) + self._ssh_url = self._makeStringAttribute(attributes["ssh_url"]) if "stargazers_url" in attributes: # pragma no branch - assert attributes["stargazers_url"] is None or isinstance(attributes["stargazers_url"], (str, unicode)), attributes["stargazers_url"] - self._stargazers_url = github.GithubObject.ValuedAttribute(attributes["stargazers_url"]) + self._stargazers_url = self._makeStringAttribute(attributes["stargazers_url"]) if "statuses_url" in attributes: # pragma no branch - assert attributes["statuses_url"] is None or isinstance(attributes["statuses_url"], (str, unicode)), attributes["statuses_url"] - self._statuses_url = github.GithubObject.ValuedAttribute(attributes["statuses_url"]) + self._statuses_url = self._makeStringAttribute(attributes["statuses_url"]) if "subscribers_url" in attributes: # pragma no branch - assert attributes["subscribers_url"] is None or isinstance(attributes["subscribers_url"], (str, unicode)), attributes["subscribers_url"] - self._subscribers_url = github.GithubObject.ValuedAttribute(attributes["subscribers_url"]) + self._subscribers_url = self._makeStringAttribute(attributes["subscribers_url"]) if "subscription_url" in attributes: # pragma no branch - assert attributes["subscription_url"] is None or isinstance(attributes["subscription_url"], (str, unicode)), attributes["subscription_url"] - self._subscription_url = github.GithubObject.ValuedAttribute(attributes["subscription_url"]) + self._subscription_url = self._makeStringAttribute(attributes["subscription_url"]) if "svn_url" in attributes: # pragma no branch - assert attributes["svn_url"] is None or isinstance(attributes["svn_url"], (str, unicode)), attributes["svn_url"] - self._svn_url = github.GithubObject.ValuedAttribute(attributes["svn_url"]) + self._svn_url = self._makeStringAttribute(attributes["svn_url"]) if "tags_url" in attributes: # pragma no branch - assert attributes["tags_url"] is None or isinstance(attributes["tags_url"], (str, unicode)), attributes["tags_url"] - self._tags_url = github.GithubObject.ValuedAttribute(attributes["tags_url"]) + self._tags_url = self._makeStringAttribute(attributes["tags_url"]) if "teams_url" in attributes: # pragma no branch - assert attributes["teams_url"] is None or isinstance(attributes["teams_url"], (str, unicode)), attributes["teams_url"] - self._teams_url = github.GithubObject.ValuedAttribute(attributes["teams_url"]) + self._teams_url = self._makeStringAttribute(attributes["teams_url"]) if "trees_url" in attributes: # pragma no branch - assert attributes["trees_url"] is None or isinstance(attributes["trees_url"], (str, unicode)), attributes["trees_url"] - self._trees_url = github.GithubObject.ValuedAttribute(attributes["trees_url"]) + self._trees_url = self._makeStringAttribute(attributes["trees_url"]) if "updated_at" in attributes: # pragma no branch - assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"] - self._updated_at = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["updated_at"])) + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) if "watchers" in attributes: # pragma no branch - assert attributes["watchers"] is None or isinstance(attributes["watchers"], (int, long)), attributes["watchers"] - self._watchers = github.GithubObject.ValuedAttribute(attributes["watchers"]) + self._watchers = self._makeIntAttribute(attributes["watchers"]) if "watchers_count" in attributes: # pragma no branch - assert attributes["watchers_count"] is None or isinstance(attributes["watchers_count"], (int, long)), attributes["watchers_count"] - self._watchers_count = github.GithubObject.ValuedAttribute(attributes["watchers_count"]) + self._watchers_count = self._makeIntAttribute(attributes["watchers_count"]) diff --git a/github/RepositoryKey.py b/github/RepositoryKey.py index 90bccd08..4c8168cb 100644 --- a/github/RepositoryKey.py +++ b/github/RepositoryKey.py @@ -122,17 +122,12 @@ class RepositoryKey(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "key" in attributes: # pragma no branch - assert attributes["key"] is None or isinstance(attributes["key"], (str, unicode)), attributes["key"] - self._key = github.GithubObject.ValuedAttribute(attributes["key"]) + self._key = self._makeStringAttribute(attributes["key"]) if "title" in attributes: # pragma no branch - assert attributes["title"] is None or isinstance(attributes["title"], (str, unicode)), attributes["title"] - self._title = github.GithubObject.ValuedAttribute(attributes["title"]) + self._title = self._makeStringAttribute(attributes["title"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) if "verified" in attributes: # pragma no branch - assert attributes["verified"] is None or isinstance(attributes["verified"], bool), attributes["verified"] - self._verified = github.GithubObject.ValuedAttribute(attributes["verified"]) + self._verified = self._makeBoolAttribute(attributes["verified"]) diff --git a/github/Status.py b/github/Status.py index c25c6a23..e70b7420 100644 --- a/github/Status.py +++ b/github/Status.py @@ -49,8 +49,6 @@ class Status(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "status" in attributes: # pragma no branch - assert attributes["status"] is None or isinstance(attributes["status"], (str, unicode)), attributes["status"] - self._status = github.GithubObject.ValuedAttribute(attributes["status"]) + self._status = self._makeStringAttribute(attributes["status"]) if "last_updated" in attributes: # pragma no branch - assert attributes["last_updated"] is None or isinstance(attributes["last_updated"], (str, unicode)), attributes["last_updated"] - self._last_updated = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["last_updated"])) + self._last_updated = self._makeDatetimeAttribute(attributes["last_updated"]) diff --git a/github/StatusMessage.py b/github/StatusMessage.py index a99e72ec..50834704 100644 --- a/github/StatusMessage.py +++ b/github/StatusMessage.py @@ -56,11 +56,8 @@ class StatusMessage(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "body" in attributes: # pragma no branch - assert attributes["body"] is None or isinstance(attributes["body"], (str, unicode)), attributes["body"] - self._body = github.GithubObject.ValuedAttribute(attributes["body"]) + self._body = self._makeStringAttribute(attributes["body"]) if "status" in attributes: # pragma no branch - assert attributes["status"] is None or isinstance(attributes["status"], (str, unicode)), attributes["status"] - self._status = github.GithubObject.ValuedAttribute(attributes["status"]) + self._status = self._makeStringAttribute(attributes["status"]) if "created_on" in attributes: # pragma no branch - assert attributes["created_on"] is None or isinstance(attributes["created_on"], (str, unicode)), attributes["created_on"] - self._created_on = github.GithubObject.ValuedAttribute(self._parseDatetime(attributes["created_on"])) + self._created_on = self._makeDatetimeAttribute(attributes["created_on"]) diff --git a/github/Tag.py b/github/Tag.py index 14b19420..7b59ba68 100644 --- a/github/Tag.py +++ b/github/Tag.py @@ -71,14 +71,10 @@ class Tag(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "commit" in attributes: # pragma no branch - assert attributes["commit"] is None or isinstance(attributes["commit"], dict), attributes["commit"] - self._commit = github.GithubObject.ValuedAttribute(None if attributes["commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["commit"], completed=False)) + self._commit = self._makeClassAttribute(github.Commit.Commit, attributes["commit"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "tarball_url" in attributes: # pragma no branch - assert attributes["tarball_url"] is None or isinstance(attributes["tarball_url"], (str, unicode)), attributes["tarball_url"] - self._tarball_url = github.GithubObject.ValuedAttribute(attributes["tarball_url"]) + self._tarball_url = self._makeStringAttribute(attributes["tarball_url"]) if "zipball_url" in attributes: # pragma no branch - assert attributes["zipball_url"] is None or isinstance(attributes["zipball_url"], (str, unicode)), attributes["zipball_url"] - self._zipball_url = github.GithubObject.ValuedAttribute(attributes["zipball_url"]) + self._zipball_url = self._makeStringAttribute(attributes["zipball_url"]) diff --git a/github/Team.py b/github/Team.py index ccb0b1f5..a3c8470f 100644 --- a/github/Team.py +++ b/github/Team.py @@ -255,29 +255,20 @@ class Team(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "members_count" in attributes: # pragma no branch - assert attributes["members_count"] is None or isinstance(attributes["members_count"], (int, long)), attributes["members_count"] - self._members_count = github.GithubObject.ValuedAttribute(attributes["members_count"]) + self._members_count = self._makeIntAttribute(attributes["members_count"]) if "members_url" in attributes: # pragma no branch - assert attributes["members_url"] is None or isinstance(attributes["members_url"], (str, unicode)), attributes["members_url"] - self._members_url = github.GithubObject.ValuedAttribute(attributes["members_url"]) + self._members_url = self._makeStringAttribute(attributes["members_url"]) if "name" in attributes: # pragma no branch - assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] - self._name = github.GithubObject.ValuedAttribute(attributes["name"]) + self._name = self._makeStringAttribute(attributes["name"]) if "permission" in attributes: # pragma no branch - assert attributes["permission"] is None or isinstance(attributes["permission"], (str, unicode)), attributes["permission"] - self._permission = github.GithubObject.ValuedAttribute(attributes["permission"]) + self._permission = self._makeStringAttribute(attributes["permission"]) if "repos_count" in attributes: # pragma no branch - assert attributes["repos_count"] is None or isinstance(attributes["repos_count"], (int, long)), attributes["repos_count"] - self._repos_count = github.GithubObject.ValuedAttribute(attributes["repos_count"]) + self._repos_count = self._makeIntAttribute(attributes["repos_count"]) if "repositories_url" in attributes: # pragma no branch - assert attributes["repositories_url"] is None or isinstance(attributes["repositories_url"], (str, unicode)), attributes["repositories_url"] - self._repositories_url = github.GithubObject.ValuedAttribute(attributes["repositories_url"]) + self._repositories_url = self._makeStringAttribute(attributes["repositories_url"]) if "slug" in attributes: # pragma no branch - assert attributes["slug"] is None or isinstance(attributes["slug"], (str, unicode)), attributes["slug"] - self._slug = github.GithubObject.ValuedAttribute(attributes["slug"]) + self._slug = self._makeStringAttribute(attributes["slug"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/github/UserKey.py b/github/UserKey.py index 66b240f5..be3b275d 100644 --- a/github/UserKey.py +++ b/github/UserKey.py @@ -113,17 +113,12 @@ class UserKey(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch - assert attributes["id"] is None or isinstance(attributes["id"], (int, long)), attributes["id"] - self._id = github.GithubObject.ValuedAttribute(attributes["id"]) + self._id = self._makeIntAttribute(attributes["id"]) if "key" in attributes: # pragma no branch - assert attributes["key"] is None or isinstance(attributes["key"], (str, unicode)), attributes["key"] - self._key = github.GithubObject.ValuedAttribute(attributes["key"]) + self._key = self._makeStringAttribute(attributes["key"]) if "title" in attributes: # pragma no branch - assert attributes["title"] is None or isinstance(attributes["title"], (str, unicode)), attributes["title"] - self._title = github.GithubObject.ValuedAttribute(attributes["title"]) + self._title = self._makeStringAttribute(attributes["title"]) if "url" in attributes: # pragma no branch - assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] - self._url = github.GithubObject.ValuedAttribute(attributes["url"]) + self._url = self._makeStringAttribute(attributes["url"]) if "verified" in attributes: # pragma no branch - assert attributes["verified"] is None or isinstance(attributes["verified"], bool), attributes["verified"] - self._verified = github.GithubObject.ValuedAttribute(attributes["verified"]) + self._verified = self._makeBoolAttribute(attributes["verified"])