Add type parameter to get_repos

This commit is contained in:
Vincent Jacques
2012-02-19 10:17:25 +01:00
parent 3c2d7b7d81
commit c700599040
3 changed files with 21 additions and 13 deletions
+6 -3
View File
@@ -82,10 +82,11 @@ class Identity( AttributeFromCallable ):
AttributeFromCallable.__init__( self, "_identity", identity )
class ListOfReferences:
def __init__( self, attributeName, type, addable = False, removable = False, hasable = False ):
def __init__( self, attributeName, type, addable = False, removable = False, hasable = False, getParameters = None ):
self.__attributeName = attributeName
self.__type = type
self.__getName = "get_" + attributeName
self.__getParameters = getParameters
if addable:
self.__addName = "add_to_" + attributeName
else:
@@ -108,10 +109,12 @@ class ListOfReferences:
if self.__hasName is not None:
cls._addMethod( self.__hasName, self.__executeHas )
def __executeGet( self, obj ):
def __executeGet( self, obj, *args, **kwds ):
for arg, argumentName in itertools.izip( args, self.__getParameters ):
kwds[ argumentName ] = arg
return [
self.__type( obj._github, attributes, lazy = True )
for attributes in obj._github._dataRequest( "GET", obj._baseUrl + "/" + self.__attributeName, None, None )
for attributes in obj._github._dataRequest( "GET", obj._baseUrl + "/" + self.__attributeName, kwds, None )
]
def __executeAdd( self, obj, toBeAdded ):