diff --git a/CodeGenerator/templates/GithubObject.py b/CodeGenerator/templates/GithubObject.py index 51d08754..45cd5531 100644 --- a/CodeGenerator/templates/GithubObject.py +++ b/CodeGenerator/templates/GithubObject.py @@ -11,33 +11,13 @@ class {{ class.name }}( object ): if not lazy: self.__complete() -{% for attribute in class.attributes %} +{% for attribute in class.attributes|dictsort:"name" %} @property def {{ attribute.name }}( self ): self.__completeIfNeeded( self.__{{ attribute.name }} ) return self.__{{ attribute.name }} {% endfor %} - def __initAttributes( self ): -{% for attribute in class.attributes %} - self.__{{ attribute.name }} = None -{% endfor %} - - 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 ): - result = self.__github._dataRequest( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( result ) - self.__completed = True - {% for method in class.methods|dictsort:"name" %} def {{ method.name|join:"_" }}( {% include "GithubObject.Parameters.py" with function=method only %} ): {% if method.request %} @@ -97,6 +77,26 @@ class {{ class.name }}( object ): {% endif %} {% endfor %} + def __initAttributes( self ): +{% for attribute in class.attributes %} + self.__{{ attribute.name }} = None +{% endfor %} + + 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 ): + result = self.__github._dataRequest( + "GET", + self.__url, + None, + None + ) + self.__useAttributes( result ) + self.__completed = True + def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory {% for attribute in class.attributes %} diff --git a/github/GithubObjects/AuthenticatedUser.py b/github/GithubObjects/AuthenticatedUser.py index f4fb233e..3ac65a8d 100644 --- a/github/GithubObjects/AuthenticatedUser.py +++ b/github/GithubObjects/AuthenticatedUser.py @@ -144,48 +144,6 @@ class AuthenticatedUser( object ): self.__completeIfNeeded( self.__url ) return self.__url - def __initAttributes( self ): - self.__avatar_url = None - self.__bio = None - self.__blog = None - self.__collaborators = None - self.__company = None - self.__created_at = None - self.__disk_usage = None - self.__email = None - self.__followers = None - self.__following = None - self.__gravatar_id = None - self.__hireable = None - self.__html_url = None - self.__id = None - self.__location = None - self.__login = None - self.__name = None - self.__owned_private_repos = None - self.__plan = None - self.__private_gists = None - self.__public_gists = None - self.__public_repos = None - self.__total_private_repos = None - self.__type = None - self.__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 ): - result = self.__github._dataRequest( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( result ) - self.__completed = True - def add_to_emails( self, *emails ): pass @@ -437,6 +395,48 @@ class AuthenticatedUser( object ): None ) + def __initAttributes( self ): + self.__avatar_url = None + self.__bio = None + self.__blog = None + self.__collaborators = None + self.__company = None + self.__created_at = None + self.__disk_usage = None + self.__email = None + self.__followers = None + self.__following = None + self.__gravatar_id = None + self.__hireable = None + self.__html_url = None + self.__id = None + self.__location = None + self.__login = None + self.__name = None + self.__owned_private_repos = None + self.__plan = None + self.__private_gists = None + self.__public_gists = None + self.__public_repos = None + self.__total_private_repos = None + self.__type = None + self.__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 ): + result = self.__github._dataRequest( + "GET", + self.__url, + None, + None + ) + self.__useAttributes( result ) + self.__completed = True + def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "avatar_url" in attributes: diff --git a/github/GithubObjects/Authorization.py b/github/GithubObjects/Authorization.py index dcd9482c..18f23446 100644 --- a/github/GithubObjects/Authorization.py +++ b/github/GithubObjects/Authorization.py @@ -56,6 +56,30 @@ class Authorization( object ): self.__completeIfNeeded( self.__url ) return self.__url + def delete( self ): + pass + + def edit( self, scopes = None, add_scopes = None, remove_scopes = None, note = None, note_url = None ): + post_parameters = { + } + if scopes is not None: + post_parameters[ "scopes" ] = scopes + if add_scopes is not None: + post_parameters[ "add_scopes" ] = add_scopes + if remove_scopes is not None: + post_parameters[ "remove_scopes" ] = remove_scopes + if note is not None: + post_parameters[ "note" ] = note + if note_url is not None: + post_parameters[ "note_url" ] = note_url + result = self.__github._dataRequest( + "PATCH", + "https://api.github.com/user", + None, + post_parameters + ) + self.__useAttributes( result ) + def __initAttributes( self ): self.__app = None self.__created_at = None @@ -82,30 +106,6 @@ class Authorization( object ): self.__useAttributes( result ) self.__completed = True - def delete( self ): - pass - - def edit( self, scopes = None, add_scopes = None, remove_scopes = None, note = None, note_url = None ): - post_parameters = { - } - if scopes is not None: - post_parameters[ "scopes" ] = scopes - if add_scopes is not None: - post_parameters[ "add_scopes" ] = add_scopes - if remove_scopes is not None: - post_parameters[ "remove_scopes" ] = remove_scopes - if note is not None: - post_parameters[ "note" ] = note - if note_url is not None: - post_parameters[ "note_url" ] = note_url - result = self.__github._dataRequest( - "PATCH", - "https://api.github.com/user", - None, - post_parameters - ) - self.__useAttributes( result ) - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "app" in attributes: diff --git a/github/GithubObjects/Commit.py b/github/GithubObjects/Commit.py index 4aa2c446..087ebccf 100644 --- a/github/GithubObjects/Commit.py +++ b/github/GithubObjects/Commit.py @@ -54,6 +54,21 @@ class Commit( object ): self.__completeIfNeeded( self.__url ) return self.__url + def create_comment( self, body, commit_id = None, line = None, path = None, position = None ): + pass + + def get_comments( self ): + result = self.__github._dataRequest( + "GET", + self.url + "/comments", + None, + None + ) + return [ + CommitComment.CommitComment( self.__github, element, lazy = True ) + for element in result + ] + def __initAttributes( self ): self.__author = None self.__commit = None @@ -79,21 +94,6 @@ class Commit( object ): self.__useAttributes( result ) self.__completed = True - def create_comment( self, body, commit_id = None, line = None, path = None, position = None ): - pass - - def get_comments( self ): - result = self.__github._dataRequest( - "GET", - self.url + "/comments", - None, - None - ) - return [ - CommitComment.CommitComment( self.__github, element, lazy = True ) - for element in result - ] - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "author" in attributes: diff --git a/github/GithubObjects/CommitComment.py b/github/GithubObjects/CommitComment.py index 7c0b18ff..0ef0eb66 100644 --- a/github/GithubObjects/CommitComment.py +++ b/github/GithubObjects/CommitComment.py @@ -67,6 +67,21 @@ class CommitComment( object ): self.__completeIfNeeded( self.__user ) return self.__user + def delete( self ): + pass + + def edit( self, body ): + post_parameters = { + "body": body, + } + result = self.__github._dataRequest( + "PATCH", + "https://api.github.com/user", + None, + post_parameters + ) + self.__useAttributes( result ) + def __initAttributes( self ): self.__body = None self.__commit_id = None @@ -95,21 +110,6 @@ class CommitComment( object ): self.__useAttributes( result ) self.__completed = True - def delete( self ): - pass - - def edit( self, body ): - post_parameters = { - "body": body, - } - result = self.__github._dataRequest( - "PATCH", - "https://api.github.com/user", - None, - post_parameters - ) - self.__useAttributes( result ) - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "body" in attributes: diff --git a/github/GithubObjects/Download.py b/github/GithubObjects/Download.py index dad69f9a..e153a948 100644 --- a/github/GithubObjects/Download.py +++ b/github/GithubObjects/Download.py @@ -111,6 +111,9 @@ class Download( object ): self.__completeIfNeeded( self.__url ) return self.__url + def delete( self ): + pass + def __initAttributes( self ): self.__accesskeyid = None self.__acl = None @@ -148,9 +151,6 @@ class Download( object ): self.__useAttributes( result ) self.__completed = True - def delete( self ): - pass - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "accesskeyid" in attributes: diff --git a/github/GithubObjects/Gist.py b/github/GithubObjects/Gist.py index 9e698525..3211cc61 100644 --- a/github/GithubObjects/Gist.py +++ b/github/GithubObjects/Gist.py @@ -84,37 +84,6 @@ class Gist( object ): self.__completeIfNeeded( self.__user ) return self.__user - def __initAttributes( self ): - self.__comments = None - self.__created_at = None - self.__description = None - self.__files = None - self.__forks = None - self.__git_pull_url = None - self.__git_push_url = None - self.__history = None - self.__html_url = None - self.__id = None - self.__public = None - self.__updated_at = None - self.__url = None - self.__user = 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 ): - result = self.__github._dataRequest( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( result ) - self.__completed = True - def create_comment( self, body ): pass @@ -163,6 +132,37 @@ class Gist( object ): def set_starred( self ): pass + def __initAttributes( self ): + self.__comments = None + self.__created_at = None + self.__description = None + self.__files = None + self.__forks = None + self.__git_pull_url = None + self.__git_push_url = None + self.__history = None + self.__html_url = None + self.__id = None + self.__public = None + self.__updated_at = None + self.__url = None + self.__user = 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 ): + result = self.__github._dataRequest( + "GET", + self.__url, + None, + None + ) + self.__useAttributes( result ) + self.__completed = True + def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "comments" in attributes: diff --git a/github/GithubObjects/GistComment.py b/github/GithubObjects/GistComment.py index 5a5dcdd8..02cf3907 100644 --- a/github/GithubObjects/GistComment.py +++ b/github/GithubObjects/GistComment.py @@ -42,6 +42,21 @@ class GistComment( object ): self.__completeIfNeeded( self.__user ) return self.__user + def delete( self ): + pass + + def edit( self, body ): + post_parameters = { + "body": body, + } + result = self.__github._dataRequest( + "PATCH", + "https://api.github.com/user", + None, + post_parameters + ) + self.__useAttributes( result ) + def __initAttributes( self ): self.__body = None self.__created_at = None @@ -65,21 +80,6 @@ class GistComment( object ): self.__useAttributes( result ) self.__completed = True - def delete( self ): - pass - - def edit( self, body ): - post_parameters = { - "body": body, - } - result = self.__github._dataRequest( - "PATCH", - "https://api.github.com/user", - None, - post_parameters - ) - self.__useAttributes( result ) - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "body" in attributes: diff --git a/github/GithubObjects/GitRef.py b/github/GithubObjects/GitRef.py index 31ee1caa..c67c91d1 100644 --- a/github/GithubObjects/GitRef.py +++ b/github/GithubObjects/GitRef.py @@ -26,6 +26,23 @@ class GitRef( object ): self.__completeIfNeeded( self.__url ) return self.__url + def delete( self ): + pass + + def edit( self, sha, force = None ): + post_parameters = { + "sha": sha, + } + if force is not None: + post_parameters[ "force" ] = force + result = self.__github._dataRequest( + "PATCH", + "https://api.github.com/user", + None, + post_parameters + ) + self.__useAttributes( result ) + def __initAttributes( self ): self.__object = None self.__ref = None @@ -46,23 +63,6 @@ class GitRef( object ): self.__useAttributes( result ) self.__completed = True - def delete( self ): - pass - - def edit( self, sha, force = None ): - post_parameters = { - "sha": sha, - } - if force is not None: - post_parameters[ "force" ] = force - result = self.__github._dataRequest( - "PATCH", - "https://api.github.com/user", - None, - post_parameters - ) - self.__useAttributes( result ) - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "object" in attributes: diff --git a/github/GithubObjects/Hook.py b/github/GithubObjects/Hook.py index db3f4419..11ac7924 100644 --- a/github/GithubObjects/Hook.py +++ b/github/GithubObjects/Hook.py @@ -56,32 +56,6 @@ class Hook( object ): self.__completeIfNeeded( self.__url ) return self.__url - def __initAttributes( self ): - self.__active = None - self.__config = None - self.__created_at = None - self.__events = None - self.__id = None - self.__last_response = None - self.__name = None - self.__updated_at = None - self.__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 ): - result = self.__github._dataRequest( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( result ) - self.__completed = True - def delete( self ): pass @@ -109,6 +83,32 @@ class Hook( object ): def test( self ): pass + def __initAttributes( self ): + self.__active = None + self.__config = None + self.__created_at = None + self.__events = None + self.__id = None + self.__last_response = None + self.__name = None + self.__updated_at = None + self.__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 ): + result = self.__github._dataRequest( + "GET", + self.__url, + None, + None + ) + self.__useAttributes( result ) + self.__completed = True + def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "active" in attributes: diff --git a/github/GithubObjects/Issue.py b/github/GithubObjects/Issue.py index f31b2dc0..06ecd2dc 100644 --- a/github/GithubObjects/Issue.py +++ b/github/GithubObjects/Issue.py @@ -101,40 +101,6 @@ class Issue( object ): self.__completeIfNeeded( self.__user ) return self.__user - def __initAttributes( self ): - self.__assignee = None - self.__body = None - self.__closed_at = None - self.__closed_by = None - self.__comments = None - self.__created_at = None - self.__html_url = None - self.__id = None - self.__labels = None - self.__milestone = None - self.__number = None - self.__pull_request = None - self.__state = None - self.__title = None - self.__updated_at = None - self.__url = None - self.__user = 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 ): - result = self.__github._dataRequest( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( result ) - self.__completed = True - def add_to_labels( self, *labels ): pass @@ -217,6 +183,40 @@ class Issue( object ): def set_labels( self, *labels ): pass + def __initAttributes( self ): + self.__assignee = None + self.__body = None + self.__closed_at = None + self.__closed_by = None + self.__comments = None + self.__created_at = None + self.__html_url = None + self.__id = None + self.__labels = None + self.__milestone = None + self.__number = None + self.__pull_request = None + self.__state = None + self.__title = None + self.__updated_at = None + self.__url = None + self.__user = 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 ): + result = self.__github._dataRequest( + "GET", + self.__url, + None, + None + ) + self.__useAttributes( result ) + self.__completed = True + def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "assignee" in attributes: diff --git a/github/GithubObjects/IssueComment.py b/github/GithubObjects/IssueComment.py index 1f28970f..addbbf6e 100644 --- a/github/GithubObjects/IssueComment.py +++ b/github/GithubObjects/IssueComment.py @@ -42,6 +42,21 @@ class IssueComment( object ): self.__completeIfNeeded( self.__user ) return self.__user + def delete( self ): + pass + + def edit( self, body ): + post_parameters = { + "body": body, + } + result = self.__github._dataRequest( + "PATCH", + "https://api.github.com/user", + None, + post_parameters + ) + self.__useAttributes( result ) + def __initAttributes( self ): self.__body = None self.__created_at = None @@ -65,21 +80,6 @@ class IssueComment( object ): self.__useAttributes( result ) self.__completed = True - def delete( self ): - pass - - def edit( self, body ): - post_parameters = { - "body": body, - } - result = self.__github._dataRequest( - "PATCH", - "https://api.github.com/user", - None, - post_parameters - ) - self.__useAttributes( result ) - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "body" in attributes: diff --git a/github/GithubObjects/Label.py b/github/GithubObjects/Label.py index 1c362780..14ac8e70 100644 --- a/github/GithubObjects/Label.py +++ b/github/GithubObjects/Label.py @@ -26,6 +26,22 @@ class Label( object ): self.__completeIfNeeded( self.__url ) return self.__url + def delete( self ): + pass + + def edit( self, name, color ): + post_parameters = { + "name": name, + "color": color, + } + result = self.__github._dataRequest( + "PATCH", + "https://api.github.com/user", + None, + post_parameters + ) + self.__useAttributes( result ) + def __initAttributes( self ): self.__color = None self.__name = None @@ -46,22 +62,6 @@ class Label( object ): self.__useAttributes( result ) self.__completed = True - def delete( self ): - pass - - def edit( self, name, color ): - post_parameters = { - "name": name, - "color": color, - } - result = self.__github._dataRequest( - "PATCH", - "https://api.github.com/user", - None, - post_parameters - ) - self.__useAttributes( result ) - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "color" in attributes: diff --git a/github/GithubObjects/Milestone.py b/github/GithubObjects/Milestone.py index deb22ffa..216b7065 100644 --- a/github/GithubObjects/Milestone.py +++ b/github/GithubObjects/Milestone.py @@ -63,33 +63,6 @@ class Milestone( object ): self.__completeIfNeeded( self.__url ) return self.__url - def __initAttributes( self ): - self.__closed_issues = None - self.__created_at = None - self.__creator = None - self.__description = None - self.__due_on = None - self.__number = None - self.__open_issues = None - self.__state = None - self.__title = None - self.__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 ): - result = self.__github._dataRequest( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( result ) - self.__completed = True - def delete( self ): pass @@ -123,6 +96,33 @@ class Milestone( object ): for element in result ] + def __initAttributes( self ): + self.__closed_issues = None + self.__created_at = None + self.__creator = None + self.__description = None + self.__due_on = None + self.__number = None + self.__open_issues = None + self.__state = None + self.__title = None + self.__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 ): + result = self.__github._dataRequest( + "GET", + self.__url, + None, + None + ) + self.__useAttributes( result ) + self.__completed = True + def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "closed_issues" in attributes: diff --git a/github/GithubObjects/NamedUser.py b/github/GithubObjects/NamedUser.py index 04cbaf21..46589654 100644 --- a/github/GithubObjects/NamedUser.py +++ b/github/GithubObjects/NamedUser.py @@ -146,49 +146,6 @@ class NamedUser( object ): self.__completeIfNeeded( self.__url ) return self.__url - def __initAttributes( self ): - self.__avatar_url = None - self.__bio = None - self.__blog = None - self.__collaborators = None - self.__company = None - self.__contributions = None - self.__created_at = None - self.__disk_usage = None - self.__email = None - self.__followers = None - self.__following = None - self.__gravatar_id = None - self.__hireable = None - self.__html_url = None - self.__id = None - self.__location = None - self.__login = None - self.__name = None - self.__owned_private_repos = None - self.__plan = None - self.__private_gists = None - self.__public_gists = None - self.__public_repos = None - self.__total_private_repos = None - self.__type = None - self.__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 ): - result = self.__github._dataRequest( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( result ) - self.__completed = True - def create_gist( self, public, files, description = None ): pass @@ -294,6 +251,49 @@ class NamedUser( object ): for element in result ] + def __initAttributes( self ): + self.__avatar_url = None + self.__bio = None + self.__blog = None + self.__collaborators = None + self.__company = None + self.__contributions = None + self.__created_at = None + self.__disk_usage = None + self.__email = None + self.__followers = None + self.__following = None + self.__gravatar_id = None + self.__hireable = None + self.__html_url = None + self.__id = None + self.__location = None + self.__login = None + self.__name = None + self.__owned_private_repos = None + self.__plan = None + self.__private_gists = None + self.__public_gists = None + self.__public_repos = None + self.__total_private_repos = None + self.__type = None + self.__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 ): + result = self.__github._dataRequest( + "GET", + self.__url, + None, + None + ) + self.__useAttributes( result ) + self.__completed = True + def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "avatar_url" in attributes: diff --git a/github/GithubObjects/Organization.py b/github/GithubObjects/Organization.py index 1d866b8a..82bbb2ea 100644 --- a/github/GithubObjects/Organization.py +++ b/github/GithubObjects/Organization.py @@ -135,47 +135,6 @@ class Organization( object ): self.__completeIfNeeded( self.__url ) return self.__url - def __initAttributes( self ): - self.__avatar_url = None - self.__billing_email = None - self.__blog = None - self.__collaborators = None - self.__company = None - self.__created_at = None - self.__disk_usage = None - self.__email = None - self.__followers = None - self.__following = None - self.__gravatar_id = None - self.__html_url = None - self.__id = None - self.__location = None - self.__login = None - self.__name = None - self.__owned_private_repos = None - self.__plan = None - self.__private_gists = None - self.__public_gists = None - self.__public_repos = None - self.__total_private_repos = None - self.__type = None - self.__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 ): - result = self.__github._dataRequest( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( result ) - self.__completed = True - def add_to_public_members( self, public_member ): result = self.__github._statusRequest( "PUT", @@ -319,6 +278,47 @@ class Organization( object ): None ) + def __initAttributes( self ): + self.__avatar_url = None + self.__billing_email = None + self.__blog = None + self.__collaborators = None + self.__company = None + self.__created_at = None + self.__disk_usage = None + self.__email = None + self.__followers = None + self.__following = None + self.__gravatar_id = None + self.__html_url = None + self.__id = None + self.__location = None + self.__login = None + self.__name = None + self.__owned_private_repos = None + self.__plan = None + self.__private_gists = None + self.__public_gists = None + self.__public_repos = None + self.__total_private_repos = None + self.__type = None + self.__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 ): + result = self.__github._dataRequest( + "GET", + self.__url, + None, + None + ) + self.__useAttributes( result ) + self.__completed = True + def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "avatar_url" in attributes: diff --git a/github/GithubObjects/PullRequest.py b/github/GithubObjects/PullRequest.py index d222eb77..0677bd47 100644 --- a/github/GithubObjects/PullRequest.py +++ b/github/GithubObjects/PullRequest.py @@ -145,49 +145,6 @@ class PullRequest( object ): self.__completeIfNeeded( self.__user ) return self.__user - def __initAttributes( self ): - self.__additions = None - self.__base = None - self.__body = None - self.__changed_files = None - self.__closed_at = None - self.__comments = None - self.__commits = None - self.__created_at = None - self.__deletions = None - self.__diff_url = None - self.__head = None - self.__html_url = None - self.__id = None - self.__issue_url = None - self.__mergeable = None - self.__merged = None - self.__merged_at = None - self.__merged_by = None - self.__number = None - self.__patch_url = None - self.__review_comments = None - self.__state = None - self.__title = None - self.__updated_at = None - self.__url = None - self.__user = 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 ): - result = self.__github._dataRequest( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( result ) - self.__completed = True - def edit( self, title = None, body = None, state = None ): post_parameters = { } @@ -250,6 +207,49 @@ class PullRequest( object ): def merge( self, commit_message = None ): pass + def __initAttributes( self ): + self.__additions = None + self.__base = None + self.__body = None + self.__changed_files = None + self.__closed_at = None + self.__comments = None + self.__commits = None + self.__created_at = None + self.__deletions = None + self.__diff_url = None + self.__head = None + self.__html_url = None + self.__id = None + self.__issue_url = None + self.__mergeable = None + self.__merged = None + self.__merged_at = None + self.__merged_by = None + self.__number = None + self.__patch_url = None + self.__review_comments = None + self.__state = None + self.__title = None + self.__updated_at = None + self.__url = None + self.__user = 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 ): + result = self.__github._dataRequest( + "GET", + self.__url, + None, + None + ) + self.__useAttributes( result ) + 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: diff --git a/github/GithubObjects/PullRequestComment.py b/github/GithubObjects/PullRequestComment.py index a1b3d20e..de6aa4be 100644 --- a/github/GithubObjects/PullRequestComment.py +++ b/github/GithubObjects/PullRequestComment.py @@ -67,6 +67,21 @@ class PullRequestComment( object ): self.__completeIfNeeded( self.__user ) return self.__user + def delete( self ): + pass + + def edit( self, body ): + post_parameters = { + "body": body, + } + result = self.__github._dataRequest( + "PATCH", + "https://api.github.com/user", + None, + post_parameters + ) + self.__useAttributes( result ) + def __initAttributes( self ): self.__body = None self.__commit_id = None @@ -95,21 +110,6 @@ class PullRequestComment( object ): self.__useAttributes( result ) self.__completed = True - def delete( self ): - pass - - def edit( self, body ): - post_parameters = { - "body": body, - } - result = self.__github._dataRequest( - "PATCH", - "https://api.github.com/user", - None, - post_parameters - ) - self.__useAttributes( result ) - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "body" in attributes: diff --git a/github/GithubObjects/Repository.py b/github/GithubObjects/Repository.py index aebc555a..8f70de54 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -182,53 +182,6 @@ class Repository( object ): self.__completeIfNeeded( self.__watchers ) return self.__watchers - def __initAttributes( self ): - self.__clone_url = None - self.__created_at = None - self.__description = None - self.__fork = None - self.__forks = None - self.__git_url = None - self.__has_downloads = None - self.__has_issues = None - self.__has_wiki = None - self.__homepage = None - self.__html_url = None - self.__id = None - self.__language = None - self.__master_branch = None - self.__mirror_url = None - self.__name = None - self.__open_issues = None - self.__organization = None - self.__owner = None - self.__parent = None - self.__permissions = None - self.__private = None - self.__pushed_at = None - self.__size = None - self.__source = None - self.__ssh_url = None - self.__svn_url = None - self.__updated_at = None - self.__url = None - self.__watchers = 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 ): - result = self.__github._dataRequest( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( result ) - self.__completed = True - def add_to_collaborators( self, collaborator ): result = self.__github._statusRequest( "PUT", @@ -593,6 +546,53 @@ class Repository( object ): None ) + def __initAttributes( self ): + self.__clone_url = None + self.__created_at = None + self.__description = None + self.__fork = None + self.__forks = None + self.__git_url = None + self.__has_downloads = None + self.__has_issues = None + self.__has_wiki = None + self.__homepage = None + self.__html_url = None + self.__id = None + self.__language = None + self.__master_branch = None + self.__mirror_url = None + self.__name = None + self.__open_issues = None + self.__organization = None + self.__owner = None + self.__parent = None + self.__permissions = None + self.__private = None + self.__pushed_at = None + self.__size = None + self.__source = None + self.__ssh_url = None + self.__svn_url = None + self.__updated_at = None + self.__url = None + self.__watchers = 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 ): + result = self.__github._dataRequest( + "GET", + self.__url, + None, + None + ) + self.__useAttributes( result ) + self.__completed = True + def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "clone_url" in attributes: diff --git a/github/GithubObjects/RepositoryKey.py b/github/GithubObjects/RepositoryKey.py index 535d7081..9d8f2f62 100644 --- a/github/GithubObjects/RepositoryKey.py +++ b/github/GithubObjects/RepositoryKey.py @@ -31,6 +31,22 @@ class RepositoryKey( object ): self.__completeIfNeeded( self.__url ) return self.__url + def delete( self ): + pass + + def edit( self, title, key ): + post_parameters = { + "title": title, + "key": key, + } + result = self.__github._dataRequest( + "PATCH", + "https://api.github.com/user", + None, + post_parameters + ) + self.__useAttributes( result ) + def __initAttributes( self ): self.__id = None self.__key = None @@ -52,22 +68,6 @@ class RepositoryKey( object ): self.__useAttributes( result ) self.__completed = True - def delete( self ): - pass - - def edit( self, title, key ): - post_parameters = { - "title": title, - "key": key, - } - result = self.__github._dataRequest( - "PATCH", - "https://api.github.com/user", - None, - post_parameters - ) - self.__useAttributes( result ) - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "id" in attributes: diff --git a/github/GithubObjects/Team.py b/github/GithubObjects/Team.py index d4c17bd4..65073b99 100644 --- a/github/GithubObjects/Team.py +++ b/github/GithubObjects/Team.py @@ -43,29 +43,6 @@ class Team( object ): self.__completeIfNeeded( self.__url ) return self.__url - def __initAttributes( self ): - self.__id = None - self.__members_count = None - self.__name = None - self.__permission = None - self.__repos_count = None - self.__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 ): - result = self.__github._dataRequest( - "GET", - self.__url, - None, - None - ) - self.__useAttributes( result ) - self.__completed = True - def add_to_members( self, member ): result = self.__github._statusRequest( "PUT", @@ -157,6 +134,29 @@ class Team( object ): None ) + def __initAttributes( self ): + self.__id = None + self.__members_count = None + self.__name = None + self.__permission = None + self.__repos_count = None + self.__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 ): + result = self.__github._dataRequest( + "GET", + self.__url, + None, + None + ) + self.__useAttributes( result ) + self.__completed = True + def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "id" in attributes: diff --git a/github/GithubObjects/UserKey.py b/github/GithubObjects/UserKey.py index 28c5b80b..79aac42b 100644 --- a/github/GithubObjects/UserKey.py +++ b/github/GithubObjects/UserKey.py @@ -31,6 +31,24 @@ class UserKey( object ): self.__completeIfNeeded( self.__url ) return self.__url + def delete( self ): + pass + + def edit( self, title = None, key = None ): + post_parameters = { + } + if title is not None: + post_parameters[ "title" ] = title + if key is not None: + post_parameters[ "key" ] = key + result = self.__github._dataRequest( + "PATCH", + "https://api.github.com/user", + None, + post_parameters + ) + self.__useAttributes( result ) + def __initAttributes( self ): self.__id = None self.__key = None @@ -52,24 +70,6 @@ class UserKey( object ): self.__useAttributes( result ) self.__completed = True - def delete( self ): - pass - - def edit( self, title = None, key = None ): - post_parameters = { - } - if title is not None: - post_parameters[ "title" ] = title - if key is not None: - post_parameters[ "key" ] = key - result = self.__github._dataRequest( - "PATCH", - "https://api.github.com/user", - None, - post_parameters - ) - self.__useAttributes( result ) - def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory if "id" in attributes: