mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Factorize the creation of attributes (preparation for #195)
This commit is contained in:
+8
-16
@@ -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"])
|
||||
|
||||
Reference in New Issue
Block a user