diff --git a/CodeGenerator/templates/GithubObject.py b/CodeGenerator/templates/GithubObject.py index 9874f433..5cc83895 100644 --- a/CodeGenerator/templates/GithubObject.py +++ b/CodeGenerator/templates/GithubObject.py @@ -15,13 +15,17 @@ class {{ class.name }}( object ): self.__completed = False self.__initAttributes() self.__useAttributes( attributes ) +{% if class.isCompletable %} if not lazy: self.__complete() +{% endif %} {% for attribute in class.attributes|dictsort:"name" %} @property def {{ attribute.name }}( self ): +{% if class.isCompletable %} self.__completeIfNeeded( self.__{{ attribute.name }} ) +{% endif %} return self.__{{ attribute.name }} {% endfor %} @@ -47,11 +51,11 @@ class {{ class.name }}( object ): self.__{{ attribute.name }} = None {% endfor %} +{% if class.isCompletable %} def __completeIfNeeded( self, testedAttribute ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", @@ -61,6 +65,7 @@ class {{ class.name }}( object ): ) self.__useAttributes( data ) self.__completed = True +{% endif %} def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory diff --git a/GenerateCode.py b/GenerateCode.py index 8f895164..80c69a4e 100644 --- a/GenerateCode.py +++ b/GenerateCode.py @@ -23,6 +23,13 @@ for class_ in description[ "classes" ]: dependencies.add( thing[ "type" ][ "name" ] ) class_[ "dependencies" ] = list( dependencies ) +for class_ in description[ "classes" ]: + isCompletable = False + for attribute in class_[ "attributes" ]: + if attribute[ "name" ] == "url": + isCompletable = True + class_[ "isCompletable" ] = isCompletable + githubObjectTemplate = django.template.loader.get_template( "GithubObject.py" ) for class_ in description[ "classes" ]: with open( "github/GithubObjects/" + class_[ "name" ] + ".py", "w" ) as f: diff --git a/github/GithubObjects/AuthenticatedUser.py b/github/GithubObjects/AuthenticatedUser.py index 2bc78f91..9ad1b4a2 100644 --- a/github/GithubObjects/AuthenticatedUser.py +++ b/github/GithubObjects/AuthenticatedUser.py @@ -559,7 +559,6 @@ class AuthenticatedUser( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/Authorization.py b/github/GithubObjects/Authorization.py index 6811a9c5..5926229f 100644 --- a/github/GithubObjects/Authorization.py +++ b/github/GithubObjects/Authorization.py @@ -106,7 +106,6 @@ class Authorization( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/Branch.py b/github/GithubObjects/Branch.py index e3cd1010..dfb7c983 100644 --- a/github/GithubObjects/Branch.py +++ b/github/GithubObjects/Branch.py @@ -15,38 +15,19 @@ class Branch( object ): self.__completed = False self.__initAttributes() self.__useAttributes( attributes ) - if not lazy: - self.__complete() @property def commit( self ): - self.__completeIfNeeded( self.__commit ) return self.__commit @property def name( self ): - self.__completeIfNeeded( self.__name ) return self.__name def __initAttributes( self ): self.__commit = None self.__name = None - def __completeIfNeeded( self, testedAttribute ): - if not self.__completed and testedAttribute is None: - self.__complete() - - # @todo Do not generate __complete if type has no url attribute - def __complete( self ): - status, headers, data = self.__requester.request( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( data ) - self.__completed = True - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "commit" in attributes and attributes[ "commit" ] is not None: diff --git a/github/GithubObjects/Commit.py b/github/GithubObjects/Commit.py index 1d129600..e9c0b4be 100644 --- a/github/GithubObjects/Commit.py +++ b/github/GithubObjects/Commit.py @@ -108,7 +108,6 @@ class Commit( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/CommitComment.py b/github/GithubObjects/CommitComment.py index 390e105c..c84939e8 100644 --- a/github/GithubObjects/CommitComment.py +++ b/github/GithubObjects/CommitComment.py @@ -110,7 +110,6 @@ class CommitComment( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/Download.py b/github/GithubObjects/Download.py index feea6a7b..3ab6343d 100644 --- a/github/GithubObjects/Download.py +++ b/github/GithubObjects/Download.py @@ -151,7 +151,6 @@ class Download( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/Event.py b/github/GithubObjects/Event.py index 2a5d92b6..b945db3a 100644 --- a/github/GithubObjects/Event.py +++ b/github/GithubObjects/Event.py @@ -98,7 +98,6 @@ class Event( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/Gist.py b/github/GithubObjects/Gist.py index c3ec1533..69c9a560 100644 --- a/github/GithubObjects/Gist.py +++ b/github/GithubObjects/Gist.py @@ -202,7 +202,6 @@ class Gist( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/GistComment.py b/github/GithubObjects/GistComment.py index b6cd2eb1..9c57ba3b 100644 --- a/github/GithubObjects/GistComment.py +++ b/github/GithubObjects/GistComment.py @@ -80,7 +80,6 @@ class GistComment( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/GitBlob.py b/github/GithubObjects/GitBlob.py index eb43f098..253c2341 100644 --- a/github/GithubObjects/GitBlob.py +++ b/github/GithubObjects/GitBlob.py @@ -53,7 +53,6 @@ class GitBlob( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/GitCommit.py b/github/GithubObjects/GitCommit.py index 0125cff5..f1583ed8 100644 --- a/github/GithubObjects/GitCommit.py +++ b/github/GithubObjects/GitCommit.py @@ -66,7 +66,6 @@ class GitCommit( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/GitRef.py b/github/GithubObjects/GitRef.py index 8b5112c2..ccd6da25 100644 --- a/github/GithubObjects/GitRef.py +++ b/github/GithubObjects/GitRef.py @@ -63,7 +63,6 @@ class GitRef( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/GitTag.py b/github/GithubObjects/GitTag.py index 5d3092c5..d289092f 100644 --- a/github/GithubObjects/GitTag.py +++ b/github/GithubObjects/GitTag.py @@ -59,7 +59,6 @@ class GitTag( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/GitTree.py b/github/GithubObjects/GitTree.py index 06fd45c0..7c596f20 100644 --- a/github/GithubObjects/GitTree.py +++ b/github/GithubObjects/GitTree.py @@ -47,7 +47,6 @@ class GitTree( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/Hook.py b/github/GithubObjects/Hook.py index cbc2880c..c78508a7 100644 --- a/github/GithubObjects/Hook.py +++ b/github/GithubObjects/Hook.py @@ -114,7 +114,6 @@ class Hook( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/Issue.py b/github/GithubObjects/Issue.py index cc11930d..a6844f4f 100644 --- a/github/GithubObjects/Issue.py +++ b/github/GithubObjects/Issue.py @@ -239,7 +239,6 @@ class Issue( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/IssueComment.py b/github/GithubObjects/IssueComment.py index 8aab4abb..2dec3f45 100644 --- a/github/GithubObjects/IssueComment.py +++ b/github/GithubObjects/IssueComment.py @@ -80,7 +80,6 @@ class IssueComment( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/IssueEvent.py b/github/GithubObjects/IssueEvent.py index 2108c095..47f4d567 100644 --- a/github/GithubObjects/IssueEvent.py +++ b/github/GithubObjects/IssueEvent.py @@ -66,7 +66,6 @@ class IssueEvent( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/Label.py b/github/GithubObjects/Label.py index a836c5ea..edde408e 100644 --- a/github/GithubObjects/Label.py +++ b/github/GithubObjects/Label.py @@ -62,7 +62,6 @@ class Label( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/Milestone.py b/github/GithubObjects/Milestone.py index c5b544b7..4c324a0d 100644 --- a/github/GithubObjects/Milestone.py +++ b/github/GithubObjects/Milestone.py @@ -125,7 +125,6 @@ class Milestone( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/NamedUser.py b/github/GithubObjects/NamedUser.py index b22886fd..7306b875 100644 --- a/github/GithubObjects/NamedUser.py +++ b/github/GithubObjects/NamedUser.py @@ -353,7 +353,6 @@ class NamedUser( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/Organization.py b/github/GithubObjects/Organization.py index 7c5e5a0e..78b613bb 100644 --- a/github/GithubObjects/Organization.py +++ b/github/GithubObjects/Organization.py @@ -369,7 +369,6 @@ class Organization( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/Plan.py b/github/GithubObjects/Plan.py index a425c1c7..96837cd3 100644 --- a/github/GithubObjects/Plan.py +++ b/github/GithubObjects/Plan.py @@ -14,27 +14,21 @@ class Plan( object ): self.__completed = False self.__initAttributes() self.__useAttributes( attributes ) - if not lazy: - self.__complete() @property def collaborators( self ): - self.__completeIfNeeded( self.__collaborators ) return self.__collaborators @property def name( self ): - self.__completeIfNeeded( self.__name ) return self.__name @property def private_repos( self ): - self.__completeIfNeeded( self.__private_repos ) return self.__private_repos @property def space( self ): - self.__completeIfNeeded( self.__space ) return self.__space def __initAttributes( self ): @@ -43,21 +37,6 @@ class Plan( object ): self.__private_repos = None self.__space = None - def __completeIfNeeded( self, testedAttribute ): - if not self.__completed and testedAttribute is None: - self.__complete() - - # @todo Do not generate __complete if type has no url attribute - def __complete( self ): - status, headers, data = self.__requester.request( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( data ) - self.__completed = True - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "collaborators" in attributes and attributes[ "collaborators" ] is not None: diff --git a/github/GithubObjects/PullRequest.py b/github/GithubObjects/PullRequest.py index 99e93688..88dc8d94 100644 --- a/github/GithubObjects/PullRequest.py +++ b/github/GithubObjects/PullRequest.py @@ -268,7 +268,6 @@ class PullRequest( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/PullRequestComment.py b/github/GithubObjects/PullRequestComment.py index b71d5a6e..558de5a9 100644 --- a/github/GithubObjects/PullRequestComment.py +++ b/github/GithubObjects/PullRequestComment.py @@ -110,7 +110,6 @@ class PullRequestComment( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/PullRequestFile.py b/github/GithubObjects/PullRequestFile.py index e6cee7e7..648e676b 100644 --- a/github/GithubObjects/PullRequestFile.py +++ b/github/GithubObjects/PullRequestFile.py @@ -14,52 +14,41 @@ class PullRequestFile( object ): self.__completed = False self.__initAttributes() self.__useAttributes( attributes ) - if not lazy: - self.__complete() @property def additions( self ): - self.__completeIfNeeded( self.__additions ) return self.__additions @property def blob_url( self ): - self.__completeIfNeeded( self.__blob_url ) return self.__blob_url @property def changes( self ): - self.__completeIfNeeded( self.__changes ) return self.__changes @property def deletions( self ): - self.__completeIfNeeded( self.__deletions ) return self.__deletions @property def filename( self ): - self.__completeIfNeeded( self.__filename ) return self.__filename @property def patch( self ): - self.__completeIfNeeded( self.__patch ) return self.__patch @property def raw_url( self ): - self.__completeIfNeeded( self.__raw_url ) return self.__raw_url @property def sha( self ): - self.__completeIfNeeded( self.__sha ) return self.__sha @property def status( self ): - self.__completeIfNeeded( self.__status ) return self.__status def __initAttributes( self ): @@ -73,21 +62,6 @@ class PullRequestFile( object ): self.__sha = None self.__status = None - def __completeIfNeeded( self, testedAttribute ): - if not self.__completed and testedAttribute is None: - self.__complete() - - # @todo Do not generate __complete if type has no url attribute - def __complete( self ): - status, headers, data = self.__requester.request( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( data ) - self.__completed = True - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "additions" in attributes and attributes[ "additions" ] is not None: diff --git a/github/GithubObjects/Repository.py b/github/GithubObjects/Repository.py index 4a95253e..9c64902a 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -884,7 +884,6 @@ class Repository( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/RepositoryKey.py b/github/GithubObjects/RepositoryKey.py index 3f1b2532..d821834c 100644 --- a/github/GithubObjects/RepositoryKey.py +++ b/github/GithubObjects/RepositoryKey.py @@ -68,7 +68,6 @@ class RepositoryKey( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/Tag.py b/github/GithubObjects/Tag.py index f0333600..236ab861 100644 --- a/github/GithubObjects/Tag.py +++ b/github/GithubObjects/Tag.py @@ -15,27 +15,21 @@ class Tag( object ): self.__completed = False self.__initAttributes() self.__useAttributes( attributes ) - if not lazy: - self.__complete() @property def commit( self ): - self.__completeIfNeeded( self.__commit ) return self.__commit @property def name( self ): - self.__completeIfNeeded( self.__name ) return self.__name @property def tarball_url( self ): - self.__completeIfNeeded( self.__tarball_url ) return self.__tarball_url @property def zipball_url( self ): - self.__completeIfNeeded( self.__zipball_url ) return self.__zipball_url def __initAttributes( self ): @@ -44,21 +38,6 @@ class Tag( object ): self.__tarball_url = None self.__zipball_url = None - def __completeIfNeeded( self, testedAttribute ): - if not self.__completed and testedAttribute is None: - self.__complete() - - # @todo Do not generate __complete if type has no url attribute - def __complete( self ): - status, headers, data = self.__requester.request( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( data ) - self.__completed = True - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "commit" in attributes and attributes[ "commit" ] is not None: diff --git a/github/GithubObjects/Team.py b/github/GithubObjects/Team.py index d5d2b010..426f7405 100644 --- a/github/GithubObjects/Team.py +++ b/github/GithubObjects/Team.py @@ -161,7 +161,6 @@ class Team( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET", diff --git a/github/GithubObjects/UserKey.py b/github/GithubObjects/UserKey.py index 380d0082..2a1de5de 100644 --- a/github/GithubObjects/UserKey.py +++ b/github/GithubObjects/UserKey.py @@ -70,7 +70,6 @@ class UserKey( object ): if not self.__completed and testedAttribute is None: self.__complete() - # @todo Do not generate __complete if type has no url attribute def __complete( self ): status, headers, data = self.__requester.request( "GET",