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:
@@ -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"])
|
||||
|
||||
Reference in New Issue
Block a user