# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
The Rebooter
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Objects.Concluder"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
import collections
import copy
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class RebooterClass(BaseClass):
    #Definition
    RepresentingKeyStrsList=[
        'RebootingDoStrsList',
        'RebootingNameStrsList',
        'RebootingAllDoBool',
        'RebootingAllNameBool',
        'RebootingDoingIsBool',
        'RebootedWatchBoolKeyStrsList',
        'RebootingSetDoIsBool'
    ]
    def default_init(self,
                        _RebootingNameStrsList=None,
                        _RebootingDoStrsList=None,
                        _RebootingAllNameBool=True,
                        _RebootingAllDoBool=True,
                        _RebootingSetDoIsBool=True,
                        _RebootedWatchBoolKeyStrsList=None,
                        **_KwargVariablesDict
                    ):
        #Call the parent __init__ method
        BaseClass.__init__(self,**_KwargVariablesDict)
    def do_reboot(self):
        #set
        if self.RebootingAllNameBool:
            #filter
            self.RebootingNameStrsList=SYS.filterNone(
                map(
                    lambda __MroClass:
                    __MroClass.NameStr 
                    if hasattr(__MroClass,'DoStr')
                    else None,
                    self.__class__.__mro__
                )
            )
        #set
        if self.RebootingAllDoBool:
            #filter
            self.RebootingDoStrsList=SYS.filterNone(
                map(
                    lambda __MroClass:
                    __MroClass.DoStr 
                    if hasattr(__MroClass,'DoStr')
                    else None,
                    self.__class__.__mro__
                )
            )
        #debug
        '''
        self.debug(
                    ('self.',self,[
                        'RebootingDoStrsList',
                        'RebootingNameStrsList'
                        ])
                )
        '''
        #map
        map(
                lambda __RebootingNameStr:
                self.setSwitch(
                    __RebootingNameStr,
                    self.RebootingDoStrsList
                ),
                self.RebootingNameStrsList
            )
        #Check
        if self.RebootingSetDoIsBool:
            #debug
            '''
            self.debug(('self.',self,['RebootingNameStrsList']))
            '''
            #map
            map(
                    lambda __RebootingClass:
                    self.setDone(
                        __RebootingClass
                    ) 
                    #if hasattr(__RebootingClass,'DoneAttributeVariablesOrderedDict')
                    #else None,
                    ,map(
                            lambda __RebootingClassStr:
                            getattr(
                                SYS,
                                __RebootingClassStr
                            ) 
                            #if hasattr(SYS,__RebootingClassStr)
                            #else None
                            ,map(SYS.getClassStrWithNameStr,self.RebootingNameStrsList)
                        )
                )
#</DefineClass>
View the Rebooter sources on Github
In [3]:
    
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Classors import Classer
from ShareYourSystem.Standards.Objects import Rebooter
#Definition 
@Classer.ClasserClass(**
{
    'ClassingSwitchMethodStrsList':['make']
})
class MakerClass(Rebooter.RebooterClass):
    #Definition
    RepresentingKeyStrsList=[
                                'MakingMyFloat',
                                'MadeMyInt'
                            ]
    def default_init(self,
                    _MakingMyFloat=0.,
                    _MadeMyInt=0,
                    **_KwarVariablesDict
                ):
        Rebooter.RebooterClass.__init__(self,**_KwarVariablesDict)
    def do_make(self):
    
        #print
        print('I am in the do_make of the Maker')
        #cast
        self.MadeMyInt=int(self.MakingMyFloat)
#Definition
@Classer.ClasserClass(**{
    'ClassingSwitchMethodStrsList':["make"]
})
class BuilderClass(MakerClass):
    #Definition
    RepresentingKeyStrsList=[
                            ]
    def default_init(self,
                    **_KwarVariablesDict
                ):
        MakerClass.__init__(self,**_KwarVariablesDict)
    def mimic_make(self):
    
        #print
        print('I am in the mimic_make of the Builder')
        #call the parent method
        MakerClass.make(self)
        #cast
        self.MadeMyInt+=10
    def do_build(self):
        pass
#Definition an instance
MyBuilder=BuilderClass()
#Print
print('Before make, MyBuilder is ')
SYS._print(MyBuilder,**{
    'RepresentingKeyStrsList':[
    'MakingMyFloat',
    'MadeMyInt',
    ]
})
#make once
MyBuilder.make(3.)
#Print
print('After the first make, MyBuilder is ')
SYS._print(MyBuilder,**{
    'RepresentingKeyStrsList':[
    'MakingMyFloat',
    'MadeMyInt',
    ]
})
#make again
MyBuilder.make(5.)
#Print
print('After the second make, MyBuilder is ')
SYS._print(MyBuilder,**{
    'RepresentingKeyStrsList':[
    'MakingMyFloat',
    'MadeMyInt',
    ]
})
#make again
print('Now we reboot')
MyBuilder.reboot(
                    #_NameStrsList=['Maker','Builder'],
                    #_DoStrsList=['Make'],
                    #_AllDoBool=True,
                    #_AllNameBool=True,
                )
#Print
print('After the reboot, MyBuilder is ')
SYS._print(MyBuilder,**{
    'RepresentingKeyStrsList':[
    'MakingMyFloat',
    'MadeMyInt',
    ]
})
#make again
MyBuilder.make(8.)
#Definition the AttestedStr
SYS._attest(
    [
        'MyBuilder is '+SYS._str(
        MyBuilder,
        **{
            'RepresentingAlineaIsBool':False,
            'RepresentingKeyStrsList':[
                'MakingMyFloat',
                'MadeMyInt',
                'RebootedWatchBoolKeyStrsList'
            ]
            }
        )
    ]
)