Remove default ListGetable capacity from lists

This commit is contained in:
Vincent Jacques
2012-02-22 19:41:01 +00:00
parent df2c351cc4
commit f2bc0ea942
5 changed files with 14 additions and 17 deletions
@@ -0,0 +1,23 @@
import itertools
class ArgumentsChecker:
def __init__( self, mandatoryParameters, optionalParameters ):
self.__mandatoryParameters = mandatoryParameters
self.__optionalParameters = optionalParameters
def check( self, args, kwds ):
data = dict( kwds )
if len( args ) + len( kwds ) == 0:
raise TypeError()
for arg, argumentName in itertools.izip( args, itertools.chain( self.__mandatoryParameters, self.__optionalParameters ) ):
if argumentName in kwds:
raise TypeError()
else:
data[ argumentName ] = arg
for argumentName in data:
if argumentName not in itertools.chain( self.__mandatoryParameters, self.__optionalParameters ):
raise TypeError()
for argumentName in self.__mandatoryParameters:
if argumentName not in data:
raise TypeError()
return data
+5 -5
View File
@@ -78,24 +78,24 @@ class ListGetable:
]
class ElementGetable:
def __init__( self, singularName ):
def __init__( self, singularName, attributes ):
self.__getName = "get_" + singularName
self.__attributes = attributes
def apply( self, list, cls ):
self.__type = list.type
self.__attributeName = list.attributeName
cls._addMethod( self.__getName, self.__execute )
def __execute( self, obj, identity ):
return self.__type( obj._github, obj._github._dataRequest( "GET", obj._baseUrl + "/" + self.__attributeName + "/" + identity, None, None ), lazy = True )
def __execute( self, obj, *args, **kwds ):
return self.__type( obj._github, self.__attributes( obj, *args, **kwds ), lazy = False )
class ListOfObjects:
def __init__( self, attributeName, type, *capacities ):
self.attributeName = attributeName
self.type = type
self.__getName = "get_" + attributeName
self.__capacities = list( capacities )
self.__capacities.append( ListGetable() )
self.__capacities = capacities
def apply( self, cls ):
for capacity in self.__capacities: