def do_derive(self): #Debug ''' print('self.DoClass is ',self.DoClass) print('') ''' #alias DoClass=self.DoClass #Link self.DerivedModule=sys.modules[DoClass.__module__] #set if len(DoClass.__bases__)>0: #set the DerivedBaseClas DerivedBaseClass=DoClass.__bases__[0] #Debug ''' print('l. 83 Deriver') print('We can set derived bases for the parent') print('DerivedBaseClass is ',DerivedBaseClass) print('') ''' #Append to the parent class if hasattr(DerivedBaseClass,'DerivedClassesList'): DerivedBaseClass.DerivedClassesList.append(DoClass) elif DerivedBaseClass!=object: DerivedBaseClass.DerivedClassesList=[DoClass] #Add to the KeyStrsList DoClass.KeyStrsList+=SYS.getKeyStrsListWithClass(DoClass)
def getReprStr(self,**_KwargVariablesDict): #Debug ''' print('l 741 getReprStr') print('_KwargVariablesDict is ') print(_KwargVariablesDict) print('') ''' #debug ''' _Variable.debug(('_Variable.__class__',self.__class__,[ 'PrintingKeyStrsList', 'DefaultBaseKeyStrsList', 'DefaultSpecificKeyStrsList', 'PrintedNotSpecificKeyStrsList' ])) ''' #/###################/# # Print the Default Key Strs... form the Instance or the still the Class # #Debug ''' print('Printer l 846') print('self.PrintingInstanceSkipKeyStrsList is ') print(self.PrintingInstanceSkipKeyStrsList) print('') ''' #Check if self.PrintingClassSkipKeyStrsList==None: self.PrintingClassSkipKeyStrsList=[] if self.PrintingInstanceSkipKeyStrsList==None: self.PrintingInstanceSkipKeyStrsList=[] #filter the skip key strs PrintedDefaultSpecificKeyStrsList=SYS._filter( lambda __DefaultSpecificKeyStr: __DefaultSpecificKeyStr not in list( self.PrintingInstanceSkipKeyStrsList )+list( self.PrintingClassSkipKeyStrsList), self.__class__.DefaultSpecificKeyStrsList ) #Represent the Specific KeyStrs PrintTuplesList=map( lambda __SpecificKeyStr: ( "<Spe>"+("<Instance>" if __SpecificKeyStr in self.__dict__ else ( "<Instance>_" if hasattr( self.__class__,__SpecificKeyStr ) and type(getattr( self.__class__,__SpecificKeyStr ))==property and getattr( self.__class__,'_'+__SpecificKeyStr )!=getattr(self,'_'+__SpecificKeyStr) and ( '_'+__SpecificKeyStr not in self.PrintingClassSkipKeyStrsList and __SpecificKeyStr not in self.PrintingInstanceSkipKeyStrsList ) else "<Class>" ) )+__SpecificKeyStr, getattr(self,__SpecificKeyStr) ), PrintedDefaultSpecificKeyStrsList ) #/###################/# # Print the Default Base Key Strs... form the Instance or the still the Class # #Represent the BaseKeyStrs if self.PrintingBaseBool: #Debug ''' print('Printer l 723') print('We print the bases') print('self.__class__.DefaultBaseKeyStrsList is ') print(self.__class__.DefaultBaseKeyStrsList) print('') ''' #filter remove PrintedDefaultBaseKeyStrsList=SYS._filter( lambda __DefaultSpecificKeyStr: __DefaultSpecificKeyStr not in list( self.PrintingInstanceSkipKeyStrsList )+list(self.PrintingClassSkipKeyStrsList), self.__class__.DefaultBaseKeyStrsList ) #filter add if self.PrintingInstanceForceBaseKeyStrsList!=None: #add PrintedDefaultBaseKeyStrsList+=self.PrintingInstanceForceBaseKeyStrsList #map PrintTuplesList+=map( lambda __BaseKeyStr: ( "<Base>"+("<Instance>" if __BaseKeyStr in self.__dict__ else "<Class>" )+__BaseKeyStr , getattr(self,__BaseKeyStr) ), PrintedDefaultBaseKeyStrsList ) #/###################/# # Print the New key strs in the instance # #print the NewInstanceKeyStrs in the __dict__ if self.PrintingNewInstanceBool: #filter PrintedNewInstanceTuplesList=SYS._filter( lambda __NewItemTuple: __NewItemTuple[0 ] not in self.__class__.DefaultSpecificKeyStrsList+self.__class__.DefaultBaseKeyStrsList, self.__dict__.items() ) #filter PrintedNewInstanceTuplesList=SYS._filter( lambda __PrintedNewInstanceTuple: __PrintedNewInstanceTuple[0] not in list( self.PrintingInstanceSkipKeyStrsList)+list( self.PrintingClassSkipKeyStrsList), PrintedNewInstanceTuplesList ) #map PrintTuplesList+=map( lambda __NewItemTuple: ( "<New><Instance>"+__NewItemTuple[0], __NewItemTuple[1] ), PrintedNewInstanceTuplesList ) #/###################/# # Print the New key strs in the class # #Represent the NewClassKeyStrs in the _self.__class____.__dict__ if self.PrintingNewClassBool: #filter PrintedNewClassKeyStrsList=SYS._filter( lambda __KeyStr: __KeyStr not in self.__class__.KeyStrsList and __KeyStr not in self.__dict__, SYS.getKeyStrsListWithClass( self.__class__ ) ) #filter PrintedNewClassKeyStrsList=SYS._filter( lambda __NewClassKeyStr: __NewClassKeyStr not in list( self.PrintingInstanceSkipKeyStrsList)+list( self.PrintingClassSkipKeyStrsList), PrintedNewClassKeyStrsList ) #filter PrintTuplesList+=map( lambda __NewKeyStr: ( "<New><Class>"+__NewKeyStr, self.__class__.__dict__[__NewKeyStr] ), PrintedNewClassKeyStrsList ) #/###################/# # Print force key strs # #Debug ''' print('Printer l 811') print('We add some forced Key Strs') print('') ''' #Check if self.PrintingInstanceForceKeyStrsList==None: self.PrintingInstanceForceKeyStrsList=[] #map PrintTuplesList+=map( lambda __PrintingKeyStr: ( "<Spe><Instance>"+__PrintingKeyStr, self.__dict__[__PrintingKeyStr] ) if __PrintingKeyStr in self.__dict__ and __PrintingKeyStr in self.__class__.DefaultSpecificKeyStrsList else( ( "<Base><Instance>"+__PrintingKeyStr, self.__dict__[__PrintingKeyStr] ) if __PrintingKeyStr in self.__dict__ and __PrintingKeyStr in self.__class__.DefaultBaseKeyStrsList else ( ( "<Base><Class>"+__PrintingKeyStr, getattr(self,__PrintingKeyStr) ) if __PrintingKeyStr not in self.__dict__ else ( "<New><Instance>"+__PrintingKeyStr, self.__dict__[__PrintingKeyStr] ) ) ), list( self.PrintingInstanceForceKeyStrsList )+list(self.PrintingClassForceKeyStrsList) ) #Append global PrintAlreadyIdIntsList #debug ''' print('Printer l.629') print('id(self) is ',id(self)) print('self not in PrintAlreadyIdIntsList is ',str( self not in PrintAlreadyIdIntsList)) print('') ''' #define the PrintStr self.PrintStr=getPointerStr( self, **_KwargVariablesDict )+getPrintStr( dict(PrintTuplesList), **_KwargVariablesDict ) #return return self.PrintStr
def __call__(self,_Class): #/###################/# # Set the NameStr, Module, SelfClass... # #get self.Module=sys.modules[_Class.__module__] #debug ''' print('Classor l.53 __call__ method') print('_Class is ',_Class) print('') ''' #set in the class the classed Strs _Class.NameStr=SYS.getNameStrWithClassStr(_Class.__name__) #Give a Pointer to the Hooker setattr(_Class,'DeriveClassor',self) #set to the SYS the module if len(SYS.NameStrsList)==0: setattr(SYS,self.NameStr,sys.modules[self.__class__.__module__]) setattr(SYS,self.__class__.__name__,self.__class__) SYS.NameStrsList.append(self.NameStr) setattr(SYS,_Class.NameStr,self.Module) setattr(SYS,_Class.__name__,_Class) SYS.NameStrsList.append(_Class.NameStr) #get the module and set it to the class _Class.Module=self.Module _Class.Module.LocalFolderPathStr=SYS.PythonlogyLocalFolderPathStr+self.Module.__name__.replace( '.','/')+'/' #set a pointer to itself _Class.SelfClass=_Class _Class.MroClassesList=_Class.__mro__ _Class.MroClassesDict=dict( map( lambda __Class: (__Class.__name__,__Class), _Class.__mro__ ) ) #Check if hasattr(_Class,'callAllMro')==False: setattr( _Class, callAllMro.__name__, callAllMro ) setattr( _Class, setAllMro.__name__, setAllMro ) setattr( _Class, mapSetAllMro.__name__, mapSetAllMro ) setattr( _Class, getClass.__name__, getClass ) #add in LocalModuleFolderPathStrAndModuleStrTuplesList global LocalModuleFolderPathStrAndModuleStrTuplesList LocalModuleFolderPathStrAndModuleStrTuplesList.append( ( _Class.Module.LocalFolderPathStr, _Class.Module.__name__ ) ) #/###################/# # Give ref to the concept module # #append ConceptModuleStr='.'.join(_Class.Module.__name__.split('.')[:-1]) if hasattr(_Class,"ConceptModuleStr")==False or _Class.ConceptModuleStr!=ConceptModuleStr: #set _Class.ConceptModuleStr=ConceptModuleStr #append LocalModuleFolderPathStrAndModuleStrTuplesList.append( ( SYS.PythonlogyLocalFolderPathStr+ConceptModuleStr.replace('.','/')+'/', ConceptModuleStr ) ) #/###################/# # Alert the base method that a derive object exists # #set if len(_Class.__bases__)>0: #set the DerivedBaseClas FirstBaseClass=_Class.__bases__[0] #Debug ''' print('l. 183 Classor') print('We can set derived bases for the base') print('FirstBaseClass is ',FirstBaseClass) print('') ''' #Append to the parent class if hasattr(FirstBaseClass,'DeriveClassesList'): FirstBaseClass.DeriveClassesList.append(_Class) elif FirstBaseClass!=object: FirstBaseClass.DeriveClassesList=[_Class] #/###################/# # Inspect the methods # #Get the Methods _Class.InspectMethodDict=SYS.MethodDict(_Class) #dict _Class.InspectInspectDict=dict( map( lambda __MethodItemTuple: ( __MethodItemTuple[0], SYS.InspectDict( __MethodItemTuple[1] ) ), _Class.InspectMethodDict.items() ) ) #/###################/# # set the KeyStrsList # #set the KeyStrsList _Class.KeyStrsList=SYS.getKeyStrsListWithClass(_Class)+['KeyStrsList'] #/###################/# # alias # self.WrapClass=_Class #Return return _Class