Factorize the creation of attributes (preparation for #195)

This commit is contained in:
Vincent Jacques
2013-09-12 09:27:25 +02:00
parent 4a5009741a
commit 597e123029
55 changed files with 620 additions and 1132 deletions
+29 -58
View File
@@ -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"])