From d24cf209ddd1758188c5f35344f76df818d09a46 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Fri, 16 Mar 2012 07:53:33 +0100 Subject: [PATCH 1/7] Be explicit about argumentChecker object --- github/GithubObjects/AuthenticatedUser.py | 42 ++++----- github/GithubObjects/Authorization.py | 2 +- github/GithubObjects/Commit.py | 4 +- github/GithubObjects/CommitComment.py | 2 +- github/GithubObjects/Gist.py | 16 ++-- github/GithubObjects/GistComment.py | 2 +- github/GithubObjects/GitRef.py | 2 +- .../GithubObject/ArgumentsChecker.py | 5 +- github/GithubObjects/GithubObject/Basic.py | 6 +- .../GithubObject/GithubObject.py | 8 +- github/GithubObjects/GithubObject/List.py | 12 +-- github/GithubObjects/Hook.py | 4 +- github/GithubObjects/Issue.py | 12 +-- github/GithubObjects/IssueComment.py | 2 +- github/GithubObjects/Label.py | 2 +- github/GithubObjects/Milestone.py | 4 +- github/GithubObjects/NamedUser.py | 4 +- github/GithubObjects/NamedUser_complete.py | 18 ++-- github/GithubObjects/Organization.py | 6 +- github/GithubObjects/Organization_complete.py | 14 +-- github/GithubObjects/PullRequest.py | 16 ++-- github/GithubObjects/PullRequestComment.py | 2 +- github/GithubObjects/Repository.py | 90 +++++++++---------- github/GithubObjects/RepositoryKey.py | 2 +- github/GithubObjects/Repository_complete.py | 6 +- github/GithubObjects/Team.py | 6 +- github/GithubObjects/UserKey.py | 2 +- 27 files changed, 146 insertions(+), 145 deletions(-) diff --git a/github/GithubObjects/AuthenticatedUser.py b/github/GithubObjects/AuthenticatedUser.py index 2a48a033..349d8037 100644 --- a/github/GithubObjects/AuthenticatedUser.py +++ b/github/GithubObjects/AuthenticatedUser.py @@ -34,56 +34,56 @@ 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`" ) ), ) 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/GithubObject/ArgumentsChecker.py b/github/GithubObjects/GithubObject/ArgumentsChecker.py index 8b08e1c2..d96a2931 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,6 @@ class ArgumentsChecker: return " " + mandatory + " " else: return " " + mandatory + ", " + optional + " " + +def NoParameters(): + return Parameters( [], [] ) 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..e00c3d27 100644 --- a/github/GithubObjects/NamedUser_complete.py +++ b/github/GithubObjects/NamedUser_complete.py @@ -7,13 +7,13 @@ from Gist import * NamedUser._addAttributePolicy( ExternalListOfObjects( "orgs", "org", Organization, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ) ) NamedUser._addAttributePolicy( ExternalListOfObjects( "events", "event", Event, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ) ) @@ -25,12 +25,12 @@ def __getPublicEvents( user ): ] NamedUser._addAttributePolicy( - MethodFromCallable( "get_public_events", [], [], __getPublicEvents, SimpleTypePolicy( "list of `Event`" ) ) + MethodFromCallable( "get_public_events", Parameters( [], [] ), __getPublicEvents, SimpleTypePolicy( "list of `Event`" ) ) ) NamedUser._addAttributePolicy( ExternalListOfObjects( "received_events", "received_event", Event, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ) ) @@ -42,24 +42,24 @@ def __getPublicReceivedEvents( user ): ] NamedUser._addAttributePolicy( - MethodFromCallable( "get_public_received_events", [], [], __getPublicReceivedEvents, SimpleTypePolicy( "list of `Event`" ) ) + MethodFromCallable( "get_public_received_events", Parameters( [], [] ), __getPublicReceivedEvents, SimpleTypePolicy( "list of `Event`" ) ) ) NamedUser._addAttributePolicy( ExternalListOfObjects( "repos", "repo", Repository, - ListGetable( [], [ "type" ] ), - ElementGetable( [ "name" ], [], { "owner" : lambda user: { "login": user.login } } ) + ListGetable( Parameters( [], [ "type" ] ) ), + ElementGetable( Parameters( [ "name" ], [] ), { "owner" : lambda user: { "login": user.login } } ) ) ) NamedUser._addAttributePolicy( ExternalListOfObjects( "watched", "watched", Repository, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ) ) NamedUser._addAttributePolicy( ExternalListOfObjects( "gists", "gist", Gist, - ListGetable( [], [] ), + 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..803905e0 100644 --- a/github/GithubObjects/Organization_complete.py +++ b/github/GithubObjects/Organization_complete.py @@ -6,9 +6,9 @@ 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", ] ) + 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", ] ) ) ) ) @@ -17,18 +17,18 @@ def __createForkForOrg( org, repo ): 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" ) + SeveralAttributePolicies( [ MethodFromCallable( "create_fork", Parameters( [ "repo" ], [] ), __createForkForOrg, ObjectTypePolicy( Repository ) ) ], "Forking" ) ) Organization._addAttributePolicy( ExternalListOfObjects( "teams", "team", Team, - ListGetable( [], [] ), - ElementCreatable( [ "name" ], [ "repo_names", "permission" ] ) + ListGetable( Parameters( [], [] ) ), + ElementCreatable( Parameters( [ "name" ], [ "repo_names", "permission" ] ) ) ) ) Organization._addAttributePolicy( ExternalListOfObjects( "events", "event", Event, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ), ) diff --git a/github/GithubObjects/PullRequest.py b/github/GithubObjects/PullRequest.py index 3357e72d..6aaf0c4f 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( Parameters( [ "body", "commit_id", "path", "position" ], [] ), __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..c981163c 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -38,102 +38,102 @@ 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" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Parameters( [ "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( Parameters( [ "title", "body", "base", "head" ], [] ), __modifyAttributesForObjectsReferingRepo ), ), ] ) ) 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..bfae3218 100644 --- a/github/GithubObjects/Repository_complete.py +++ b/github/GithubObjects/Repository_complete.py @@ -5,13 +5,13 @@ from Event import * Repository._addAttributePolicy( ExternalListOfObjects( "teams", "team", Team, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ) ) Repository._addAttributePolicy( ExternalListOfObjects( "events", "event", Event, - ListGetable( [], [] ) + ListGetable( Parameters( [], [] ) ) ), ) @@ -23,5 +23,5 @@ def __getNetworkEvents( repo ): ] Repository._addAttributePolicy( - MethodFromCallable( "get_network_events", [], [], __getNetworkEvents, SimpleTypePolicy( "list of `Event`" ) ) + 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(), ) From a85de99ea5b5e7b38bd68e076d09c49207b8687e Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Fri, 16 Mar 2012 07:54:19 +0100 Subject: [PATCH 2/7] dos2unix --- github/GithubObjects/NamedUser_complete.py | 130 +++++++++--------- github/GithubObjects/Organization_complete.py | 68 ++++----- github/GithubObjects/Repository_complete.py | 54 ++++---- 3 files changed, 126 insertions(+), 126 deletions(-) diff --git a/github/GithubObjects/NamedUser_complete.py b/github/GithubObjects/NamedUser_complete.py index e00c3d27..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( 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( [], [] ) ), - ) -) +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_complete.py b/github/GithubObjects/Organization_complete.py index 803905e0..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( 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( [], [] ) ) - ), -) +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/Repository_complete.py b/github/GithubObjects/Repository_complete.py index bfae3218..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( 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`" ) ) -) +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`" ) ) +) From a475d685d8ae709095d09094ea0962ac182d33f0 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Fri, 16 Mar 2012 08:11:07 +0100 Subject: [PATCH 3/7] On the way to alternative inputs. Still needs unit and integration testing --- ReferenceOfApis.md | 4 ++-- ReferenceOfClasses.md | 4 ++-- .../GithubObject/ArgumentsChecker.py | 18 ++++++++++++++++++ github/GithubObjects/PullRequest.py | 2 +- github/GithubObjects/Repository.py | 2 +- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index 8230f5fd..8fab4012 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -321,7 +321,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 +331,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..695b67b1 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -703,7 +703,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] )` @@ -901,7 +901,7 @@ 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` Teams ----- diff --git a/github/GithubObjects/GithubObject/ArgumentsChecker.py b/github/GithubObjects/GithubObject/ArgumentsChecker.py index d96a2931..b2c5b054 100644 --- a/github/GithubObjects/GithubObject/ArgumentsChecker.py +++ b/github/GithubObjects/GithubObject/ArgumentsChecker.py @@ -37,3 +37,21 @@ class Parameters: 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/PullRequest.py b/github/GithubObjects/PullRequest.py index 6aaf0c4f..5ee414d5 100644 --- a/github/GithubObjects/PullRequest.py +++ b/github/GithubObjects/PullRequest.py @@ -33,7 +33,7 @@ PullRequest = GithubObject( ExternalListOfObjects( "comments", "comment", PullRequestComment, ListGetable( Parameters( [], [] ), __modifyAttributesForObjectsReferingReferedRepo ), ElementGetable( Parameters( [ "id" ], [] ), __modifyAttributesForObjectsReferingReferedRepo ), - ElementCreatable( Parameters( [ "body", "commit_id", "path", "position" ], [] ), __modifyAttributesForObjectsReferingReferedRepo ), + ElementCreatable( Alternative( Parameters( [ "body", "commit_id", "path", "position" ], [] ), Parameters( [ "body", "in_reply_to" ], [] ) ), __modifyAttributesForObjectsReferingReferedRepo ), ), MethodFromCallable( "is_merged", Parameters( [], [] ), __pullRequestIsMerged, SimpleTypePolicy( "bool" ) ), MethodFromCallable( "merge", Parameters( [], [ "commit_message" ] ), __mergePullRequest, SimpleTypePolicy( None ) ), diff --git a/github/GithubObjects/Repository.py b/github/GithubObjects/Repository.py index c981163c..8b8675fa 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -134,6 +134,6 @@ Repository._addAttributePolicy( SeveralAttributePolicies( [ ExternalListOfObjects( "pulls", "pull", PullRequest, ListGetable( Parameters( [], [ "state" ] ), __modifyAttributesForObjectsReferingRepo ), ElementGetable( Parameters( [ "number" ], [] ), __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( Parameters( [ "title", "body", "base", "head" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( Alternative( Parameters( [ "title", "body", "base", "head" ], [] ), Parameters( [ "issue", "base", "head" ], [] ) ), __modifyAttributesForObjectsReferingRepo ), ), ] ) ) From 6af2bfd0d46bc0eeb8c37b85c7b3003e0e4ae297 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sat, 17 Mar 2012 07:42:54 +0100 Subject: [PATCH 4/7] Optional parameter for Repository.create_git_tree --- ReferenceOfApis.md | 4 ---- github/GithubObjects/Repository.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index 8fab4012..b4e8bf49 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -206,10 +206,6 @@ 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` diff --git a/github/GithubObjects/Repository.py b/github/GithubObjects/Repository.py index 8b8675fa..05579294 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -87,7 +87,7 @@ Repository._addAttributePolicy( SeveralAttributePolicies( [ ), ExternalListOfObjects( "git/trees", "git_tree", GitTree, ElementGetable( Parameters( [ "sha" ], [] ), __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( Parameters( [ "tree" ], [] ), __modifyAttributesForObjectsReferingRepo ) + ElementCreatable( Parameters( [ "tree" ], [ "base_tree" ] ), __modifyAttributesForObjectsReferingRepo ) ), ExternalListOfObjects( "git/blobs", "git_blob", GitBlob, ElementGetable( Parameters( [ "sha" ], [] ), __modifyAttributesForObjectsReferingRepo ), From 1d2b27824d20612066d84be42d6691c66bb18ef4 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Mon, 19 Mar 2012 07:32:34 +0100 Subject: [PATCH 5/7] Repository.get_git_tree with 'recursive' --- ReferenceOfApis.md | 4 ---- ReferenceOfClasses.md | 5 +++-- github/GithubObjects/GitTree.py | 4 ++-- github/GithubObjects/Repository.py | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index b4e8bf49..04372696 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -210,10 +210,6 @@ 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` diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index 695b67b1..fc85d0ed 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -363,6 +363,7 @@ Attributes * `sha` * `url` * `tree` +* `recursive` Class `Hook` ============ @@ -842,8 +843,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 --------- 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/Repository.py b/github/GithubObjects/Repository.py index 05579294..3024075e 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -86,7 +86,7 @@ Repository._addAttributePolicy( SeveralAttributePolicies( [ ElementCreatable( Parameters( [ "message", "tree", "parents" ], [ "author", "committer" ] ), __modifyAttributesForObjectsReferingRepo ) ), ExternalListOfObjects( "git/trees", "git_tree", GitTree, - ElementGetable( Parameters( [ "sha" ], [] ), __modifyAttributesForObjectsReferingRepo ), + ElementGetable( Parameters( [ "sha" ], [ "recursive" ] ), __modifyAttributesForObjectsReferingRepo ), ElementCreatable( Parameters( [ "tree" ], [ "base_tree" ] ), __modifyAttributesForObjectsReferingRepo ) ), ExternalListOfObjects( "git/blobs", "git_blob", GitBlob, From bd39726f7cf86ea7ffb33b5718241fdab5fc8f53 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Mon, 19 Mar 2012 07:40:52 +0100 Subject: [PATCH 6/7] AuthenticatedUser.get_issues --- ReferenceOfApis.md | 2 +- ReferenceOfClasses.md | 4 ++++ github/GithubObjects/AuthenticatedUser.py | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index 04372696..729a6453 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` ================================== diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index fc85d0ed..99d6b9a7 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` ===================== diff --git a/github/GithubObjects/AuthenticatedUser.py b/github/GithubObjects/AuthenticatedUser.py index 349d8037..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 [ @@ -86,4 +87,8 @@ AuthenticatedUser = GithubObject( url = "/gists", ), MethodFromCallable( "get_starred_gists", Parameters( [], [] ), __getStaredGists, SimpleTypePolicy( "list of `Gist`" ) ), + ExternalListOfObjects( "issues", "issue", Issue, + ListGetable( Parameters( [], [] ) ), + url = "/issues", + ), ) From 1095d304b7fab3818dcb4c42093c8c56d3ac05e4 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Mon, 19 Mar 2012 17:28:03 +0100 Subject: [PATCH 7/7] Repository.compare --- ReferenceOfApis.md | 2 +- ReferenceOfClasses.md | 1 + github/GithubObjects/Repository.py | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index 729a6453..ad6cdfc7 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -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` ===================================== diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index 99d6b9a7..22a7fdb3 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -907,6 +907,7 @@ Pulls * `get_pulls( [state] )`: list of `PullRequest` * `get_pull( number )`: `PullRequest` * `create_pull( < title, body, base, head > or < issue, base, head > )`: `PullRequest` +* `compare( base, head )` Teams ----- diff --git a/github/GithubObjects/Repository.py b/github/GithubObjects/Repository.py index 3024075e..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 ), @@ -136,4 +139,5 @@ Repository._addAttributePolicy( SeveralAttributePolicies( [ ElementGetable( Parameters( [ "number" ], [] ), __modifyAttributesForObjectsReferingRepo ), ElementCreatable( Alternative( Parameters( [ "title", "body", "base", "head" ], [] ), Parameters( [ "issue", "base", "head" ], [] ) ), __modifyAttributesForObjectsReferingRepo ), ), + MethodFromCallable( "compare", Parameters( [ "base", "head" ], [] ), __compare, SimpleTypePolicy( None ) ), ] ) )