diff --git a/github/GithubObject.UnitTest.py b/github/GithubObject.UnitTest.py index 29cb6006..a1759d37 100644 --- a/github/GithubObject.UnitTest.py +++ b/github/GithubObject.UnitTest.py @@ -205,7 +205,7 @@ class GithubObjectWithListGetableList( TestCaseWithGithubTestObject ): "GithubTestObject", BaseUrl( lambda obj: "/test" ), BasicAttributes( "a1", "a2" ), - ListOfObjects( "a3s", ContainedObject, ListGetable( [], [ "type" ] ) ) + ListAttribute( "a3s", ContainedObject, ListGetable( [], [ "type" ] ) ) ) def testGetList( self ): @@ -233,7 +233,7 @@ class GithubObjectWithElementAddableList( TestCaseWithGithubTestObject ): "GithubTestObject", BaseUrl( lambda obj: "/test" ), BasicAttributes( "a1", "a2" ), - ListOfObjects( "a3s", ContainedObject, ElementAddable() ) + ListAttribute( "a3s", ContainedObject, ElementAddable() ) ) def testAddToList( self ): @@ -253,7 +253,7 @@ class GithubObjectWithElementRemovableList( TestCaseWithGithubTestObject ): "GithubTestObject", BaseUrl( lambda obj: "/test" ), BasicAttributes( "a1", "a2" ), - ListOfObjects( "a3s", ContainedObject, ElementRemovable() ) + ListAttribute( "a3s", ContainedObject, ElementRemovable() ) ) def testRemoveFromList( self ): @@ -273,7 +273,7 @@ class GithubObjectWithElementHasableList( TestCaseWithGithubTestObject ): "GithubTestObject", BaseUrl( lambda obj: "/test" ), BasicAttributes( "a1", "a2" ), - ListOfObjects( "a3s", ContainedObject, ElementHasable() ) + ListAttribute( "a3s", ContainedObject, ElementHasable() ) ) def testHasInList( self ): @@ -295,7 +295,7 @@ class GithubObjectWithElementCreatableList( TestCaseWithGithubTestObject ): "GithubTestObject", BaseUrl( lambda obj: "/test" ), BasicAttributes( "a1", "a2" ), - ListOfObjects( "a3s", ContainedObject, ElementCreatable( "a3", [ "name" ], [ "p1", "p2" ] ) ) + ListAttribute( "a3s", ContainedObject, ElementCreatable( "a3", [ "name" ], [ "p1", "p2" ] ) ) ) def testCreate( self ): @@ -333,7 +333,7 @@ class GithubObjectWithElementGetableList( TestCaseWithGithubTestObject ): "GithubTestObject", BaseUrl( lambda obj: "/test" ), BasicAttributes( "a1", "a2" ), - ListOfObjects( "a3s", ContainedObject, ElementGetable( "a3", lambda obj, id: { "id": id } ) ) + ListAttribute( "a3s", ContainedObject, ElementGetable( "a3", lambda obj, id: { "id": id } ) ) ) def testGetList( self ): diff --git a/github/GithubObject.py b/github/GithubObject.py index e6a252f5..06017d71 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -2,7 +2,7 @@ import itertools import ObjectCapacities.ArgumentsChecker as ArgumentsChecker from ObjectCapacities.Basic import AttributeFromCallable, MethodFromCallable -from ObjectCapacities.List import ListOfObjects, ListGetable, ElementCreatable, ElementGetable, ElementAddable, ElementRemovable, ElementHasable +from ObjectCapacities.List import ListAttribute, ListGetable, ElementCreatable, ElementGetable, ElementAddable, ElementRemovable, ElementHasable class BadGithubObjectException( Exception ): pass diff --git a/github/GithubObjects.py b/github/GithubObjects.py index ae9b2df3..08e21677 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -31,11 +31,11 @@ NamedUser = GithubObject( ), ) -AuthenticatedUser._addAttributePolicy( ListOfObjects( "followers", NamedUser, ListGetable( [], [] ) ) ) -NamedUser._addAttributePolicy( ListOfObjects( "followers", NamedUser, ListGetable( [], [] ) ) ) +AuthenticatedUser._addAttributePolicy( ListAttribute( "followers", NamedUser, ListGetable( [], [] ) ) ) +NamedUser._addAttributePolicy( ListAttribute( "followers", NamedUser, ListGetable( [], [] ) ) ) -AuthenticatedUser._addAttributePolicy( ListOfObjects( "following", NamedUser, ListGetable( [], [] ), ElementAddable(), ElementRemovable(), ElementHasable() ) ) -NamedUser._addAttributePolicy( ListOfObjects( "following", NamedUser, ListGetable( [], [] ) ) ) +AuthenticatedUser._addAttributePolicy( ListAttribute( "following", NamedUser, ListGetable( [], [] ), ElementAddable(), ElementRemovable(), ElementHasable() ) ) +NamedUser._addAttributePolicy( ListAttribute( "following", NamedUser, ListGetable( [], [] ) ) ) Organization = GithubObject( "Organization", @@ -49,13 +49,13 @@ Organization = GithubObject( "disk_usage", "collaborators", "billing_email", "plan", "private_gists", "total_private_repos", "owned_private_repos", ), - ListOfObjects( "public_members", NamedUser, ListGetable( [], [] ), ElementAddable(), ElementRemovable(), ElementHasable() ), - ListOfObjects( "members", NamedUser, ListGetable( [], [] ), ElementRemovable(), ElementHasable() ), + ListAttribute( "public_members", NamedUser, ListGetable( [], [] ), ElementAddable(), ElementRemovable(), ElementHasable() ), + ListAttribute( "members", NamedUser, ListGetable( [], [] ), ElementRemovable(), ElementHasable() ), Editable( [], [ "billing_email", "blog", "company", "email", "location", "name" ] ), ) -AuthenticatedUser._addAttributePolicy( ListOfObjects( "orgs", Organization, ListGetable( [], [] ) ) ) -NamedUser._addAttributePolicy( ListOfObjects( "orgs", Organization, ListGetable( [], [] ) ) ) +AuthenticatedUser._addAttributePolicy( ListAttribute( "orgs", Organization, ListGetable( [], [] ) ) ) +NamedUser._addAttributePolicy( ListAttribute( "orgs", Organization, ListGetable( [], [] ) ) ) Repository = GithubObject( "Repository", @@ -71,24 +71,24 @@ Repository = GithubObject( "mirror_url", "updated_at", "id", ), ComplexAttribute( "owner", NamedUser ), - ListOfObjects( "collaborators", NamedUser, ListGetable( [], [] ), ElementAddable(), ElementRemovable(), ElementHasable() ), - ListOfObjects( "contributors", NamedUser, ListGetable( [], [] ) ), - ListOfObjects( "watchers", NamedUser, ListGetable( [], [] ) ), + ListAttribute( "collaborators", NamedUser, ListGetable( [], [] ), ElementAddable(), ElementRemovable(), ElementHasable() ), + ListAttribute( "contributors", NamedUser, ListGetable( [], [] ) ), + ListAttribute( "watchers", NamedUser, ListGetable( [], [] ) ), Editable( [ "name" ], [ "description", "homepage", "public", "has_issues", "has_wiki", "has_downloads" ] ), ) Repository._addAttributePolicy( ComplexAttribute( "parent", Repository ) ) Repository._addAttributePolicy( ComplexAttribute( "source", Repository ) ) -Repository._addAttributePolicy( ListOfObjects( "forks", Repository, ListGetable( [], [] ) ) ) +Repository._addAttributePolicy( ListAttribute( "forks", Repository, ListGetable( [], [] ) ) ) __repoElementCreatable = ElementCreatable( "repo", [ "name" ], [ "description", "homepage", "private", "has_issues", "has_wiki", "has_downloads", "team_id", ] ) __repoElementGetable = ElementGetable( "repo", lambda obj, name: { "owner": { "login": obj.login }, "name": name } ) __repoListGetable = ListGetable( [], [] ) -AuthenticatedUser._addAttributePolicy( ListOfObjects( "repos", Repository, __repoListGetable, __repoElementGetable, __repoElementCreatable ) ) -NamedUser._addAttributePolicy( ListOfObjects( "repos", Repository, __repoListGetable, __repoElementGetable ) ) -Organization._addAttributePolicy( ListOfObjects( "repos", Repository, __repoListGetable, __repoElementGetable, __repoElementCreatable ) ) +AuthenticatedUser._addAttributePolicy( ListAttribute( "repos", Repository, __repoListGetable, __repoElementGetable, __repoElementCreatable ) ) +NamedUser._addAttributePolicy( ListAttribute( "repos", Repository, __repoListGetable, __repoElementGetable ) ) +Organization._addAttributePolicy( ListAttribute( "repos", Repository, __repoListGetable, __repoElementGetable, __repoElementCreatable ) ) -AuthenticatedUser._addAttributePolicy( ListOfObjects( "watched", Repository, ListGetable( [], [] ), ElementAddable(), ElementRemovable(), ElementHasable() ) ) -NamedUser._addAttributePolicy( ListOfObjects( "watched", Repository, ListGetable( [], [] ) ) ) +AuthenticatedUser._addAttributePolicy( ListAttribute( "watched", Repository, ListGetable( [], [] ), ElementAddable(), ElementRemovable(), ElementHasable() ) ) +NamedUser._addAttributePolicy( ListAttribute( "watched", Repository, ListGetable( [], [] ) ) ) def __createForkForUser( user, repo ): assert isinstance( repo, Repository ) diff --git a/github/ObjectCapacities/List.py b/github/ObjectCapacities/List.py index 61deabf4..1fe32927 100644 --- a/github/ObjectCapacities/List.py +++ b/github/ObjectCapacities/List.py @@ -75,7 +75,7 @@ class ElementGetable: def __execute( self, obj, *args, **kwds ): return self.__type( obj._github, self.__attributes( obj, *args, **kwds ), lazy = False ) -class ListOfObjects: +class ListAttribute: def __init__( self, attributeName, type, *capacities ): self.attributeName = attributeName self.type = type