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
+5 -10
View File
@@ -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"])