From f14d761344782215c94a23be806a357e5d7ab58d Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Wed, 9 May 2012 18:20:44 +0200 Subject: [PATCH] Structure some attributes --- CodeGenerator/templates/GithubObject.py | 11 +++ .../description.000.human_readable.json | 72 ++++++++--------- .../description.001.normalized.json | 78 +++++++++---------- NewIntegrationTest.py | 4 +- ReferenceOfClasses.md | 72 ++++++++--------- github/GithubObjects/GitBlob.py | 5 ++ github/GithubObjects/GitCommit.py | 10 ++- github/GithubObjects/GitTree.py | 2 + github/GithubObjects/Repository.py | 58 ++++++++++---- 9 files changed, 183 insertions(+), 129 deletions(-) diff --git a/CodeGenerator/templates/GithubObject.py b/CodeGenerator/templates/GithubObject.py index 08dfcfc6..e0ac5bf3 100644 --- a/CodeGenerator/templates/GithubObject.py +++ b/CodeGenerator/templates/GithubObject.py @@ -71,6 +71,8 @@ class {{ class.name }}( object ): #@todo No need to check if attribute is in attributes when attribute is mandatory {% for attribute in class.attributes|dictsort:"name" %} if "{{ attribute.name }}" in attributes and attributes[ "{{ attribute.name }}" ] is not None: + +{% if attribute.type.cardinality == "scalar" %} {% if attribute.type.simple %} {% if attribute.type.name == "string" %} assert isinstance( attributes[ "{{ attribute.name }}" ], ( str, unicode ) ) @@ -86,5 +88,14 @@ class {{ class.name }}( object ): assert isinstance( attributes[ "{{ attribute.name }}" ], dict ) self.__{{ attribute.name }} = {% if attribute.type.name != class.name %}{{ attribute.type.name }}.{% endif %}{{ attribute.type.name }}( self.__requester, attributes[ "{{ attribute.name }}" ], lazy = True ) {% endif %} +{% endif %} + +{% if attribute.type.cardinality == "list" %} + assert isinstance( attributes[ "{{ attribute.name }}" ], list ) + self.__{{ attribute.name }} = [ + {% if attribute.type.name != class.name %}{{ attribute.type.name }}.{% endif %}{{ attribute.type.name }}( self.__requester, element, lazy = True ) + for element in attributes[ "{{ attribute.name }}" ] + ] +{% endif %} {% endfor %} diff --git a/JsonDescriptionOfGithubApiV3/description.000.human_readable.json b/JsonDescriptionOfGithubApiV3/description.000.human_readable.json index 468d9244..82c97373 100644 --- a/JsonDescriptionOfGithubApiV3/description.000.human_readable.json +++ b/JsonDescriptionOfGithubApiV3/description.000.human_readable.json @@ -500,11 +500,11 @@ { "name": "GitBlob", "attributes": [ - { "name": "content", "type": "@todo" }, - { "name": "encoding", "type": "@todo" }, - { "name": "sha", "type": "@todo" }, - { "name": "size", "type": "@todo" }, - { "name": "url", "type": "@todo" } + { "name": "content", "type": "string" }, + { "name": "encoding", "type": "string" }, + { "name": "sha", "type": "string" }, + { "name": "size", "type": "integer" }, + { "name": "url", "type": "string" } ], "collections": [ ] @@ -514,10 +514,10 @@ "attributes": [ { "name": "author", "type": "GitAuthor" }, { "name": "committer", "type": "GitAuthor" }, - { "name": "message", "type": "@todo" }, - { "name": "parents", "type": "@todo" }, - { "name": "sha", "type": "@todo" }, - { "name": "url", "type": "@todo" }, + { "name": "message", "type": "string" }, + { "name": "parents", "type": "list:GitCommit" }, + { "name": "sha", "type": "string" }, + { "name": "url", "type": "string" }, { "name": "tree", "type": "GitTree" } ], "collections": [ @@ -558,9 +558,9 @@ { "name": "GitTree", "attributes": [ - { "name": "sha", "type": "@todo" }, + { "name": "sha", "type": "string" }, { "name": "tree", "type": "@todo" }, - { "name": "url", "type": "@todo" } + { "name": "url", "type": "string" } ], "collections": [ ] @@ -1192,36 +1192,36 @@ ] }, "attributes": [ - { "name": "clone_url", "type": "@todo" }, - { "name": "created_at", "type": "@todo" }, - { "name": "description", "type": "@todo" }, - { "name": "fork", "type": "@todo" }, - { "name": "forks", "type": "@todo" }, - { "name": "git_url", "type": "@todo" }, - { "name": "has_downloads", "type": "@todo" }, - { "name": "has_issues", "type": "@todo" }, - { "name": "has_wiki", "type": "@todo" }, - { "name": "homepage", "type": "@todo" }, - { "name": "html_url", "type": "@todo" }, - { "name": "id", "type": "@todo" }, - { "name": "language", "type": "@todo" }, - { "name": "master_branch", "type": "@todo" }, - { "name": "mirror_url", "type": "@todo" }, + { "name": "clone_url", "type": "string" }, + { "name": "created_at", "type": "string" }, + { "name": "description", "type": "string" }, + { "name": "fork", "type": "bool" }, + { "name": "forks", "type": "integer" }, + { "name": "git_url", "type": "string" }, + { "name": "has_downloads", "type": "bool" }, + { "name": "has_issues", "type": "bool" }, + { "name": "has_wiki", "type": "bool" }, + { "name": "homepage", "type": "string" }, + { "name": "html_url", "type": "string" }, + { "name": "id", "type": "integer" }, + { "name": "language", "type": "string" }, + { "name": "master_branch", "type": "string" }, + { "name": "mirror_url", "type": "string" }, { "name": "name", "type": "string" }, - { "name": "open_issues", "type": "@todo" }, - { "name": "organization", "type": "@todo" }, + { "name": "open_issues", "type": "integer" }, + { "name": "organization", "type": "Organization" }, { "name": "owner", "type": "NamedUser" }, { "name": "parent", "type": "Repository" }, { "name": "permissions", "type": "@todo" }, - { "name": "private", "type": "@todo" }, - { "name": "pushed_at", "type": "@todo" }, - { "name": "size", "type": "@todo" }, + { "name": "private", "type": "bool" }, + { "name": "pushed_at", "type": "string" }, + { "name": "size", "type": "integer" }, { "name": "source", "type": "Repository" }, - { "name": "ssh_url", "type": "@todo" }, - { "name": "svn_url", "type": "@todo" }, - { "name": "updated_at", "type": "@todo" }, - { "name": "url", "type": "@todo" }, - { "name": "watchers", "type": "@todo" } + { "name": "ssh_url", "type": "string" }, + { "name": "svn_url", "type": "string" }, + { "name": "updated_at", "type": "string" }, + { "name": "url", "type": "string" }, + { "name": "watchers", "type": "integer" } ], "collections": [ { diff --git a/JsonDescriptionOfGithubApiV3/description.001.normalized.json b/JsonDescriptionOfGithubApiV3/description.001.normalized.json index 634a227b..74e73dcb 100644 --- a/JsonDescriptionOfGithubApiV3/description.001.normalized.json +++ b/JsonDescriptionOfGithubApiV3/description.001.normalized.json @@ -2939,7 +2939,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "content" }, @@ -2947,7 +2947,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "encoding" }, @@ -2955,7 +2955,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "sha" }, @@ -2963,7 +2963,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "size" }, @@ -2971,7 +2971,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "url" } @@ -3001,15 +3001,15 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "message" }, { "type": { - "simple": true, - "cardinality": "scalar", - "name": "@todo" + "simple": false, + "cardinality": "list", + "name": "GitCommit" }, "name": "parents" }, @@ -3017,7 +3017,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "sha" }, @@ -3033,7 +3033,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "url" } @@ -3203,7 +3203,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "sha" }, @@ -3219,7 +3219,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "url" } @@ -6843,7 +6843,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "clone_url" }, @@ -6851,7 +6851,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "created_at" }, @@ -6859,7 +6859,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "description" }, @@ -6867,7 +6867,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "bool" }, "name": "fork" }, @@ -6875,7 +6875,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "forks" }, @@ -6883,7 +6883,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "git_url" }, @@ -6891,7 +6891,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "bool" }, "name": "has_downloads" }, @@ -6899,7 +6899,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "bool" }, "name": "has_issues" }, @@ -6907,7 +6907,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "bool" }, "name": "has_wiki" }, @@ -6915,7 +6915,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "homepage" }, @@ -6923,7 +6923,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "html_url" }, @@ -6931,7 +6931,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "id" }, @@ -6939,7 +6939,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "language" }, @@ -6947,7 +6947,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "master_branch" }, @@ -6955,7 +6955,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "mirror_url" }, @@ -6971,15 +6971,15 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "open_issues" }, { "type": { - "simple": true, + "simple": false, "cardinality": "scalar", - "name": "@todo" + "name": "Organization" }, "name": "organization" }, @@ -7011,7 +7011,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "bool" }, "name": "private" }, @@ -7019,7 +7019,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "pushed_at" }, @@ -7027,7 +7027,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "size" }, @@ -7043,7 +7043,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "ssh_url" }, @@ -7051,7 +7051,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "svn_url" }, @@ -7059,7 +7059,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "updated_at" }, @@ -7067,7 +7067,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "url" }, @@ -7075,7 +7075,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "watchers" } diff --git a/NewIntegrationTest.py b/NewIntegrationTest.py index ca0d8deb..3c37c04d 100644 --- a/NewIntegrationTest.py +++ b/NewIntegrationTest.py @@ -210,7 +210,9 @@ class GitCommit( TestCase ): self.assertEqual( self.c.committer.email, "vincent@vincent-jacques.net" ) self.assertEqual( self.c.committer.date, "2012-04-17T10:55:16-07:00" ) self.assertEqual( self.c.message, "Merge branch 'develop'\n" ) - self.assertEqual( self.c.parents, [{u'url': u'https://api.github.com/repos/jacquev6/PyGithub/git/commits/936f4a97f1a86392637ec002bbf89ff036a5062d', u'sha': u'936f4a97f1a86392637ec002bbf89ff036a5062d'}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/git/commits/2a7e80e6421c5d4d201d60619068dea6bae612cb', u'sha': u'2a7e80e6421c5d4d201d60619068dea6bae612cb'}] ) ### @todo Structure + self.assertEqual( len( self.c.parents ), 2 ) + self.assertEqual( self.c.parents[ 0 ].sha, "936f4a97f1a86392637ec002bbf89ff036a5062d" ) + self.assertEqual( self.c.parents[ 1 ].sha, "2a7e80e6421c5d4d201d60619068dea6bae612cb" ) self.assertEqual( self.c.sha, "4303c5b90e2216d927155e9609436ccb8984c495" ) self.assertEqual( self.c.tree.sha, "f492784d8ca837779650d1fb406a1a3587a764ad" ) self.assertEqual( self.c.url, "https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495" ) diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index 64b12969..e46e42e0 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -363,11 +363,11 @@ Class `GitBlob` Attributes ---------- -* `content` -* `encoding` -* `sha` -* `size` -* `url` +* `content`: string +* `encoding`: string +* `sha`: string +* `size`: integer +* `url`: string Class `GitCommit` ================= @@ -376,11 +376,11 @@ Attributes ---------- * `author`: `GitAuthor` * `committer`: `GitAuthor` -* `message` -* `parents` -* `sha` +* `message`: string +* `parents`: list of `GitCommit` +* `sha`: string * `tree`: `GitTree` -* `url` +* `url`: string Class `GitRef` ============== @@ -418,9 +418,9 @@ Class `GitTree` Attributes ---------- -* `sha` +* `sha`: string * `tree` -* `url` +* `url`: string Class `Hook` ============ @@ -873,36 +873,36 @@ Class `Repository` Attributes ---------- -* `clone_url` -* `created_at` -* `description` -* `fork` -* `forks` -* `git_url` -* `has_downloads` -* `has_issues` -* `has_wiki` -* `homepage` -* `html_url` -* `id` -* `language` -* `master_branch` -* `mirror_url` +* `clone_url`: string +* `created_at`: string +* `description`: string +* `fork`: bool +* `forks`: integer +* `git_url`: string +* `has_downloads`: bool +* `has_issues`: bool +* `has_wiki`: bool +* `homepage`: string +* `html_url`: string +* `id`: integer +* `language`: string +* `master_branch`: string +* `mirror_url`: string * `name`: string -* `open_issues` -* `organization` +* `open_issues`: integer +* `organization`: `Organization` * `owner`: `NamedUser` * `parent`: `Repository` * `permissions` -* `private` -* `pushed_at` -* `size` +* `private`: bool +* `pushed_at`: string +* `size`: integer * `source`: `Repository` -* `ssh_url` -* `svn_url` -* `updated_at` -* `url` -* `watchers` +* `ssh_url`: string +* `svn_url`: string +* `updated_at`: string +* `url`: string +* `watchers`: integer Comparison ---------- diff --git a/github/GithubObjects/GitBlob.py b/github/GithubObjects/GitBlob.py index 253c2341..011333ca 100644 --- a/github/GithubObjects/GitBlob.py +++ b/github/GithubObjects/GitBlob.py @@ -66,12 +66,17 @@ class GitBlob( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "content" in attributes and attributes[ "content" ] is not None: + assert isinstance( attributes[ "content" ], ( str, unicode ) ) self.__content = attributes[ "content" ] if "encoding" in attributes and attributes[ "encoding" ] is not None: + assert isinstance( attributes[ "encoding" ], ( str, unicode ) ) self.__encoding = attributes[ "encoding" ] if "sha" in attributes and attributes[ "sha" ] is not None: + assert isinstance( attributes[ "sha" ], ( str, unicode ) ) self.__sha = attributes[ "sha" ] if "size" in attributes and attributes[ "size" ] is not None: + assert isinstance( attributes[ "size" ], int ) self.__size = attributes[ "size" ] if "url" in attributes and attributes[ "url" ] is not None: + assert isinstance( attributes[ "url" ], ( str, unicode ) ) self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/GitCommit.py b/github/GithubObjects/GitCommit.py index 8724d508..a781d0a8 100644 --- a/github/GithubObjects/GitCommit.py +++ b/github/GithubObjects/GitCommit.py @@ -3,6 +3,7 @@ import PaginatedList import GitAuthor +import GitCommit import GitTree # This allows None as a valid value for an optional parameter @@ -86,13 +87,20 @@ class GitCommit( object ): assert isinstance( attributes[ "committer" ], dict ) self.__committer = GitAuthor.GitAuthor( self.__requester, attributes[ "committer" ], lazy = True ) if "message" in attributes and attributes[ "message" ] is not None: + assert isinstance( attributes[ "message" ], ( str, unicode ) ) self.__message = attributes[ "message" ] if "parents" in attributes and attributes[ "parents" ] is not None: - self.__parents = attributes[ "parents" ] + assert isinstance( attributes[ "parents" ], list ) + self.__parents = [ + GitCommit( self.__requester, element, lazy = True ) + for element in attributes[ "parents" ] + ] if "sha" in attributes and attributes[ "sha" ] is not None: + assert isinstance( attributes[ "sha" ], ( str, unicode ) ) self.__sha = attributes[ "sha" ] if "tree" in attributes and attributes[ "tree" ] is not None: assert isinstance( attributes[ "tree" ], dict ) self.__tree = GitTree.GitTree( self.__requester, attributes[ "tree" ], lazy = True ) if "url" in attributes and attributes[ "url" ] is not None: + assert isinstance( attributes[ "url" ], ( str, unicode ) ) self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/GitTree.py b/github/GithubObjects/GitTree.py index 3012f814..54fedb09 100644 --- a/github/GithubObjects/GitTree.py +++ b/github/GithubObjects/GitTree.py @@ -54,8 +54,10 @@ class GitTree( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "sha" in attributes and attributes[ "sha" ] is not None: + assert isinstance( attributes[ "sha" ], ( str, unicode ) ) self.__sha = attributes[ "sha" ] if "tree" in attributes and attributes[ "tree" ] is not None: self.__tree = attributes[ "tree" ] if "url" in attributes and attributes[ "url" ] is not None: + assert isinstance( attributes[ "url" ], ( str, unicode ) ) self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/Repository.py b/github/GithubObjects/Repository.py index 31dbde2d..c12e6ee9 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -2,27 +2,28 @@ # Do not modify it manually, your work would be lost. import PaginatedList +import Branch +import IssueEvent +import Label +import GitBlob +import Commit +import GitRef +import Issue +import Repository +import PullRequest +import RepositoryKey +import NamedUser +import Milestone +import CommitComment import GitCommit import Team -import PullRequest -import GitBlob -import Repository -import IssueEvent -import Milestone -import RepositoryKey -import GitTag -import CommitComment +import Organization +import GitTree import Hook import Tag -import Branch -import GitRef +import GitTag import Download -import Commit -import NamedUser -import Issue import Event -import GitTree -import Label # This allows None as a valid value for an optional parameter class DefaultValueForOptionalParametersType: @@ -897,42 +898,59 @@ class Repository( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "clone_url" in attributes and attributes[ "clone_url" ] is not None: + assert isinstance( attributes[ "clone_url" ], ( str, unicode ) ) self.__clone_url = attributes[ "clone_url" ] if "created_at" in attributes and attributes[ "created_at" ] is not None: + assert isinstance( attributes[ "created_at" ], ( str, unicode ) ) self.__created_at = attributes[ "created_at" ] if "description" in attributes and attributes[ "description" ] is not None: + assert isinstance( attributes[ "description" ], ( str, unicode ) ) self.__description = attributes[ "description" ] if "fork" in attributes and attributes[ "fork" ] is not None: + assert isinstance( attributes[ "fork" ], bool ) self.__fork = attributes[ "fork" ] if "forks" in attributes and attributes[ "forks" ] is not None: + assert isinstance( attributes[ "forks" ], int ) self.__forks = attributes[ "forks" ] if "git_url" in attributes and attributes[ "git_url" ] is not None: + assert isinstance( attributes[ "git_url" ], ( str, unicode ) ) self.__git_url = attributes[ "git_url" ] if "has_downloads" in attributes and attributes[ "has_downloads" ] is not None: + assert isinstance( attributes[ "has_downloads" ], bool ) self.__has_downloads = attributes[ "has_downloads" ] if "has_issues" in attributes and attributes[ "has_issues" ] is not None: + assert isinstance( attributes[ "has_issues" ], bool ) self.__has_issues = attributes[ "has_issues" ] if "has_wiki" in attributes and attributes[ "has_wiki" ] is not None: + assert isinstance( attributes[ "has_wiki" ], bool ) self.__has_wiki = attributes[ "has_wiki" ] if "homepage" in attributes and attributes[ "homepage" ] is not None: + assert isinstance( attributes[ "homepage" ], ( str, unicode ) ) self.__homepage = attributes[ "homepage" ] if "html_url" in attributes and attributes[ "html_url" ] is not None: + assert isinstance( attributes[ "html_url" ], ( str, unicode ) ) self.__html_url = attributes[ "html_url" ] if "id" in attributes and attributes[ "id" ] is not None: + assert isinstance( attributes[ "id" ], int ) self.__id = attributes[ "id" ] if "language" in attributes and attributes[ "language" ] is not None: + assert isinstance( attributes[ "language" ], ( str, unicode ) ) self.__language = attributes[ "language" ] if "master_branch" in attributes and attributes[ "master_branch" ] is not None: + assert isinstance( attributes[ "master_branch" ], ( str, unicode ) ) self.__master_branch = attributes[ "master_branch" ] if "mirror_url" in attributes and attributes[ "mirror_url" ] is not None: + assert isinstance( attributes[ "mirror_url" ], ( str, unicode ) ) self.__mirror_url = attributes[ "mirror_url" ] if "name" in attributes and attributes[ "name" ] is not None: assert isinstance( attributes[ "name" ], ( str, unicode ) ) self.__name = attributes[ "name" ] if "open_issues" in attributes and attributes[ "open_issues" ] is not None: + assert isinstance( attributes[ "open_issues" ], int ) self.__open_issues = attributes[ "open_issues" ] if "organization" in attributes and attributes[ "organization" ] is not None: - self.__organization = attributes[ "organization" ] + assert isinstance( attributes[ "organization" ], dict ) + self.__organization = Organization.Organization( self.__requester, attributes[ "organization" ], lazy = True ) if "owner" in attributes and attributes[ "owner" ] is not None: assert isinstance( attributes[ "owner" ], dict ) self.__owner = NamedUser.NamedUser( self.__requester, attributes[ "owner" ], lazy = True ) @@ -942,21 +960,29 @@ class Repository( object ): if "permissions" in attributes and attributes[ "permissions" ] is not None: self.__permissions = attributes[ "permissions" ] if "private" in attributes and attributes[ "private" ] is not None: + assert isinstance( attributes[ "private" ], bool ) self.__private = attributes[ "private" ] if "pushed_at" in attributes and attributes[ "pushed_at" ] is not None: + assert isinstance( attributes[ "pushed_at" ], ( str, unicode ) ) self.__pushed_at = attributes[ "pushed_at" ] if "size" in attributes and attributes[ "size" ] is not None: + assert isinstance( attributes[ "size" ], int ) self.__size = attributes[ "size" ] if "source" in attributes and attributes[ "source" ] is not None: assert isinstance( attributes[ "source" ], dict ) self.__source = Repository( self.__requester, attributes[ "source" ], lazy = True ) if "ssh_url" in attributes and attributes[ "ssh_url" ] is not None: + assert isinstance( attributes[ "ssh_url" ], ( str, unicode ) ) self.__ssh_url = attributes[ "ssh_url" ] if "svn_url" in attributes and attributes[ "svn_url" ] is not None: + assert isinstance( attributes[ "svn_url" ], ( str, unicode ) ) self.__svn_url = attributes[ "svn_url" ] if "updated_at" in attributes and attributes[ "updated_at" ] is not None: + assert isinstance( attributes[ "updated_at" ], ( str, unicode ) ) self.__updated_at = attributes[ "updated_at" ] if "url" in attributes and attributes[ "url" ] is not None: + assert isinstance( attributes[ "url" ], ( str, unicode ) ) self.__url = attributes[ "url" ] if "watchers" in attributes and attributes[ "watchers" ] is not None: + assert isinstance( attributes[ "watchers" ], int ) self.__watchers = attributes[ "watchers" ]