diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index 8230f5fd..ad6cdfc7 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -55,7 +55,7 @@ API `/gists/starred` API `/issues` ============= -* GET: (TODO) +* GET: `AuthenticatedUser.get_issues` API `/networks/:user/:repo/events` ================================== @@ -143,7 +143,7 @@ API `/repos/:user/:repo/commits/:sha/comments` API `/repos/:user/:repo/compare/:base...:head` ============================================== -* GET: (TODO) +* GET: `Repository.compare` API `/repos/:user/:repo/contributors` ===================================== @@ -206,18 +206,10 @@ API `/repos/:user/:repo/git/trees` ================================== * POST: `Repository.create_git_tree` -API `/repos/:user/:repo/git/trees?base_tree=` -============================================= -* POST: (TODO) - API `/repos/:user/:repo/git/trees/:sha` ======================================= * GET: `Repository.get_git_tree` -API `/repos/:user/:repo/git/trees/:sha?recursive=1` -=================================================== -* GET: (TODO) - API `/repos/:user/:repo/hooks` ============================== * GET: `Repository.get_hooks` @@ -321,7 +313,7 @@ API `/repos/:user/:repo/milestones/:number/labels` API `/repos/:user/:repo/pulls` ============================== * GET: `Repository.get_pulls` -* POST: `Repository.create_pull` (TODO: alternative input) +* POST: `Repository.create_pull` API `/repos/:user/:repo/pulls/:id` ================================== @@ -331,7 +323,7 @@ API `/repos/:user/:repo/pulls/:id` API `/repos/:user/:repo/pulls/:id/comments` =========================================== * GET: `PullRequest.get_comments` -* POST: `PullRequest.create_comment` (TODO: alternative input) +* POST: `PullRequest.create_comment` API `/repos/:user/:repo/pulls/:id/commits` ========================================== diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index 5c47e16d..22a7fdb3 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -119,6 +119,10 @@ Gists * `create_gist( public, files, [description] )`: `Gist` * `get_starred_gists()`: list of `Gist` +Issues +------ +* `get_issues()`: list of `Issue` + Class `Authorization` ===================== @@ -363,6 +367,7 @@ Attributes * `sha` * `url` * `tree` +* `recursive` Class `Hook` ============ @@ -703,7 +708,7 @@ Comments -------- * `get_comments()`: list of `PullRequestComment` * `get_comment( id )`: `PullRequestComment` -* `create_comment( body, commit_id, path, position )`: `PullRequestComment` +* `create_comment( < body, commit_id, path, position > or < body, in_reply_to > )`: `PullRequestComment` * `is_merged()`: bool * `merge( [commit_message] )` @@ -842,8 +847,8 @@ Git commits Git trees --------- -* `get_git_tree( sha )`: `GitTree` -* `create_git_tree( tree )`: `GitTree` +* `get_git_tree( sha, [recursive] )`: `GitTree` +* `create_git_tree( tree, [base_tree] )`: `GitTree` Git blobs --------- @@ -901,7 +906,8 @@ Pulls ----- * `get_pulls( [state] )`: list of `PullRequest` * `get_pull( number )`: `PullRequest` -* `create_pull( title, body, base, head )`: `PullRequest` +* `create_pull( < title, body, base, head > or < issue, base, head > )`: `PullRequest` +* `compare( base, head )` Teams ----- diff --git a/github/GithubObjects/AuthenticatedUser.py b/github/GithubObjects/AuthenticatedUser.py index 2a48a033..22d7121f 100644 --- a/github/GithubObjects/AuthenticatedUser.py +++ b/github/GithubObjects/AuthenticatedUser.py @@ -5,6 +5,7 @@ from NamedUser import * from Organization import * from Repository import * from Gist import * +from Issue import * def __getOrganizationEvents( user, org ): return [ @@ -34,56 +35,60 @@ AuthenticatedUser = GithubObject( "type", "total_private_repos", "owned_private_repos", "private_gists", "disk_usage", "collaborators", "plan", ), - Editable( [], [ "name", "email", "blog", "company", "location", "hireable", "bio" ] ), + Editable( Parameters( [], [ "name", "email", "blog", "company", "location", "hireable", "bio" ] ) ), ExternalListOfSimpleTypes( "emails", "email", "string", - ListGetable( [], [] ), + ListGetable( Parameters( [], [] ) ), SeveralElementsAddable(), SeveralElementsRemovable() ), ExternalListOfObjects( "authorizations", "authorization", Authorization, - ListGetable( [], [] ), - ElementGetable( [ "id" ], [] ), - ElementCreatable( [], [ "scopes", "note", "note_url" ] ), + ListGetable( Parameters( [], [] ) ), + ElementGetable( Parameters( [ "id" ], [] ) ), + ElementCreatable( Parameters( [], [ "scopes", "note", "note_url" ] ) ), url = "/authorizations", ), ExternalListOfObjects( "keys", "key", UserKey, - ListGetable( [], [] ), - ElementGetable( [ "id" ], [] ), - ElementCreatable( [ "title", "key" ], [] ), + ListGetable( Parameters( [], [] ) ), + ElementGetable( Parameters( [ "id" ], [] ) ), + ElementCreatable( Parameters( [ "title", "key" ], [] ) ), ), ExternalListOfObjects( "events", "event", Event, - ListGetable( [], [] ), + ListGetable( Parameters( [], [] ) ), url = "/events" ), ExternalListOfObjects( "followers", "follower", NamedUser, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ), ExternalListOfObjects( "following", "following", NamedUser, - ListGetable( [], [] ), + ListGetable( Parameters( [], [] ) ), ElementAddable(), ElementRemovable(), ElementHasable() ), ExternalListOfObjects( "orgs", "org", Organization, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ), - MethodFromCallable( "get_organization_events", [ "org" ], [], __getOrganizationEvents, SimpleTypePolicy( "list of `Event`" ) ), + MethodFromCallable( "get_organization_events", Parameters( [ "org" ], [] ), __getOrganizationEvents, SimpleTypePolicy( "list of `Event`" ) ), ExternalListOfObjects( "repos", "repo", Repository, - ListGetable( [], [ "type" ] ), - ElementGetable( [ "name" ], [], { "owner" : lambda user: { "login": user.login } } ), - ElementCreatable( [ "name" ], [ "description", "homepage", "private", "has_issues", "has_wiki", "has_downloads", "team_id", ] ) + ListGetable( Parameters( [], [ "type" ] ) ), + ElementGetable( Parameters( [ "name" ], [] ), { "owner" : lambda user: { "login": user.login } } ), + ElementCreatable( Parameters( [ "name" ], [ "description", "homepage", "private", "has_issues", "has_wiki", "has_downloads", "team_id", ] ) ) ), ExternalListOfObjects( "watched", "watched", Repository, - ListGetable( [], [] ), + ListGetable( Parameters( [], [] ) ), ElementAddable(), ElementRemovable(), ElementHasable() ), - SeveralAttributePolicies( [ MethodFromCallable( "create_fork", [ "repo" ], [], __createFork, ObjectTypePolicy( Repository ) ) ], "Forking" ), + SeveralAttributePolicies( [ MethodFromCallable( "create_fork", Parameters( [ "repo" ], [] ), __createFork, ObjectTypePolicy( Repository ) ) ], "Forking" ), ExternalListOfObjects( "gists", "gist", Gist, - ListGetable( [], [] ), - ElementCreatable( [ "public", "files", ], [ "description" ] ), + ListGetable( Parameters( [], [] ) ), + ElementCreatable( Parameters( [ "public", "files", ], [ "description" ] ) ), url = "/gists", ), - MethodFromCallable( "get_starred_gists", [], [], __getStaredGists, SimpleTypePolicy( "list of `Gist`" ) ), + MethodFromCallable( "get_starred_gists", Parameters( [], [] ), __getStaredGists, SimpleTypePolicy( "list of `Gist`" ) ), + ExternalListOfObjects( "issues", "issue", Issue, + ListGetable( Parameters( [], [] ) ), + url = "/issues", + ), ) diff --git a/github/GithubObjects/Authorization.py b/github/GithubObjects/Authorization.py index 7b83f334..2316041b 100644 --- a/github/GithubObjects/Authorization.py +++ b/github/GithubObjects/Authorization.py @@ -7,6 +7,6 @@ Authorization = GithubObject( "id", "url", "scopes", "token", "app", "note", "note_url", "updated_at", "created_at", ), - Editable( [], [ "scopes", "add_scopes", "remove_scopes", "note", "note_url" ] ), + Editable( Parameters( [], [ "scopes", "add_scopes", "remove_scopes", "note", "note_url" ] ) ), Deletable(), ) diff --git a/github/GithubObjects/Commit.py b/github/GithubObjects/Commit.py index 8d92597b..3a990227 100644 --- a/github/GithubObjects/Commit.py +++ b/github/GithubObjects/Commit.py @@ -18,7 +18,7 @@ Commit = GithubObject( InternalObjectAttribute( "author", NamedUser ), InternalObjectAttribute( "committer", NamedUser ), ExternalListOfObjects( "comments", "comment", CommitComment, - ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ), - ElementCreatable( [ "body" ], [ "commit_id", "line", "path", "position" ], __modifyAttributesForObjectsReferingReferedRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingReferedRepo ), + ElementCreatable( Parameters( [ "body" ], [ "commit_id", "line", "path", "position" ] ), __modifyAttributesForObjectsReferingReferedRepo ), ), ) diff --git a/github/GithubObjects/CommitComment.py b/github/GithubObjects/CommitComment.py index 9d38fe34..5bb93108 100644 --- a/github/GithubObjects/CommitComment.py +++ b/github/GithubObjects/CommitComment.py @@ -9,6 +9,6 @@ CommitComment = GithubObject( "_repo", ), InternalObjectAttribute( "user", NamedUser ), - Editable( [ "body" ], [] ), + Editable( Parameters( [ "body" ], [] ) ), Deletable(), ) diff --git a/github/GithubObjects/Gist.py b/github/GithubObjects/Gist.py index 9ce601c0..771c33f7 100644 --- a/github/GithubObjects/Gist.py +++ b/github/GithubObjects/Gist.py @@ -16,22 +16,22 @@ Gist = GithubObject( "updated_at", ), InternalObjectAttribute( "user", NamedUser ), - Editable( [], [ "description", "files" ] ), + Editable( Parameters( [], [ "description", "files" ] ) ), Deletable(), ExternalListOfObjects( "comments", "comment", GistComment, - ListGetable( [], [] ), - ElementGetable( [ "id" ], [] ), - ElementCreatable( [ "body" ], [] ), + ListGetable( Parameters( [], [] ) ), + ElementGetable( Parameters( [ "id" ], [] ) ), + ElementCreatable( Parameters( [ "body" ], [] ) ), ), SeveralAttributePolicies( [ - MethodFromCallable( "is_starred", [], [], __isStarred, SimpleTypePolicy( "bool" ) ), - MethodFromCallable( "set_starred", [], [], __setStarred, SimpleTypePolicy( None ) ), - MethodFromCallable( "reset_starred", [], [], __resetStarred, SimpleTypePolicy( None ) ), + MethodFromCallable( "is_starred", Parameters( [], [] ), __isStarred, SimpleTypePolicy( "bool" ) ), + MethodFromCallable( "set_starred", Parameters( [], [] ), __setStarred, SimpleTypePolicy( None ) ), + MethodFromCallable( "reset_starred", Parameters( [], [] ), __resetStarred, SimpleTypePolicy( None ) ), ], "Starring" ), ) def __createFork( gist ): return Gist( gist._github, gist._github._dataRequest( "POST", gist._baseUrl() + "/fork", None, None ), lazy = True ) Gist._addAttributePolicy( SeveralAttributePolicies( [ - MethodFromCallable( "create_fork", [], [], __createFork, ObjectTypePolicy( Gist ) ), + MethodFromCallable( "create_fork", Parameters( [], [] ), __createFork, ObjectTypePolicy( Gist ) ), ], "Forking" ), ) diff --git a/github/GithubObjects/GistComment.py b/github/GithubObjects/GistComment.py index 88fd3b3b..4fc4c442 100644 --- a/github/GithubObjects/GistComment.py +++ b/github/GithubObjects/GistComment.py @@ -8,6 +8,6 @@ GistComment = GithubObject( "updated_at", ), InternalObjectAttribute( "user", NamedUser ), - Editable( [ "body" ], [] ), + Editable( Parameters( [ "body" ], [] ) ), Deletable(), ) diff --git a/github/GithubObjects/GitRef.py b/github/GithubObjects/GitRef.py index 4ac2d8e8..34da1a29 100644 --- a/github/GithubObjects/GitRef.py +++ b/github/GithubObjects/GitRef.py @@ -8,5 +8,5 @@ GitRef = GithubObject( "object", "_repo", ), - Editable( [ "sha" ], [ "force" ] ), + Editable( Parameters( [ "sha" ], [ "force" ] ) ), ) diff --git a/github/GithubObjects/GitTree.py b/github/GithubObjects/GitTree.py index a7ac8bd5..87666f3f 100644 --- a/github/GithubObjects/GitTree.py +++ b/github/GithubObjects/GitTree.py @@ -2,10 +2,10 @@ from GithubObject import * GitTree = GithubObject( "GitTree", - BaseUrl( lambda obj: obj._repo._baseUrl() + "/git/trees/" + obj.sha ), + BaseUrl( lambda obj: obj._repo._baseUrl() + "/git/trees/" + obj.sha + "?recursive=1" if obj.recursive else "" ), InternalSimpleAttributes( "sha", "url", "tree", - "_repo", + "_repo", "recursive", ), ) diff --git a/github/GithubObjects/GithubObject/ArgumentsChecker.py b/github/GithubObjects/GithubObject/ArgumentsChecker.py index 8b08e1c2..b2c5b054 100644 --- a/github/GithubObjects/GithubObject/ArgumentsChecker.py +++ b/github/GithubObjects/GithubObject/ArgumentsChecker.py @@ -1,6 +1,6 @@ import itertools -class ArgumentsChecker: +class Parameters: def __init__( self, mandatoryParameters, optionalParameters ): self.__mandatoryParameters = mandatoryParameters self.__optionalParameters = optionalParameters @@ -34,3 +34,24 @@ class ArgumentsChecker: return " " + mandatory + " " else: return " " + mandatory + ", " + optional + " " + +def NoParameters(): + return Parameters( [], [] ) + +class Alternative: + def __init__( self, *checkers ): + self.__checkers = checkers + + def check( self, args, kwds ): + # Try the n - 1 first checkers + for checker in self.__checkers[ : -1 ]: + try: + return checker.check( args, kwds ) + except TypeError: + pass + # Use the last checker + # This way, the call stack will point to an actual validation failure + return self.__checkers[ -1 ].check( args, kwds ) + + def documentParameters( self ): + return " <" + "> or <".join( checker.documentParameters() for checker in self.__checkers ) + "> " diff --git a/github/GithubObjects/GithubObject/Basic.py b/github/GithubObjects/GithubObject/Basic.py index 4435b862..2702c9f4 100644 --- a/github/GithubObjects/GithubObject/Basic.py +++ b/github/GithubObjects/GithubObject/Basic.py @@ -1,5 +1,3 @@ -from ArgumentsChecker import * - class AttributeFromCallable: class AttributeDefinition: def __init__( self, name, callable ): @@ -26,8 +24,8 @@ class AttributeFromCallable: return "" class MethodFromCallable: - def __init__( self, name, mandatoryParameters, optionalParameters, callable, returnTypePolicy ): - self.__argumentsChecker = ArgumentsChecker( mandatoryParameters, optionalParameters ) + def __init__( self, name, parameters, callable, returnTypePolicy ): + self.__argumentsChecker = parameters self.__name = name self.__callable = callable self.__returnTypePolicy = returnTypePolicy diff --git a/github/GithubObjects/GithubObject/GithubObject.py b/github/GithubObjects/GithubObject/GithubObject.py index 023509b9..30d515e9 100644 --- a/github/GithubObjects/GithubObject/GithubObject.py +++ b/github/GithubObjects/GithubObject/GithubObject.py @@ -21,21 +21,21 @@ def ExternalSimpleAttribute( attributeName, type ): return ExternalAttribute( attributeName, SimpleTypePolicy( type ) ) def BaseUrl( baseUrl ): - return MethodFromCallable( "_baseUrl", [], [], baseUrl, SimpleTypePolicy( None ) ) + return MethodFromCallable( "_baseUrl", NoParameters(), baseUrl, SimpleTypePolicy( None ) ) def Identity( identity ): return AttributeFromCallable( "_identity", identity ) -def Editable( mandatoryParameters, optionalParameters ): +def Editable( parameters ): def __execute( obj, **data ): attributes = obj._github._dataRequest( "PATCH", obj._baseUrl(), None, data ) obj._updateAttributes( attributes ) - return SeveralAttributePolicies( [ MethodFromCallable( "edit", mandatoryParameters, optionalParameters, __execute, SimpleTypePolicy( None ) ) ], "Modification" ) + return SeveralAttributePolicies( [ MethodFromCallable( "edit", parameters, __execute, SimpleTypePolicy( None ) ) ], "Modification" ) def Deletable(): def __execute( obj ): obj._github._statusRequest( "DELETE", obj._baseUrl(), None, None ) - return SeveralAttributePolicies( [ MethodFromCallable( "delete", [], [], __execute, SimpleTypePolicy( None ) ) ], "Deletion" ) + return SeveralAttributePolicies( [ MethodFromCallable( "delete", NoParameters(), __execute, SimpleTypePolicy( None ) ) ], "Deletion" ) def GithubObject( className, *attributePolicies ): class GithubObject: diff --git a/github/GithubObjects/GithubObject/List.py b/github/GithubObjects/GithubObject/List.py index ce824a9e..b4d29b38 100644 --- a/github/GithubObjects/GithubObject/List.py +++ b/github/GithubObjects/GithubObject/List.py @@ -74,9 +74,9 @@ class ListCapacityWithModifier( ListCapacity ): return attributes class ElementCreatable( ListCapacityWithModifier ): - def __init__( self, mandatoryParameters, optionalParameters, attributeModifiers = {} ): + def __init__( self, parameters = NoParameters(), attributeModifiers = {} ): ListCapacityWithModifier.__init__( self, attributeModifiers ) - self.__argumentsChecker = ArgumentsChecker( mandatoryParameters, optionalParameters ) + self.__argumentsChecker = parameters def apply( self, cls ): cls._addMethod( "create_" + self.singularName, self.__execute ) @@ -99,9 +99,9 @@ class ElementCreatable( ListCapacityWithModifier ): return "* `create_" + self.singularName + "(" + self.__argumentsChecker.documentParameters() + ")`: " + self.typePolicy.documentTypeName() + "\n" class ElementGetable( ListCapacityWithModifier ): - def __init__( self, mandatoryParameters, optionalParameters, attributeModifiers = {} ): + def __init__( self, parameters = NoParameters(), attributeModifiers = {} ): ListCapacityWithModifier.__init__( self, attributeModifiers ) - self.__argumentsChecker = ArgumentsChecker( mandatoryParameters, optionalParameters ) + self.__argumentsChecker = parameters def apply( self, cls ): cls._addMethod( "get_" + self.singularName, self.__execute ) @@ -155,9 +155,9 @@ class SeveralElementsRemovable( ListCapacity ): return "* `remove_from_" + self.safeAttributeName + "( " + self.singularName + ", ... )`\n * `" + self.singularName + "`: " + self.typePolicy.documentTypeName() + "\n" class ListGetable( ListCapacityWithModifier ): - def __init__( self, mandatoryParameters, optionalParameters, attributeModifiers = {} ): + def __init__( self, parameters = NoParameters(), attributeModifiers = {} ): ListCapacityWithModifier.__init__( self, attributeModifiers ) - self.__argumentsChecker = ArgumentsChecker( mandatoryParameters, optionalParameters ) + self.__argumentsChecker = parameters def apply( self, cls ): cls._addMethod( "get_" + self.safeAttributeName, self.__execute ) diff --git a/github/GithubObjects/Hook.py b/github/GithubObjects/Hook.py index 07f9660e..36dc1354 100644 --- a/github/GithubObjects/Hook.py +++ b/github/GithubObjects/Hook.py @@ -10,7 +10,7 @@ Hook = GithubObject( "id", "last_response", "_repo", ), - Editable( [ "name", "config" ], [ "events", "add_events", "remove_events", "active" ] ), + Editable( Parameters( [ "name", "config" ], [ "events", "add_events", "remove_events", "active" ] ) ), Deletable(), - SeveralAttributePolicies( [ MethodFromCallable( "test", [], [], __testHook, SimpleTypePolicy( None ) ) ], "Testing" ) + SeveralAttributePolicies( [ MethodFromCallable( "test", Parameters( [], [] ), __testHook, SimpleTypePolicy( None ) ) ], "Testing" ) ) diff --git a/github/GithubObjects/Issue.py b/github/GithubObjects/Issue.py index 92ae7365..13c2f05a 100644 --- a/github/GithubObjects/Issue.py +++ b/github/GithubObjects/Issue.py @@ -18,20 +18,20 @@ Issue = GithubObject( InternalObjectAttribute( "user", NamedUser ), InternalObjectAttribute( "assignee", NamedUser ), InternalObjectAttribute( "milestone", Milestone ), - Editable( [], [ "title", "body", "assignee", "state", "milestone", "labels" ] ), + Editable( Parameters( [], [ "title", "body", "assignee", "state", "milestone", "labels" ] ) ), ExternalListOfObjects( "labels", "label", Label, - ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingReferedRepo ), SeveralElementsAddable(), ListSetable(), ListDeletable(), ElementRemovable(), ), ExternalListOfObjects( "comments", "comment", IssueComment, - ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ), - ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingReferedRepo ), - ElementCreatable( [ "body" ], [], __modifyAttributesForObjectsReferingReferedRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingReferedRepo ), + ElementGetable( Parameters( [ "id" ], [] ), __modifyAttributesForObjectsReferingReferedRepo ), + ElementCreatable( Parameters( [ "body" ], [] ), __modifyAttributesForObjectsReferingReferedRepo ), ), ExternalListOfObjects( "events", "event", IssueEvent, - ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ) + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingReferedRepo ) ), ) diff --git a/github/GithubObjects/IssueComment.py b/github/GithubObjects/IssueComment.py index 43c306a5..fb812b33 100644 --- a/github/GithubObjects/IssueComment.py +++ b/github/GithubObjects/IssueComment.py @@ -8,6 +8,6 @@ IssueComment = GithubObject( "_repo", ), InternalObjectAttribute( "user", NamedUser ), - Editable( [ "body" ], [] ), + Editable( Parameters( [ "body" ], [] ) ), Deletable(), ) diff --git a/github/GithubObjects/Label.py b/github/GithubObjects/Label.py index 4fbb42a1..aec594f9 100644 --- a/github/GithubObjects/Label.py +++ b/github/GithubObjects/Label.py @@ -10,6 +10,6 @@ Label = GithubObject( "url", "name", "color", "_repo", ), - Editable( [ "name", "color" ], [] ), + Editable( Parameters( [ "name", "color" ], [] ) ), Deletable(), ) diff --git a/github/GithubObjects/Milestone.py b/github/GithubObjects/Milestone.py index b1ac5ef4..7cd1bc0d 100644 --- a/github/GithubObjects/Milestone.py +++ b/github/GithubObjects/Milestone.py @@ -12,9 +12,9 @@ Milestone = GithubObject( "_repo", ), InternalObjectAttribute( "creator", NamedUser ), - Editable( [ "title" ], [ "state", "description", "due_on" ] ), + Editable( Parameters( [ "title" ], [ "state", "description", "due_on" ] ) ), Deletable(), ExternalListOfObjects( "labels", "label", Label, - ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ) + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingReferedRepo ) ), ) diff --git a/github/GithubObjects/NamedUser.py b/github/GithubObjects/NamedUser.py index 434f9299..c460d2f2 100644 --- a/github/GithubObjects/NamedUser.py +++ b/github/GithubObjects/NamedUser.py @@ -19,12 +19,12 @@ NamedUser = GithubObject( NamedUser._addAttributePolicy( ExternalListOfObjects( "followers", "follower", NamedUser, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ) ) NamedUser._addAttributePolicy( ExternalListOfObjects( "following", "following", NamedUser, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ) ) diff --git a/github/GithubObjects/NamedUser_complete.py b/github/GithubObjects/NamedUser_complete.py index 4500ac75..92c00b30 100644 --- a/github/GithubObjects/NamedUser_complete.py +++ b/github/GithubObjects/NamedUser_complete.py @@ -1,65 +1,65 @@ -from NamedUser import * - -from Organization import * -from Event import * -from Repository import * -from Gist import * - -NamedUser._addAttributePolicy( - ExternalListOfObjects( "orgs", "org", Organization, - ListGetable( [], [] ) - ) -) - -NamedUser._addAttributePolicy( - ExternalListOfObjects( "events", "event", Event, - ListGetable( [], [] ) - ) -) - -def __getPublicEvents( user ): - return [ - Event( user._github, attributes, lazy = True ) - for attributes - in user._github._dataRequest( "GET", user._baseUrl() + "/events/public", None, None ) - ] - -NamedUser._addAttributePolicy( - MethodFromCallable( "get_public_events", [], [], __getPublicEvents, SimpleTypePolicy( "list of `Event`" ) ) -) - -NamedUser._addAttributePolicy( - ExternalListOfObjects( "received_events", "received_event", Event, - ListGetable( [], [] ) - ) -) - -def __getPublicReceivedEvents( user ): - return [ - Event( user._github, attributes, lazy = True ) - for attributes - in user._github._dataRequest( "GET", user._baseUrl() + "/received_events/public", None, None ) - ] - -NamedUser._addAttributePolicy( - MethodFromCallable( "get_public_received_events", [], [], __getPublicReceivedEvents, SimpleTypePolicy( "list of `Event`" ) ) -) - -NamedUser._addAttributePolicy( - ExternalListOfObjects( "repos", "repo", Repository, - ListGetable( [], [ "type" ] ), - ElementGetable( [ "name" ], [], { "owner" : lambda user: { "login": user.login } } ) - ) -) - -NamedUser._addAttributePolicy( - ExternalListOfObjects( "watched", "watched", Repository, - ListGetable( [], [] ) - ) -) - -NamedUser._addAttributePolicy( - ExternalListOfObjects( "gists", "gist", Gist, - ListGetable( [], [] ), - ) -) +from NamedUser import * + +from Organization import * +from Event import * +from Repository import * +from Gist import * + +NamedUser._addAttributePolicy( + ExternalListOfObjects( "orgs", "org", Organization, + ListGetable( Parameters( [], [] ) ) + ) +) + +NamedUser._addAttributePolicy( + ExternalListOfObjects( "events", "event", Event, + ListGetable( Parameters( [], [] ) ) + ) +) + +def __getPublicEvents( user ): + return [ + Event( user._github, attributes, lazy = True ) + for attributes + in user._github._dataRequest( "GET", user._baseUrl() + "/events/public", None, None ) + ] + +NamedUser._addAttributePolicy( + MethodFromCallable( "get_public_events", Parameters( [], [] ), __getPublicEvents, SimpleTypePolicy( "list of `Event`" ) ) +) + +NamedUser._addAttributePolicy( + ExternalListOfObjects( "received_events", "received_event", Event, + ListGetable( Parameters( [], [] ) ) + ) +) + +def __getPublicReceivedEvents( user ): + return [ + Event( user._github, attributes, lazy = True ) + for attributes + in user._github._dataRequest( "GET", user._baseUrl() + "/received_events/public", None, None ) + ] + +NamedUser._addAttributePolicy( + MethodFromCallable( "get_public_received_events", Parameters( [], [] ), __getPublicReceivedEvents, SimpleTypePolicy( "list of `Event`" ) ) +) + +NamedUser._addAttributePolicy( + ExternalListOfObjects( "repos", "repo", Repository, + ListGetable( Parameters( [], [ "type" ] ) ), + ElementGetable( Parameters( [ "name" ], [] ), { "owner" : lambda user: { "login": user.login } } ) + ) +) + +NamedUser._addAttributePolicy( + ExternalListOfObjects( "watched", "watched", Repository, + ListGetable( Parameters( [], [] ) ) + ) +) + +NamedUser._addAttributePolicy( + ExternalListOfObjects( "gists", "gist", Gist, + ListGetable( Parameters( [], [] ) ), + ) +) diff --git a/github/GithubObjects/Organization.py b/github/GithubObjects/Organization.py index 7a63f2ac..3fb7adc1 100644 --- a/github/GithubObjects/Organization.py +++ b/github/GithubObjects/Organization.py @@ -12,15 +12,15 @@ Organization = GithubObject( "disk_usage", "collaborators", "billing_email", "plan", "private_gists", "total_private_repos", "owned_private_repos", ), - Editable( [], [ "billing_email", "blog", "company", "email", "location", "name" ] ), + Editable( Parameters( [], [ "billing_email", "blog", "company", "email", "location", "name" ] ) ), ExternalListOfObjects( "public_members", "public_member", NamedUser, - ListGetable( [], [] ), + ListGetable( Parameters( [], [] ) ), ElementAddable(), ElementRemovable(), ElementHasable() ), ExternalListOfObjects( "members", "member", NamedUser, - ListGetable( [], [] ), + ListGetable( Parameters( [], [] ) ), ElementRemovable(), ElementHasable() ), diff --git a/github/GithubObjects/Organization_complete.py b/github/GithubObjects/Organization_complete.py index 98178096..dd1096ae 100644 --- a/github/GithubObjects/Organization_complete.py +++ b/github/GithubObjects/Organization_complete.py @@ -1,34 +1,34 @@ -from Organization import * - -from Repository import * -from Team import * -from Event import * - -Organization._addAttributePolicy( - ExternalListOfObjects( "repos", "repo", Repository, - ListGetable( [], [ "type" ] ), - ElementGetable( [ "name" ], [], { "owner" : lambda user: { "login": user.login } } ), - ElementCreatable( [ "name" ], [ "description", "homepage", "private", "has_issues", "has_wiki", "has_downloads", "team_id", ] ) - ) -) - -def __createForkForOrg( org, repo ): - assert isinstance( repo, Repository ) - return Repository( org._github, org._github._dataRequest( "POST", repo._baseUrl() + "/forks", { "org": org.login }, None ), lazy = True ) - -Organization._addAttributePolicy( - SeveralAttributePolicies( [ MethodFromCallable( "create_fork", [ "repo" ], [], __createForkForOrg, ObjectTypePolicy( Repository ) ) ], "Forking" ) -) - -Organization._addAttributePolicy( - ExternalListOfObjects( "teams", "team", Team, - ListGetable( [], [] ), - ElementCreatable( [ "name" ], [ "repo_names", "permission" ] ) - ) -) - -Organization._addAttributePolicy( - ExternalListOfObjects( "events", "event", Event, - ListGetable( [], [] ) - ), -) +from Organization import * + +from Repository import * +from Team import * +from Event import * + +Organization._addAttributePolicy( + ExternalListOfObjects( "repos", "repo", Repository, + ListGetable( Parameters( [], [ "type" ] ) ), + ElementGetable( Parameters( [ "name" ], [] ), { "owner" : lambda user: { "login": user.login } } ), + ElementCreatable( Parameters( [ "name" ], [ "description", "homepage", "private", "has_issues", "has_wiki", "has_downloads", "team_id", ] ) ) + ) +) + +def __createForkForOrg( org, repo ): + assert isinstance( repo, Repository ) + return Repository( org._github, org._github._dataRequest( "POST", repo._baseUrl() + "/forks", { "org": org.login }, None ), lazy = True ) + +Organization._addAttributePolicy( + SeveralAttributePolicies( [ MethodFromCallable( "create_fork", Parameters( [ "repo" ], [] ), __createForkForOrg, ObjectTypePolicy( Repository ) ) ], "Forking" ) +) + +Organization._addAttributePolicy( + ExternalListOfObjects( "teams", "team", Team, + ListGetable( Parameters( [], [] ) ), + ElementCreatable( Parameters( [ "name" ], [ "repo_names", "permission" ] ) ) + ) +) + +Organization._addAttributePolicy( + ExternalListOfObjects( "events", "event", Event, + ListGetable( Parameters( [], [] ) ) + ), +) diff --git a/github/GithubObjects/PullRequest.py b/github/GithubObjects/PullRequest.py index 3357e72d..5ee414d5 100644 --- a/github/GithubObjects/PullRequest.py +++ b/github/GithubObjects/PullRequest.py @@ -23,18 +23,18 @@ PullRequest = GithubObject( "_repo", ), InternalObjectAttribute( "user", NamedUser ), - Editable( [], [ "title", "body", "state" ] ), + Editable( Parameters( [], [ "title", "body", "state" ] ) ), ExternalListOfObjects( "commits", "commit", Commit, - ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingReferedRepo ), ), ExternalListOfObjects( "files", "file", PullRequestFile, - ListGetable( [], [] ), + ListGetable( Parameters( [], [] ) ), ), ExternalListOfObjects( "comments", "comment", PullRequestComment, - ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ), - ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingReferedRepo ), - ElementCreatable( [ "body", "commit_id", "path", "position" ], [], __modifyAttributesForObjectsReferingReferedRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingReferedRepo ), + ElementGetable( Parameters( [ "id" ], [] ), __modifyAttributesForObjectsReferingReferedRepo ), + ElementCreatable( Alternative( Parameters( [ "body", "commit_id", "path", "position" ], [] ), Parameters( [ "body", "in_reply_to" ], [] ) ), __modifyAttributesForObjectsReferingReferedRepo ), ), - MethodFromCallable( "is_merged", [], [], __pullRequestIsMerged, SimpleTypePolicy( "bool" ) ), - MethodFromCallable( "merge", [], [ "commit_message" ], __mergePullRequest, SimpleTypePolicy( None ) ), + MethodFromCallable( "is_merged", Parameters( [], [] ), __pullRequestIsMerged, SimpleTypePolicy( "bool" ) ), + MethodFromCallable( "merge", Parameters( [], [ "commit_message" ] ), __mergePullRequest, SimpleTypePolicy( None ) ), ) diff --git a/github/GithubObjects/PullRequestComment.py b/github/GithubObjects/PullRequestComment.py index 14d7ac6c..ac3cb0d3 100644 --- a/github/GithubObjects/PullRequestComment.py +++ b/github/GithubObjects/PullRequestComment.py @@ -9,6 +9,6 @@ PullRequestComment = GithubObject( "_repo", ), InternalObjectAttribute( "user", NamedUser ), - Editable( [ "body" ], [] ), + Editable( Parameters( [ "body" ], [] ) ), Deletable(), ) diff --git a/github/GithubObjects/Repository.py b/github/GithubObjects/Repository.py index b1c8400d..253cb901 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -19,6 +19,9 @@ from PullRequest import * __modifyAttributesForObjectsReferingRepo = { "_repo": lambda repo: repo } +def __compare( repo, base, head ): + return repo._github._dataRequest( "GET", repo._baseUrl() + "/compare/" + base + "..." + head, None, None ) + Repository = GithubObject( "Repository", BaseUrl( lambda obj: "/repos/" + obj.owner.login + "/" + obj.name ), @@ -38,102 +41,103 @@ Repository._addAttributePolicy( InternalObjectAttribute( "parent", Repository ) Repository._addAttributePolicy( InternalObjectAttribute( "source", Repository ) ) Repository._addAttributePolicy( ExternalListOfObjects( "issues/events", "issues_event", IssueEvent, - ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ), - ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementGetable( Parameters( [ "id" ], [] ), __modifyAttributesForObjectsReferingRepo ), ) ) Repository._addAttributePolicy( ExternalListOfObjects( "forks", "fork", Repository, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ) ) Repository._addAttributePolicy( - Editable( [ "name" ], [ "description", "homepage", "public", "has_issues", "has_wiki", "has_downloads" ] ) + Editable( Parameters( [ "name" ], [ "description", "homepage", "public", "has_issues", "has_wiki", "has_downloads" ] ) ) ) Repository._addAttributePolicy( SeveralAttributePolicies( [ ExternalSimpleAttribute( "languages", "dictionary of strings to integers" ) ], "Languages" ) ) Repository._addAttributePolicy( SeveralAttributePolicies( [ ExternalListOfObjects( "hooks", "hook", Hook, - ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ), - ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [ "name", "config" ], [ "events", "active" ], __modifyAttributesForObjectsReferingRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementGetable( Parameters( [ "id" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Parameters( [ "name", "config" ], [ "events", "active" ] ), __modifyAttributesForObjectsReferingRepo ), ), ExternalListOfObjects( "keys", "key", RepositoryKey, - ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ), - ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [ "title", "key" ], [], __modifyAttributesForObjectsReferingRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementGetable( Parameters( [ "id" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Parameters( [ "title", "key" ], [] ), __modifyAttributesForObjectsReferingRepo ), ), ExternalListOfObjects( "collaborators", "collaborator", NamedUser, - ListGetable( [], [] ), + ListGetable( Parameters( [], [] ) ), ElementAddable(), ElementRemovable(), ElementHasable() ), ExternalListOfObjects( "contributors", "contributor", NamedUser, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ), ExternalListOfObjects( "watchers", "watcher", NamedUser, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ), ExternalListOfObjects( "git/refs", "git_ref", GitRef, - ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ), - ElementGetable( [ "ref" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [ "ref", "sha" ], [], __modifyAttributesForObjectsReferingRepo ) + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementGetable( Parameters( [ "ref" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Parameters( [ "ref", "sha" ], [] ), __modifyAttributesForObjectsReferingRepo ) ), ExternalListOfObjects( "git/commits", "git_commit", GitCommit, - ElementGetable( [ "sha" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [ "message", "tree", "parents" ], [ "author", "committer" ], __modifyAttributesForObjectsReferingRepo ) + ElementGetable( Parameters( [ "sha" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Parameters( [ "message", "tree", "parents" ], [ "author", "committer" ] ), __modifyAttributesForObjectsReferingRepo ) ), ExternalListOfObjects( "git/trees", "git_tree", GitTree, - ElementGetable( [ "sha" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [ "tree" ], [], __modifyAttributesForObjectsReferingRepo ) + ElementGetable( Parameters( [ "sha" ], [ "recursive" ] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Parameters( [ "tree" ], [ "base_tree" ] ), __modifyAttributesForObjectsReferingRepo ) ), ExternalListOfObjects( "git/blobs", "git_blob", GitBlob, - ElementGetable( [ "sha" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [ "content", "encoding" ], [], __modifyAttributesForObjectsReferingRepo ) + ElementGetable( Parameters( [ "sha" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Parameters( [ "content", "encoding" ], [] ), __modifyAttributesForObjectsReferingRepo ) ), ExternalListOfObjects( "git/tags", "git_tag", GitTag, - ElementGetable( [ "sha" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [ "tag", "message", "object", "type" ], [ "tagger" ], __modifyAttributesForObjectsReferingRepo ) + ElementGetable( Parameters( [ "sha" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Parameters( [ "tag", "message", "object", "type" ], [ "tagger" ] ), __modifyAttributesForObjectsReferingRepo ) ), ExternalListOfObjects( "labels", "label", Label, - ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ), - ElementGetable( [ "name" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [ "name", "color" ], [], __modifyAttributesForObjectsReferingRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementGetable( Parameters( [ "name" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Parameters( [ "name", "color" ], [] ), __modifyAttributesForObjectsReferingRepo ), ), ExternalListOfObjects( "milestones", "milestone", Milestone, - ListGetable( [], [ "state", "sort", "direction" ], __modifyAttributesForObjectsReferingRepo ), - ElementGetable( [ "number" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [ "title" ], [ "state", "description", "due_on" ], __modifyAttributesForObjectsReferingRepo ) + ListGetable( Parameters( [], [ "state", "sort", "direction" ] ), __modifyAttributesForObjectsReferingRepo ), + ElementGetable( Parameters( [ "number" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Parameters( [ "title" ], [ "state", "description", "due_on" ] ), __modifyAttributesForObjectsReferingRepo ) ), ExternalListOfObjects( "issues", "issue", Issue, - ListGetable( [], [ "milestone", "state", "assignee", "mentioned", "labels", "sort", "direction", "since" ], __modifyAttributesForObjectsReferingRepo ), - ElementGetable( [ "number" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [ "title" ], [ "body", "assignee", "milestone", "labels", ], __modifyAttributesForObjectsReferingRepo ) + ListGetable( Parameters( [], [ "milestone", "state", "assignee", "mentioned", "labels", "sort", "direction", "since" ] ), __modifyAttributesForObjectsReferingRepo ), + ElementGetable( Parameters( [ "number" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Parameters( [ "title" ], [ "body", "assignee", "milestone", "labels", ] ), __modifyAttributesForObjectsReferingRepo ) ), ExternalListOfObjects( "downloads", "download", Download, - ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ), - ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [ "name", "size" ], [ "description", "content_type" ], __modifyAttributesForObjectsReferingRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementGetable( Parameters( [ "id" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Parameters( [ "name", "size" ], [ "description", "content_type" ] ), __modifyAttributesForObjectsReferingRepo ), ), ExternalListOfObjects( "comments", "comment", CommitComment, - ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ), - ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementGetable( Parameters( [ "id" ], [] ), __modifyAttributesForObjectsReferingRepo ), ), ExternalListOfObjects( "commits", "commit", Commit, - ListGetable( [], [ "sha", "path" ], __modifyAttributesForObjectsReferingRepo ), - ElementGetable( [ "sha" ], [], __modifyAttributesForObjectsReferingRepo ), + ListGetable( Parameters( [], [ "sha", "path" ] ), __modifyAttributesForObjectsReferingRepo ), + ElementGetable( Parameters( [ "sha" ], [] ), __modifyAttributesForObjectsReferingRepo ), ), ExternalListOfObjects( "tags", "tag", Tag, - ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingRepo ), ), ExternalListOfObjects( "branches", "branch", Branch, - ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ), + ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingRepo ), ), ExternalListOfObjects( "pulls", "pull", PullRequest, - ListGetable( [], [ "state" ], __modifyAttributesForObjectsReferingRepo ), - ElementGetable( [ "number" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [ "title", "body", "base", "head" ], [], __modifyAttributesForObjectsReferingRepo ), + ListGetable( Parameters( [], [ "state" ] ), __modifyAttributesForObjectsReferingRepo ), + ElementGetable( Parameters( [ "number" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Alternative( Parameters( [ "title", "body", "base", "head" ], [] ), Parameters( [ "issue", "base", "head" ], [] ) ), __modifyAttributesForObjectsReferingRepo ), ), + MethodFromCallable( "compare", Parameters( [ "base", "head" ], [] ), __compare, SimpleTypePolicy( None ) ), ] ) ) diff --git a/github/GithubObjects/RepositoryKey.py b/github/GithubObjects/RepositoryKey.py index 8f2c7548..cea71c01 100644 --- a/github/GithubObjects/RepositoryKey.py +++ b/github/GithubObjects/RepositoryKey.py @@ -7,6 +7,6 @@ RepositoryKey = GithubObject( "url", "id", "title", "key", "_repo", ), - Editable( [ "title", "key" ], [] ), + Editable( Parameters( [ "title", "key" ], [] ) ), Deletable() ) diff --git a/github/GithubObjects/Repository_complete.py b/github/GithubObjects/Repository_complete.py index fb7d4e95..4a9ae6f5 100644 --- a/github/GithubObjects/Repository_complete.py +++ b/github/GithubObjects/Repository_complete.py @@ -1,27 +1,27 @@ -from Repository import * - -from Team import * -from Event import * - -Repository._addAttributePolicy( - ExternalListOfObjects( "teams", "team", Team, - ListGetable( [], [] ) - ) -) - -Repository._addAttributePolicy( - ExternalListOfObjects( "events", "event", Event, - ListGetable( [], [] ) - ), -) - -def __getNetworkEvents( repo ): - return [ - Event( repo._github, attributes, lazy = True ) - for attributes - in repo._github._dataRequest( "GET", "/networks/" + repo.owner.login + "/" + repo.name + "/events", None, None ) - ] - -Repository._addAttributePolicy( - MethodFromCallable( "get_network_events", [], [], __getNetworkEvents, SimpleTypePolicy( "list of `Event`" ) ) -) +from Repository import * + +from Team import * +from Event import * + +Repository._addAttributePolicy( + ExternalListOfObjects( "teams", "team", Team, + ListGetable( Parameters( [], [] ) ) + ) +) + +Repository._addAttributePolicy( + ExternalListOfObjects( "events", "event", Event, + ListGetable( Parameters( [], [] ) ) + ), +) + +def __getNetworkEvents( repo ): + return [ + Event( repo._github, attributes, lazy = True ) + for attributes + in repo._github._dataRequest( "GET", "/networks/" + repo.owner.login + "/" + repo.name + "/events", None, None ) + ] + +Repository._addAttributePolicy( + MethodFromCallable( "get_network_events", Parameters( [], [] ), __getNetworkEvents, SimpleTypePolicy( "list of `Event`" ) ) +) diff --git a/github/GithubObjects/Team.py b/github/GithubObjects/Team.py index 4bd62e66..fcd84420 100644 --- a/github/GithubObjects/Team.py +++ b/github/GithubObjects/Team.py @@ -8,16 +8,16 @@ Team = GithubObject( InternalSimpleAttributes( "url", "name", "id", "permission", "members_count", "repos_count", ), - Editable( [ "name" ], [ "permission" ] ), + Editable( Parameters( [ "name" ], [ "permission" ] ) ), Deletable(), ExternalListOfObjects( "members", "member", NamedUser, - ListGetable( [], [] ), + ListGetable( Parameters( [], [] ) ), ElementAddable(), ElementRemovable(), ElementHasable() ), ExternalListOfObjects( "repos", "repo", Repository, - ListGetable( [], [] ), + ListGetable( Parameters( [], [] ) ), ElementAddable(), ElementRemovable(), ElementHasable() diff --git a/github/GithubObjects/UserKey.py b/github/GithubObjects/UserKey.py index 6be23ea7..ba912f6a 100644 --- a/github/GithubObjects/UserKey.py +++ b/github/GithubObjects/UserKey.py @@ -6,6 +6,6 @@ UserKey = GithubObject( InternalSimpleAttributes( "url", "id", "title", "key", ), - Editable( [], [ "title", "key" ] ), + Editable( Parameters( [], [ "title", "key" ] ) ), Deletable(), )