def getPropertizedVariableWithItemTuple(_ItemTuple): #Maybe it is already defined if 'PropertyInitVariable' in _ItemTuple[1]: return _ItemTuple[1]['PropertyInitVariable'] else: #Return the default one associated with the type return SYS.getTypeClassWithTypeStr(SYS.getWordStrsListWithStr(_ItemTuple[0])[-1])
def do_set(self): """ """ #debug ''' self.debug( ("self.",self,[ 'SettingKeyVariable', 'SettingValueVariable' ]) ) ''' #itemize first if self.SettingItemBool: #debug ''' self.debug('first we itemize') ''' #itemize self.itemize( self.SettingKeyVariable ) else: #set self.ItemizedValueMethod=None #/############################ # Case of a method get # #debug ''' self.debug( ('self.',self,['ItemizedValueMethod']) ) ''' #Check if self.ItemizedValueMethod!=None: #debug ''' self.debug( [ 'we are going to call the method but first get it', ('self.',self,['ItemizedValueMethod']) ] ) ''' #/####################/# # Get the method and init the liarg and kwarg # #get SettedValueMethod=self[self.SettingKeyVariable] #alias SettedLiargVariable=self.SettingValueVariable SettedKwargVariable=None #/####################/# # Check for an argument dict # #debug ''' self.debug( [ 'SettedValueMethod is '+SYS._str(SettedValueMethod), 'Before calling the itemized method, we adapt the liarg', ('self.',self,['SettingValueVariable']) ] ) ''' #Check if hasattr( self.SettingValueVariable,'items' ): #Check if any( map( lambda __KeyStr: __KeyStr in self.SettingValueVariable, [ SetLiargGrabStr, SetMapLiargGetGrabStr, SetLiargGetGrabStr, SetKwargGrabStr, SetMapKwargGetKeyGrabStr, SetMapKwargGetKeyValueGrabStr ] ) ): #debug ''' self.debug( [ 'It is an argument dict' ] ) ''' #get [SettedLiargVariable,SettedKwargVariable]=map( lambda __KeyStr: ArgumentDict( self.SettingValueVariable, self )[__KeyStr], ['LiargVariablesList','KwargVariablesDict'] ) #debug ''' self.debug( [ 'SettedLiargVariable is '+SYS._str(SettedLiargVariable), 'SettedKwargVariable is '+SYS._str(SettedKwargVariable), ] ) ''' #/#################/# # Set a map lambda # elif SetLiargLambdaGrabStr in self.SettingValueVariable: #debug ''' self.debug( [ 'we set a value with a SetLiargLambdaGrabStr inside', ('self.',self,['SettingValueVariable']) ] ) ''' #temp SettedLambdaValueVariable=self.SettingValueVariable SettedLambdaKeyVariable=self.SettingKeyVariable #getMap SettedMapLambdaList=self.getMapLambdaList( SettedLambdaValueVariable ) #debug ''' self.debug( [ 'SettedMapLambdaList is', str(SettedMapLambdaList) ] ) ''' #map map set map( lambda __SettedVariable: self.mapSet(__SettedVariable), SettedMapLambdaList ) #Stop the setting return {"HookingIsBool":False} #set SettedIsBool=False #define if hasattr(SettedValueMethod,'im_func'): #Check if hasattr(SettedValueMethod.im_func,'BaseDoClass'): #debug ''' self.debug( [ "hasattr(SettedValueMethod.im_func.BaseDoClass.Module,'getLiargVariablesList') is", str(hasattr(SettedValueMethod.im_func.BaseDoClass.Module,'getLiargVariablesList')) ] ) ''' #Check if hasattr( SettedValueMethod.im_func.BaseDoClass.Module, 'getLiargVariablesList' ): #set SettedIsBool=True #get SettedLiargVariablesList=SettedValueMethod.im_func.BaseDoClass.Module.getLiargVariablesList( SettedLiargVariable ) #debug ''' self.debug( 'SettedLiargVariablesList is '+str(SettedLiargVariablesList) ) ''' if SettedKwargVariable!=None: #get the method and put the value as arguments SettedValueMethod(*SettedLiargVariablesList,**SettedKwargVariable) else: #get the method and put the value as arguments SettedValueMethod(*SettedLiargVariablesList) #Stop the setting return {"HookingIsBool":False} if SettedIsBool==False: #debug ''' self.debug( [ 'call the SettedValueMethod with self.SettingValueVariable directly', 'SettedLiargVariable is '+SYS._str(SettedLiargVariable) ] ) ''' #Check if hasattr(SettedLiargVariable,'items'): SettedLiargVariable=SettedLiargVariable.items() elif type(SettedLiargVariable)!=list: SettedLiargVariable=[SettedLiargVariable] #Check if SettedKwargVariable!=None: #direct #SettedValueMethod(*self.SettingValueVariable) SettedValueMethod(*SettedLiargVariable,**SettedKwargVariable) else: #direct #SettedValueMethod(*self.SettingValueVariable) SettedValueMethod(*SettedLiargVariable) #Stop the setting return {"HookingIsBool":False} #/####################/# # Case of a non method with set with a set key str # elif type( self.SettingKeyVariable ) in [str,unicode]: #cast self.SettingKeyVariable=str(self.SettingKeyVariable) #/####################/# # Case of #bound: set # #Check if self.SettingKeyVariable.startswith( SetBoundPrefixStr ): #deprefix SettedMethodStr=SYS.deprefix( self.SettingKeyVariable, SetBoundPrefixStr ) #debug ''' self.debug( [ 'We bound here', 'SettedMethodStr is '+SettedMethodStr ] ) ''' #bound setattr( self.__class__, SettedMethodStr, self.SettingValueVariable ) #call self.SettingValueVariable(self) #stop the setting return {'HookingIsBool':False} #/####################/# # Case of #untype: set # #Check elif self.SettingKeyVariable.startswith( SetUntypePrefixStr ): #set self.SettingTypeBool=False #get SettedEachGetVariable=self.set( SYS.deprefix( self.SettingKeyVariable, SetUntypePrefixStr ), self.SettingValueVariable ) #reset self.SettingTypeBool=True #Return stop the setting return {'HookingIsBool':False} #/####################/# # Case of #each: set # #Check elif self.SettingKeyVariable.startswith( SetEachPrefixStr ): #temp SettedTempLiargSettingValueVariable=self.SettingValueVariable #get SettedEachGetVariable=self[ SYS.deprefix( self.SettingKeyVariable, SetEachPrefixStr ) ] #debug ''' self.debug( [ 'We each here', ('self.',self,['SettingKeyVariable']), 'SettedEachGetVariable is '+str(SettedEachGetVariable) ] ) ''' #Check if hasattr(SettedEachGetVariable,'values'): SettedEachGetVariablesList=SettedEachGetVariable.values() else: SettedEachGetVariablesList=SettedEachGetVariable #debug ''' self.debug( [ 'SettedEachGetVariablesList is ', SYS._str(SettedEachGetVariablesList), 'SettedTempLiargSettingValueVariable is ', SYS._str(SettedTempLiargSettingValueVariable) ] ) ''' #map map( lambda __SettedGetVariable,__SettedValueVariable: __SettedGetVariable[SetMapStr]( SYS.SetList(__SettedValueVariable) ), SettedEachGetVariablesList, SettedTempLiargSettingValueVariable ) #Return stop the setting return {'HookingIsBool':False} #/####################/# # Case of #all: set # #Check elif self.SettingKeyVariable.startswith( SetAllPrefixStr ): #get SettedGetVariable=self[ SYS.deprefix( self.SettingKeyVariable, SetAllPrefixStr ) ] #Check if hasattr(SettedGetVariable,'values'): SettedGetVariablesList=SettedGetVariable.values() else: SettedGetVariablesList=SettedGetVariable #debug ''' self.debug( [ 'SettedGetVariablesList is ', SYS._str(SettedGetVariablesList), ('self.',self,['SettingValueVariable']) ] ) ''' #Check if type(self.SettingValueVariable) in [ list,tuple ] and len(self.SettingValueVariable)==2: #map map( lambda __SettedGetVariable: __SettedGetVariable.set( *self.SettingValueVariable ), SettedGetVariablesList ) else: #map map( lambda __SettedGetVariable: __SettedGetVariable[SetMapStr]( self.SettingValueVariable ), SettedGetVariablesList ) #Return stop the setting return {'HookingIsBool':False} #/####################/# # Case of #copy: set # #Check elif self.SettingKeyVariable.startswith( SetCopyPrefixStr ): #deprefix GetKeyStr=SYS.deprefix( self.SettingKeyVariable, SetCopyPrefixStr ) #debug ''' self.debug( [ 'We copy set here', 'GetKeyStr is ', GetKeyStr ] ) ''' #set self[GetKeyStr]=copy.copy(self.SettingValueVariable) #Return stop the setting return {'HookingIsBool':False} #Check elif self.SettingKeyVariable.startswith( SetDeepCopyPrefixStr ): #deprefix GetKeyStr=SYS.deprefix( self.SettingKeyVariable, SetDeepCopyPrefixStr ) #debug ''' self.debug( [ 'We deepcopy set here', 'GetKeyStr is ', GetKeyStr ] ) ''' #set self[GetKeyStr]=copy.deepcopy(self.SettingValueVariable) #Return stop the setting return {'HookingIsBool':False} #/####################/# # Case of a set in the __dict__ # else: #/####################/# # Case of a set with a #get in the value # if type( self.SettingValueVariable )==str and self.SettingValueVariable.startswith(SetUndirectPrefixStr): #deprefix SettedKeyStr=SYS.deprefix( self.SettingValueVariable, SetUndirectPrefixStr ) #debug ''' self.debug( [ 'This is a undirect of a str variable', 'SettedKeyStr is '+SettedKeyStr ] ) ''' #Check if SetUndirectPrefixStr in SettedKeyStr: #split SettedKeyStrsList=SettedKeyStr.split(SetUndirectPrefixStr) #define SettedRecursiveKeyStr=''.join( SettedKeyStrsList[:-1])+self[SettedKeyStrsList[-1]] #debug ''' self.debug( [ 'This is a recursive undirect set', 'SettedRecursiveKeyStr is '+SettedRecursiveKeyStr ] ) ''' #set self[ self.SettingKeyVariable ]=SetUndirectPrefixStr+SettedRecursiveKeyStr else: #debug ''' self.debug( 'This is one level undirect set' ) ''' #set self[ self.SettingKeyVariable ]=self[SettedKeyStr] #Stop the getting return {"HookingIsBool":False} #/####################/# # Case of a set with a set dict # #Check elif hasattr( self.SettingValueVariable,'items' ): #debug ''' self.debug( [ 'Check for a set value dict', ('self.',self,['SettingValueVariable']) ] ) ''' if SetValueGrabStr in self.SettingValueVariable: #debug ''' self.debug( [ 'we set a value with a SetValueGrabStr inside', ('self.',self,['SettingValueVariable']) ] ) ''' #set self[self.SettingKeyVariable]=self.SettingValueVariable[SetValueGrabStr] #Return return {'HookingIsBool':False} elif SetMapValueGetGrabStr in self.SettingValueVariable: #debug ''' self.debug( [ 'we set a value with a map SetMapValueGetGrabStr inside', ('self.',self,['SettingValueVariable']) ] ) ''' #set self[self.SettingKeyVariable]=self[ SYS.deprefix( SetMapValueGetGrabStr, SetValueGrabPrefixStr ) ]( *self.SettingValueVariable[SetMapValueGetGrabStr] ).ItemizedMapValueVariablesList #Return return {'HookingIsBool':False} #Check elif SetValueGetGrabStr in self.SettingValueVariable: #Get SettedGrabValueVariable=self[ self.SettingValueVariable[SetValueGetGrabStr] ] #debug ''' self.debug( [ 'we set a value with a SetValueGetGrabStr inside', ('self.',self,['SettingValueVariable']), 'SettedGrabValueVariable is '+SYS._str( SettedGrabValueVariable) ] ) ''' #set self[ self.SettingKeyVariable ]=SettedGrabValueVariable #Return return {'HookingIsBool':False} elif SetValueLambdaGrabStr in self.SettingValueVariable: #debug ''' self.debug( [ 'This is a lambda map set', ('self.',self,['SettingValueVariable']) ] ) ''' #temp SettedTempKeyVariable=self.SettingKeyVariable SettedTempValueVariable=self.SettingValueVariable #getMap SettedReplaceValueVariablesList=self.getMapLambdaList( SettedTempValueVariable ) #set self[SettedTempKeyVariable]=SettedReplaceValueVariablesList #Return return {'HookingIsBool':False} #/####################/# # Case of an instancing set # #Check if self.SettingTypeBool: #debug ''' self.debug( [ 'we check if we have to set a default value here', ('self.',self,[ 'SettingKeyVariable', 'SettingValueVariable' ]) ] ) ''' #get SettedValueType=SYS.getTypeClassWithTypeStr( SYS.getTypeStrWithKeyStr( self.SettingKeyVariable) ) #type SettedSettingValueVariableType=type(self.SettingValueVariable) #cast if SettedSettingValueVariableType==unicode: self.SettingValueVariable=str(self.SettingValueVariable) SettedSettingValueVariableType=str #Check if SettedValueType!=SettedSettingValueVariableType: #debug ''' self.debug( [ 'Check that the type is not a lst and a numpy array' ] ) ''' #Check if set([ SettedValueType.__name__, SettedSettingValueVariableType.__name__ ])!=SetListTypesSet: #debug ''' self.debug( [ 'SettedValueType is '+str(SettedValueType), ('self.',self,['SettingKeyVariable']) ] ) ''' #Check if SettedValueType!=None.__class__: #debug ''' self.debug( [ 'we wrap the setting value', ('self.',self,['SettingValueVariable']) ] ) ''' #alias ''' try: ''' #map set self[self.SettingKeyVariable]=SettedValueType( ).mapSet( self.SettingValueVariable ) #self[self.SettingKeyVariable]=SettedValueType( # )[SetMapStr]( # self.SettingValueVariable #) #self.SettingValueVariable=SettedValueType( # )[SetMapValueGetGrabStr]( # self.SettingValueVariable #) ''' except: #debug self.debug( [ 'set failed because the suffix str indicates a different type from the value', 'SettedValueType is '+str(SettedValueType), 'type(self.SettingValueVariable) is '+str( type(self.SettingValueVariable)) ] ) ''' #debug ''' self.debug( 'Ok we have instanced' ) ''' #Return return {'HookingIsBool':False} #/####################/# # Check that it is not a property # #Check if hasattr(self.__class__,self.SettingKeyVariable): #get SettedPropertyValueVariable=getattr(self.__class__,self.SettingKeyVariable) #Check if type(SettedPropertyValueVariable)==property: #debug ''' self.debug('It is a property set') ''' #set the property setattr( self, self.SettingKeyVariable, self.SettingValueVariable ) #Return return {'HookingIsBool':False} #/####################/# # Set in the __dict__ ... finally # #debug ''' self.debug( [ 'we just maybe set in the __dict__', ('self.',self,[ 'SettingKeyVariable', 'SettingValueVariable' ]) ] ) ''' #__setitem__ in the __dict__, this is an utility set self.__dict__[ self.SettingKeyVariable ]=self.SettingValueVariable #/####################/# # GIve maybe some things to the setted value # #add in the SettingValue try: self.SettingValueVariable.SetTagStr=self.SettingKeyVariable self.SettingValueVariable.SetDeriveSetter=self except: pass #Return return {'HookingIsBool':False} #/####################/# # Case of a non method set with a set dict in the Key Variable # elif hasattr(self.SettingKeyVariable,'items'): #get SettedGetKeyVariable=self[self.SettingKeyVariable] #debug ''' self.debug( [ 'SettingKeyVariable has items...', ('self.',self,['SettingKeyVariable']), 'SettedGetKeyVariable is '+SYS._str(SettedGetKeyVariable) ] ) ''' #set self.set( SettedGetKeyVariable, self.SettingValueVariable ) #Return return {'HookingIsBool':False} #/####################/# # Case of a function set # elif callable(self.SettingKeyVariable): #/####################/# # Case of a non method with a set dict in the Value Variable # #debug ''' self.debug( [ 'The key is callable', ('self.',self,[ 'SettingValueVariable', 'PathDerivePather' ]), 'map get the values to have the liargvariables list' ] ) ''' #Set SettedTempKeyVariable=self.SettingKeyVariable SettedLiargVariable=self.SettingValueVariable SettedKwargVariable=None #/####################/# # Check for an argument dict # #Check if hasattr( SettedLiargVariable,'items' ): #Check if any( map( lambda __KeyStr: __KeyStr in SettedLiargVariable, [ SetLiargGrabStr, SetMapLiargGetGrabStr, SetLiargGetGrabStr, SetKwargGrabStr, SetMapKwargGetKeyGrabStr, SetMapKwargGetKeyValueGrabStr ] ) ): #debug self.debug( [ 'It is a argument dict' ] ) #get [SettedLiargVariable,SettedKwargVariable]=map( lambda __KeyStr: ArgumentDict( SettedLiargVariable, self )[__KeyStr], ['LiargVariablesList','KwargVariablesDict'] ) #debug ''' self.debug( [ 'SettedLiargVariable is '+SYS._str(SettedLiargVariable), 'SettedKwargVariable is '+SYS._str(SettedKwargVariable), ] ) ''' else: #/###################/ # It is a get dict # #call a set to active the #value get self.set( 'TempSetVariable', SettedLiargVariable ) #debug ''' self.debug( [ 'This is a get dict ', 'self.TempSetVariable is '+SYS._str(self.TempSetVariable), ('self.',self,['SettingValueVariable']) ] ) ''' #get SettedLiargVariable=self.TempSetVariable if type( self.TempSetVariable)==list else [self.TempSetVariable] #delete del self.__dict__['TempSetVariable'] #reupdate self.SettingKeyVariable=SettedTempKeyVariable #Check if type(SettedLiargVariable)!=list: #get SettedLiargVariablesList=[SettedLiargVariable] else: #alias SettedLiargVariablesList=SettedLiargVariable #debug ''' self.debug( [ 'we call here', ('self.',self,['SettingKeyVariable']), 'SettedLiargVariablesList is '+SYS._str(SettedLiargVariablesList) ] ) ''' #call if SettedLiargVariable!=None and SettedKwargVariable!=None: self.SettingKeyVariable( *SettedLiargVariablesList, **SettedKwargVariable ) else: self.SettingKeyVariable( *SettedLiargVariablesList ) #debug ''' self.debug( 'self.SettingKeyVariable.__self__ is '+SYS._str( self.SettingKeyVariable.__self__ ) ) ''' #Return return {'HookingIsBool':False}
def setDefaultMutable( _InstanceVariable, _ClassVariable, _AttributeKeyVariable=None, **_KwargVariablesDict ): #get DefaultClassesList=SYS.GetList(_ClassVariable,SYS) #Set if 'ForceSetIsBool' in _KwargVariablesDict: ForceSetIsBool=_KwargVariablesDict['ForceSetIsBool'] else: ForceSetIsBool=False #/#################/# # Get all the attribute to default set again and filter # the ones that have not the right # #Check if _AttributeKeyVariable==None: AttributeKeyStrsList=SYS.sum( map( lambda __DefaultClass: __DefaultClass.DefaultSpecificKeyStrsList, DefaultClassesList ) ) elif type(_AttributeKeyVariable)!=list: AttributeKeyStrsList=[AttributeKeyVariable] else: AttributeKeyStrsList=_AttributeKeyVariable #/################/# # map an init for the mutable variables by detecting them at the level of the class # they are None # #map TypeClassesList=map( lambda __AttributeKeyStr: SYS.getTypeClassWithTypeStr( SYS.getTypeStrWithKeyStr(__AttributeKeyStr) ) if ( SYS.getIsNoneBool( getattr( _InstanceVariable, __AttributeKeyStr ) ) if ForceSetIsBool==False else True ) and getattr( _InstanceVariable.__class__, __AttributeKeyStr )==None else None.__class__, AttributeKeyStrsList ) #debug ''' print('l 122 Defaultor') print('AttributeKeyStrsList is '+str(AttributeKeyStrsList)) print('TypeClassesList is '+str(TypeClassesList)) print('') ''' #set in the instance map( lambda __AttributeKeyStr,__TypeClass: setattr( _InstanceVariable, __AttributeKeyStr, __TypeClass() ) if __TypeClass!=None.__class__ else None, AttributeKeyStrsList, TypeClassesList ) #return return _InstanceVariable
DoClass.DoneAttributeTuplesList ) #Define DoneKwargDict=dict(DoClass.DoneNotAttributeTupleItemsList) else: #Define DoneKwargDict={} #map TypeClassesList=map( lambda __DoneKeyStr: SYS.getTypeClassWithTypeStr( SYS.getTypeStrWithKeyStr(__DoneKeyStr) ) if getattr(_InstanceVariable,__DoneKeyStr )==None else None.__class__, _Class.DoingAttributeVariablesOrderedDict.keys( )+_Class.DoneAttributeVariablesOrderedDict.keys() ) #debug ''' print('TypeClassesList is '+str(TypeClassesList)) print('') ''' #set in the instance map( lambda __DoneKeyStr,__TypeClass:
DoClass.DoTempAttributeItemTuplesList ) #Define DoneKwargDict=dict(DoClass.DoTempNotAttributeItemTupleItemsList) else: #Define DoneKwargDict={} #map TypeClassesList=map( lambda __DoneKeyStr: SYS.getTypeClassWithTypeStr( SYS.getTypeStrWithKeyStr(__DoneKeyStr) ) if getattr(_InstanceVariable,__DoneKeyStr)==None else None.__class__, DoClass.DoingAttributeVariablesOrderedDict.keys( )+DoClass.DoneAttributeVariablesOrderedDict.keys() ) #debug ''' print('TypeClassesList is '+str(TypeClassesList)) print('') ''' #set in the instance map(
def do_get(self): """ """ #debug ''' self.debug( [ ("self.",self,[ 'GettingKeyVariable', 'NameStr', 'GettingItemBool' ] ) ] ) ''' #itemize first if self.GettingItemBool: #debug ''' self.debug('first we itemize') ''' #Check if self.GettingKeyVariable==GetMapStr: #set self.ItemizingMapGetVariable='GettedValueVariable' #itemize self.itemize( self.GettingKeyVariable ) #Check #if self.GettingKeyVariable==GetMapStr: # # #set # self.GettingItemBool=False else: #set self.ItemizedValueMethod=None #set #self.GettingItemBool=True #/############################ # Case of a method get # #debug ''' self.debug( ('self.',self,['ItemizedValueMethod']) ) ''' #Check if self.ItemizedValueMethod!=None: #debug ''' self.debug( [ 'This is a method get', ('self.',self,[ 'ItemizedValueMethod', 'ItemizingMapGetVariable' ] ) ] ) ''' #alias self.GettedValueVariable=self.ItemizedValueMethod #Stop the getting return {"HookingIsBool":False} #/############################ # Case of a GetClass get # #Check if type(self.GettingKeyVariable)==GetClass: #Check if self.GettingKeyVariable.SelfVariable==None: self.GettingKeyVariable.SelfVariable=self #call self.GettedValueVariable=self.GettingKeyVariable() #Stop the getting return {"HookingIsBool":False} #/############################ # Cases of a key str get # #Check if type(self.GettingKeyVariable) in [str,unicode]: #debug ''' self.debug( [ 'This is a non method get', ('self.',self,[ 'GettingKeyVariable', 'GettingNewBool' ]) ] ) ''' ''' #/############################ # Case of a delete in the instance __dict__ # if self.GettingKeyVariable.startswith(GetDeletePrefixStr) #delete del self.__dict__[ SYS.deprefix( self.GettingKeyVariable, GetDeletePrefixStr ) ] #Stop the getting return {"HookingIsBool":False} ''' #/############################ # Case of a direct str get # if self.GettingKeyVariable.startswith(GetDirectPrefixStr): #debug ''' self.debug('This is a direct get of a str variable') ''' #set self.GettedValueVariable=SYS.deprefix( self.GettingKeyVariable, GetDirectPrefixStr ) #Stop the getting return {"HookingIsBool":False} #/############################ # Case of a call str get # if self.GettingKeyVariable.startswith(GetCallPrefixStr): #get GettedMethod=self[ SYS.deprefix( self.GettingKeyVariable, GetCallPrefixStr ) ] #debug ''' self.debug( [ 'This is a call get of a str variable', 'GettedMethod is '+SYS._str(GettedMethod) ] ) ''' if type(GettedMethod)==types.MethodType: #set self.GettedValueVariable=GettedMethod() else: #set self.GettedValueVariable=GettedMethod(self) #Stop the getting return {"HookingIsBool":False} #/############################ # Case of a #id: get of an instance thanks to its id # elif self.GettingKeyVariable.startswith(GetIdPrefixStr): #deprefix GettedKeyStr=SYS.deprefix( self.GettingKeyVariable, GetIdPrefixStr ) #debug ''' self.debug( [ 'This is a id get ', 'GettedKeyStr is '+GettedKeyStr ] ) ''' #IdDict self.GettedValueVariable=SYS.IdDict[ int(GettedKeyStr) ] #Stop the getting return {"HookingIsBool":False} #/############################ # Case of a #get: str get # elif self.GettingKeyVariable.startswith(GetUndirectPrefixStr): #deprefix GettedKeyStr=SYS.deprefix( self.GettingKeyVariable, GetUndirectPrefixStr ) #debug ''' self.debug( [ 'This is a undirect of a str variable', 'GettedKeyStr is '+GettedKeyStr ] ) ''' #Check if GetUndirectPrefixStr in GettedKeyStr: #split GettedKeyStrsList=GettedKeyStr.split(GetUndirectPrefixStr) #define GettedRecursiveKeyStr=''.join(GettedKeyStrsList[:-1])+self[GettedKeyStrsList[-1]] #debug ''' self.debug( [ 'This is a recursive undirect get', 'GettedRecursiveKeyStr is '+GettedRecursiveKeyStr ] ) ''' #set self.GettedValueVariable=self[ GetUndirectPrefixStr+GettedRecursiveKeyStr ] else: #debug ''' self.debug( 'This is one level undirect get' ) ''' #set self.GettedValueVariable=self[ self[GettedKeyStr] ] #Stop the getting return {"HookingIsBool":False} #/############################ # Case of a get in the instance __dict__ # #Get safely the Value elif self.GettingKeyVariable in self.__dict__: #debug ''' self.debug( [ 'self.GettingKeyVariable exists in the __dict__', self.GettingKeyVariable ] ) ''' #__getitem__ in the __dict__ self.GettedValueVariable=self.__dict__[ self.GettingKeyVariable ] #Check if type(self.GettedValueVariable)==GetClass: #debug ''' self.debug( [ 'Actually the getted value is a GetClass' ] ) ''' #set self.GettedValueVariable.SelfVariable=self #call self.GettedValueVariable=self.GettedValueVariable() #debug ''' self.debug( [ 'This is a Spe in Instance', ('self.',self,['GettedValueVariable']) ] ) ''' #Stop the getting return {"HookingIsBool":False} #/############################ # Case of the __class__ get # #Check elif self.GettingKeyVariable=='__class__': #set self.GettedValueVariable=self.__class__ #Stop the getting return {"HookingIsBool":False} #/############################ # Case of a get in the instance __dict__ # #Check elif self.GettingKeyVariable in self.__class__.__dict__: #debug ''' self.debug( [ 'this is in a class __dict__', ('self.',self,['GettingKeyVariable']) ] ) ''' #get GettedClassValueVariable=self.__class__.__dict__[ self.GettingKeyVariable ] #/############################ # Case of a get of a property # if type(GettedClassValueVariable)==property: #get by the reactive getattr self.GettedValueVariable=getattr(self,self.GettingKeyVariable) else: #__getitem__ in the __class__ self.GettedValueVariable=GettedClassValueVariable #debug ''' self.debug( [ 'This is in the __class__', ('self.',self,['GettedValueVariable']) ] ) ''' #Stop the getting return {"HookingIsBool":False} elif self.GettingNewBool: #debug ''' self.debug( [ 'we are going to set a default value here', ('self.',self,['GettingKeyVariable']) ] ) ''' #get GettedValueType=SYS.getTypeClassWithTypeStr( SYS.getTypeStrWithKeyStr( self.GettingKeyVariable) ) #debug ''' self.debug( [ 'GettedValueType is '+str(GettedValueType), ('self.',self,['GettingKeyVariable']) ] ) ''' #Check if callable(GettedValueType): #debug self.debug( [ 'We call here', 'GettedValueType is '+str(GettedValueType), ('self.',self,['GettingKeyVariable']) ] ) #alias self.GettedValueVariable=GettedValueType() #set a default value self.__setattr__( self.GettingKeyVariable, self.GettedValueVariable ) #add in the SettingValue try: self.GettedValueVariable.SetTagStr=self.GettingKeyVariable self.GettedValueVariable.SetDeriveSetter=self except: pass #Stop the getting return {"HookingIsBool":False} #/############################ # Cases of a dict GetVariable get # elif hasattr(self.GettingKeyVariable,'items' ) and type(self.GettingKeyVariable)!=type: #debug ''' self.debug( [ 'we get or set with an itemizable instance', ('self.',self,['GettingKeyVariable']) ] ) ''' #Init GettedReturnBool=False #Temp GettedTempGettingKeyVariable=self.GettingKeyVariable #Check if GetGrabStr in GettedTempGettingKeyVariable: #debug ''' self.debug( [ 'we get with the GetGrabStr' ] ) ''' #get self.GettedValueVariable=self[ GettedTempGettingKeyVariable[GetGrabStr] ] #set GettedReturnBool=True elif GetUndirectGrabStr in GettedTempGettingKeyVariable: #get GettedKeyStr=GettedTempGettingKeyVariable[GetUndirectGrabStr] #debug ''' self.debug( [ 'we get with the GetUndirectGrabStr', ('self.',self,['GettingKeyVariable']), 'GettedKeyStr is '+GettedKeyStr ] ) ''' #get get self.GettedValueVariable=self[ self[ GettedKeyStr ] ] #set GettedReturnBool=True #Check elif GetMapUndirectGrabStr in GettedTempGettingKeyVariable: #get GettedLiargVariablesList=GettedTempGettingKeyVariable[ GetMapUndirectGrabStr ] #debug ''' self.debug( [ 'we get with the GetMapUndirectGrabStr', ('self.',self,['GettingKeyVariable']), 'GettedLiargVariablesList is '+SYS._str(GettedLiargVariablesList) ] ) ''' #get self.GettedValueVariable=self[ SYS.deprefix( GetMapUndirectGrabStr, GetUndirectGrabPrefixStr ) ]( *GettedLiargVariablesList ).ItemizedMapValueVariablesList #set GettedReturnBool=True #/##################/# # Case of a modification # #Check if GetModifyGrabStr in GettedTempGettingKeyVariable: #debug ''' self.debug( 'We modify here ' ) ''' #call #self.GettedValueVariable=GettedTempGettingKeyVariable[ # GetModifyGrabStr #]() self.GettedValueVariable=self[ GettedTempGettingKeyVariable[GetModifyGrabStr] ] if GetSetGrabStr in GettedTempGettingKeyVariable: #debug ''' self.debug( 'We set here in the GettedValueVariable' ) ''' #get SetVariable=GettedTempGettingKeyVariable[GetSetGrabStr] #set self.GettedValueVariable[ SetVariable[0] ]=SetVariable[1] elif GetMapSetGrabStr in GettedTempGettingKeyVariable: #debug ''' self.debug( 'We map a set here in the GettedValueVariable' ) ''' #get SetVariable=GettedTempGettingKeyVariable[GetMapSetGrabStr] #Check if hasattr(SetVariable,'items'): SetVariablesList=SetVariable.items() else: SetVariablesList=SetVariable #set map( lambda __SetVariable: self.GettedValueVariable.__setitem__( __SetVariable[0], __SetVariable[1] ), SetVariablesList ) #Check if GettedReturnBool: #Stop the getting return {"HookingIsBool":False} #/############################ # Cases of a direct get # #elif hasattr(self.GettingKeyVariable,'MroClassesList'): if type(self.GettingKeyVariable)!=str: #debug ''' self.debug('This is a direct get of a non str variable') ''' #set self.GettedValueVariable=self.GettingKeyVariable #Stop the getting return {"HookingIsBool":False} #set self.GettedValueVariable=None #debug ''' self.debug( [ 'Not found here so set it to None', ('self.',self,['GettedValueVariable']) ] ) ''' #Return an output dict return {"HookingIsBool":True}
def do_set(self): """ """ #debug ''' self.debug( ("self.",self,[ 'SettingKeyVariable', 'SettingValueVariable' ]) ) ''' #itemize first if self.SettingItemBool: #debug ''' self.debug('first we itemize') ''' #itemize self.itemize( self.SettingKeyVariable ) else: #set self.ItemizedValueMethod=None #/############################ # Case of a method get # #debug ''' self.debug( ('self.',self,['ItemizedValueMethod']) ) ''' #Check if self.ItemizedValueMethod!=None: #debug ''' self.debug('we are going to call the method but first get it') ''' #get SettedValueMethod=self[self.SettingKeyVariable] #debug ''' self.debug('SettedValueMethod is '+str(SettedValueMethod)) ''' #define try: #get SettedLiargVariablesList=SettedValueMethod.im_func.BaseDoClass.Module.getLiargVariablesList( self.SettingValueVariable ) ''' self.debug( 'SettedLiargVariablesList is '+str(SettedLiargVariablesList) ) ''' #get the method and put the value as arguments SettedValueMethod(*SettedLiargVariablesList) except: #debug ''' self.debug('call the SettedValueMethod with self.SettingValueVariable directly') ''' #direct #SettedValueMethod(*self.SettingValueVariable) SettedValueMethod(self.SettingValueVariable) #debug #Stop the setting return {"HookingIsBool":False} #/####################/# # Case of a non method with set with a set key str # elif type(self.SettingKeyVariable )==str: #/####################/# # Case of #each: set # #Check if self.SettingKeyVariable.startswith( SetEachPrefixStr ): #get SettedGetVariable=self[ SYS.deprefix( self.SettingKeyVariable, SetEachPrefixStr ) ] #Check if hasattr(SettedGetVariable,'values'): SettedGetVariablesList=SettedGetVariable.values() else: SettedGetVariablesList=SettedGetVariable #debug ''' self.debug( [ 'SettedGetVariablesList is ', SYS._str(SettedGetVariablesList), ('self.',self,['SettingValueVariable']) ] ) ''' #map map( lambda __SettedGetVariable,__SettedValueVariable: __SettedGetVariable.set( *__SettedValueVariable ) if type(__SettedValueVariable) in [ list,tuple ] and len(__SettedValueVariable)==2 else __SettedGetVariable['#map@set']( __SettedValueVariable ), SettedGetVariablesList, self.SettingValueVariable ) #Return stop the setting return {'HookingIsBool':False} #/####################/# # Case of #all: set # #Check elif self.SettingKeyVariable.startswith( SetAllPrefixStr ): #get SettedGetVariable=self[ SYS.deprefix( self.SettingKeyVariable, SetAllPrefixStr ) ] #Check if hasattr(SettedGetVariable,'values'): SettedGetVariablesList=SettedGetVariable.values() else: SettedGetVariablesList=SettedGetVariable #debug ''' self.debug( [ 'SettedGetVariablesList is ', SYS._str(SettedGetVariablesList), ('self.',self,['SettingValueVariable']) ] ) ''' #Check if type(self.SettingValueVariable) in [ list,tuple ] and len(self.SettingValueVariable)==2: #map map( lambda __SettedGetVariable: __SettedGetVariable.set( *self.SettingValueVariable ), SettedGetVariablesList ) else: #map map( lambda __SettedGetVariable: __SettedGetVariable['#map@set']( self.SettingValueVariable ), SettedGetVariablesList ) #Return stop the setting return {'HookingIsBool':False} #/####################/# # Case of a set in the __dict__ # else: #/####################/# # Case of an instancing set # #Check if self.SettingTypeBool: #debug ''' self.debug( [ 'we check if we have to set a default value here', ('self.',self,[ 'SettingKeyVariable', 'SettingValueVariable' ]) ] ) ''' #get SettedValueType=SYS.getTypeClassWithTypeStr( SYS.getTypeStrWithKeyStr( self.SettingKeyVariable) ) #Check if SettedValueType!=type(self.SettingValueVariable): #debug ''' self.debug( [ 'SettedValueType is '+str(SettedValueType) ] ) ''' #Check if SettedValueType!=None.__class__: #debug self.debug( [ 'we wrap the setting value', ('self.',self,['SettingValueVariable']) ] ) #alias ''' try: ''' #map set self.SettingValueVariable=SettedValueType( )['#map@set']( self.SettingValueVariable ) ''' except: #debug self.debug( [ 'set failed because the suffix str indicates a different type from the value', 'SettedValueType is '+str(SettedValueType), 'type(self.SettingValueVariable) is '+str( type(self.SettingValueVariable)) ] ) ''' #debug ''' self.debug( [ 'we just set in the __dict__', ('self.',self,[ 'SettingKeyVariable', 'SettingValueVariable' ]) ] ) ''' #map ''' if type(self.SettingKeyVariable)==SYS.MapListClass: #map map( lambda __MappedVariable: self.__setitem__( *__MappedVariable ), self.SettingKeyVariable ) #Return an output dict return {"HookingIsBool":False} else: ''' #__setitem__ in the __dict__, this is an utility set self.__dict__[ self.SettingKeyVariable ]=self.SettingValueVariable #add in the SettingValue try: self.SettingValueVariable.SetTagStr=self.SettingKeyVariable #self.SettingValueVariable.SetDeriveSetter=self except: pass #Return return {'HookingIsBool':False} #/####################/# # Case of a non method with set with a set dict # elif hasattr(self.SettingKeyVariable,'items'): #debug self.debug( [ 'SettingKeyVariable has items...', ('self.',self,['SettingKeyVariable']) ] ) try: #debug self.debug( 'We set with a SetKeyVariable' ) #set self.set( self.SettingKeyVariable['SetKeyVariable'], self.SettingValueVariable ) #delete del self.SettingKeyVariable['SetKeyVariable'] except: #debug self.debug( 'We set with a SetKeyVariable' ) #set self.set( self.SettingKeyVariable['SetKeyVariable'], SYS.update( self.SettingKeyVariable, self.SettingValueVariable ) ) #delete del self.SettingKeyVariable['SetKeyVariable'] #Return return {'HookingIsBool':False}
def do_get(self): """ """ #debug ''' self.debug( [ ("self.",self,[ 'GettingKeyVariable', 'NameStr' ] ) ] ) ''' #itemize first if self.GettingItemBool: #debug ''' self.debug('first we itemize') ''' #Check if self.GettingKeyVariable==Itemizer.ItemMapPrefixStr+'get': #set self.ItemizingMapGetVariable='GettedValueVariable' #itemize self.itemize( self.GettingKeyVariable ) #Check if self.GettingKeyVariable==Itemizer.ItemMapPrefixStr+'get': #set self.GettingItemBool=False else: #set self.ItemizedValueMethod=None #set self.GettingItemBool=True #/############################ # Case of a method get # #debug ''' self.debug( ('self.',self,['ItemizedValueMethod']) ) ''' #Check if self.ItemizedValueMethod!=None: #debug ''' self.debug( [ 'This is a method get', ('self.',self,[ 'ItemizedValueMethod', 'ItemizingMapGetVariable' ] ) ] ) ''' #alias self.GettedValueVariable=self.ItemizedValueMethod #Stop the getting return {"HookingIsBool":False} #/############################ # Cases of a key str get # #Check if type(self.GettingKeyVariable) in [str,unicode]: #debug ''' self.debug( 'This is a non method get' ) ''' ''' #/############################ # Case of a delete in the instance __dict__ # if self.GettingKeyVariable.startswith(GetDeletePrefixStr) #delete del self.__dict__[ SYS.deprefix( self.GettingKeyVariable, GetDeletePrefixStr ) ] #Stop the getting return {"HookingIsBool":False} ''' #/############################ # Case of a get in the instance __dict__ # #Get safely the Value if self.GettingKeyVariable in self.__dict__: #__getitem__ in the __dict__ self.GettedValueVariable=self.__dict__[ self.GettingKeyVariable ] #debug ''' self.debug( [ 'This is a Spe in Instance', ('self.',self,['GettedValueVariable']) ] ) ''' #Stop the getting return {"HookingIsBool":False} #/############################ # Case of the __class__ get # #Check elif self.GettingKeyVariable=='__class__': #set self.GettedValueVariable=self.__class__ #Stop the getting return {"HookingIsBool":False} #/############################ # Case of a get in the instance __dict__ # #Check elif self.GettingKeyVariable in self.__class__.__dict__: #__getitem__ in the __class__ self.GettedValueVariable=self.__class__.__dict__[ self.GettingKeyVariable ] #debug ''' self.debug( [ 'This is in the __class__', ('self.',self,['GettedValueVariable']) ] ) ''' #Stop the getting return {"HookingIsBool":False} elif self.GettingNewBool: #debug ''' self.debug( [ 'we are going to set a default value here', ('self.',self,['GettingKeyVariable']) ] ) ''' #get GettedValueType=SYS.getTypeClassWithTypeStr( SYS.getTypeStrWithKeyStr( self.GettingKeyVariable) ) #debug ''' self.debug('GettedValueType is '+str(GettedValueType)) ''' #Check if callable(GettedValueType): #alias self.GettedValueVariable=GettedValueType() #set a default value self.__setattr__( self.GettingKeyVariable, self.GettedValueVariable ) #add in the SettingValue try: self.GettedValueVariable.SetTagStr=self.GettingKeyVariable except: pass #Stop the getting return {"HookingIsBool":False} #/############################ # Cases of a dict GetVariable get # elif hasattr(self.GettingKeyVariable,'items'): #debug self.debug( [ 'we get or set with an itemizable instance', ('self.',self,['GettingKeyVariable']) ] ) #try try: #debug ''' self.debug( [ 'we get with the GetVariable' ] ) ''' #get self.GettedValueVariable=self[ self.GettingKeyVariable['GetVariable'] ] #del del self.GettingKeyVariable['GetVariable'] except: #debug ''' self.debug( [ 'we get with the SetKeyVariable', "self.GettingKeyVariable['SetKeyVariable'] is ", str( self.GettingKeyVariable['SetKeyVariable'] ) ] ) ''' #set try: #debug self.debug('We get with the GetVariable') #get self[ self.GettingKeyVariable['GetVariable'] ]=self.GettingKeyVariable #del del self.GettingKeyVariable['GetVariable'] except: #debug self.debug('We get with the SetKeyVariable') #set self.__setattr__( self.GettingKeyVariable['SetKeyVariable'], self.GettingKeyVariable ) #del del self.GettingKeyVariable['SetKeyVariable'] #alias self.GettedValueVariable=self.GettingKeyVariable #Stop the getting return {"HookingIsBool":False} #/############################ # Cases of a direct get # elif hasattr(self.GettingKeyVariable,'MroClassesList'): #set self.GettedValueVariable=self.GettingKeyVariable #Stop the getting return {"HookingIsBool":False} #set self.GettedValueVariable=None #debug ''' self.debug( [ 'Not found here so set it to None', ('self.',self,['GettedValueVariable']) ] ) ''' #Return an output dict return {"HookingIsBool":True}