Conditioner

Doc


The Conditioner


View the Conditioner notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Conditioner.ipynb)

Code



# -*- coding: utf-8 -*-
"""


<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>


The Conditioner

"""


#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Objects.Debugger"
DecorationModuleStr="ShareYourSystem.Classors.Representer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
Representer=DecorationModule
#</ImportSpecificModules>

#<DefineClass>
@DecorationClass()
class ConditionerClass(BaseClass):

    #Definition
    RepresentingKeyStrsList=[
                                    'ConditioningTestVariable',
                                    'ConditioningGetBoolFunction',
                                    'ConditionedIsBool'
                                ]

    def default_init(self,
                        _ConditioningTestVariable=None,
                        _ConditioningGetBoolFunction=None,
                        _ConditioningAttestVariable=None,
                        _ConditionedIsBool=True,
                        **_KwargVariablesDict
                    ):

        #Call the parent init method
        BaseClass.__init__(self,**_KwargVariablesDict)

    #<DefineDoMethod>   
    def do_condition(self):

        #debug
        '''
        self.debug(('self.',self,[
                                    'ConditioningTestVariable',
                                    'ConditioningAttestVariable'
                                ]))
        '''

        #call
        self.ConditionedIsBool=self.ConditioningGetBoolFunction(
            self.ConditioningTestVariable,
            self.ConditioningAttestVariable
        )

        #debug
        '''
        self.debug(('self.',self,['ConditionedIsBool']))
        '''

#</DefineClass>

View the Conditioner sources on Github

Example

Let's create an empty class, which will automatically receive special attributes from the decorating ClassorClass, specially the NameStr, that should be the ClassStr without the TypeStr in the end.


In [3]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Classors import Attester
from ShareYourSystem.Objects import Conditioner

#Definition of an instance Conditioner and make it print hello
MyConditioner=Conditioner.ConditionerClass(**{
        'ConditioningGetBoolFunction':lambda _TestVariable,_AttestVariable:_TestVariable==_AttestVariable,
        'ConditioningAttestVariable':2
    })
MyConditioner.condition(3).ConditionedIsBool
    
#Definition the AttestedStr
SYS._attest(
                    [
                        'MyConditioner.condition(3).ConditionedIsBool is '+str(
                            MyConditioner.condition(3).ConditionedIsBool),
                        'MyConditioner.condition(2).ConditionedIsBool is '+str(
                            MyConditioner.condition(2).ConditionedIsBool)
                    ]
                ) 

#Print



*****Start of the Attest *****

MyConditioner.condition(3).ConditionedIsBool is False

------

MyConditioner.condition(2).ConditionedIsBool is True

*****End of the Attest *****