Walker

Doc


A Parenter completes the list of grand-parent nodes that a child node could have. It is a recursive top-down set of the pointers and the pathStrs.


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

Code



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


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


A Parenter completes the list of grand-parent nodes that 
a child node could have. It is a recursive top-down set
of the pointers and the pathStrs.

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Applyiers.Commander"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
import collections
from ShareYourSystem.Functers import Argumenter
#</ImportSpecificModules>

#<DefineLocals>
WalkingStr="zz"
#</DefineLocals>

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

    #Definition
    RepresentingKeyStrsList=[
                                    'WalkingSocketDict',
                                    #'WalkedOrderedDict',
                                    #'WalkedTopOrderedDict'
                                ]

    def default_init(self,
                _WalkingSocketDict=None,
                _WalkedOrderedDict=None,
                _WalkedTopOrderedDict=None,
                **_KwargVariablesDict
            ):

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

    def do_walk(self):

        #Init the WalkedTopOrderedDict
        WalkedTopOrderedDict=None
        if 'IdStr' not in self.WalkingSocketDict:

            #Definition the IdStr of this walk
            IdStr=str(id(self.WalkingSocketDict))

            #set the _WalkingSocketDict
            self.WalkingSocketDict.update(
                                    {
                                        'IdStr':IdStr,
                                        'TopVariable':self,
                                    }
                                )

            #Definition WalkedTopOrderedSetTagStr
            WalkedTopOrderedSetTagStr='Walked'+WalkingStr+IdStr+WalkingStr+'OrderedDict'

            #set the corresponding WalkedOrderedDict
            self.__setattr__(
                                WalkedTopOrderedSetTagStr,
                                collections.OrderedDict(**
                                    {
                                        'IndexInt':-1,
                                        'TopIntsList':['/'],
                                        'TopVariablesList':[self]
                                    }
                                )
                            )

            #Alias this Dict
            self.WalkedTopOrderedDict=getattr(
                self,
                WalkedTopOrderedSetTagStr
            )

        else:

            #Get the information at the top
            WalkedTopOrderedSetTagStr='Walked'+WalkingStr+self.WalkingSocketDict['IdStr']+WalkingStr+'OrderedDict'
            self.WalkedTopOrderedDict=getattr(
                self.WalkingSocketDict['TopVariable'],
                WalkedTopOrderedSetTagStr
            )
            self.WalkedTopOrderedDict['IndexInt']+=1
            self.WalkedTopOrderedDict['TopIntsList']+=[str(
                self.WalkedTopOrderedDict['IndexInt'])]
            self.WalkedTopOrderedDict['TopVariablesList']+=[self]

        #An Update just before is possible
        if 'BeforeUpdateList' in self.WalkingSocketDict:

            #debug
            '''
            self.debug(('_SocketDict',_SocketDict,['BeforeUpdateList']))
            '''

            #Update
            self.update(self.WalkingSocketDict['BeforeUpdateList'])

        #Debug
        '''
        self.debug(('self.',self,['WalkingSocketDict']))
        '''

        #Command an recursive order in other gathered variables
        self.command(
                        _UpdateList=[
                            ('walk',{
                                        'LiargVariablesList':[self.WalkingSocketDict],
                                    }
                            )
                        ],
                        **{
                            'GatheringVariablesList':self.WalkingSocketDict[
                                'GatherVariablesList'
                            ]
                        }
                    )

        #An Update just after is possible
        if 'AfterUpdateList' in self.WalkingSocketDict:
            self.update(self.WalkingSocketDict[
                'AfterUpdateList'])

        #Retrieve the previous Path
        if len(self.WalkedTopOrderedDict['TopIntsList'])>0:
            self.WalkedTopOrderedDict['TopIntsList']=self.WalkedTopOrderedDict[
            'TopIntsList'][:-1] 
            self.WalkedTopOrderedDict['TopVariablesList']=self.WalkedTopOrderedDict[
            'TopVariablesList'][:-1]

        #Return self
        if self.WalkingSocketDict['TopVariable']==self:
            self.WalkedOrderedDict=WalkedTopOrderedDict
            del self[WalkedTopOrderedSetTagStr]
            return self
#</DefineClass>

View the Walker 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.Standards.Walkers import Walker

#Definition a Walker instance with a noded tree
MyWalker=Walker.WalkerClass().update(
    [
        (
            '<Tree>FirstChildWalker',
            Walker.WalkerClass().update(
                [
                    (
                        '<Tree>GrandChildWalker',
                        Walker.WalkerClass()
                    )
                ]
            )
        ),
        (
            '<Tree>SecondChildWalker',
            Walker.WalkerClass()
        )
    ]
)

#Walk inside the Tree in order to parent again because the tree was not yet completely setted when it was done
MyWalker.walk(
            {
                'BeforeUpdateList':
                [
                    ('SwitchingParentBool',False),
                    ('parent',{'LiargVariablesList':['Tree']})
                ],
                'GatherVariablesList':['<Tree>']
            }
        )


#Definition the AttestedStr
SYS._attest(
    [
        'MyWalker is '+SYS._str(
        MyWalker,
        **{
            'RepresentingBaseKeyStrsListBool':False,
            'RepresentingAlineaIsBool':False,
            'RepresentingKeyStrsList':['ParentedDeriveParentersList']
        }
        )
    ]
) 

#Print



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

MyWalker is < (WalkerClass), 4559758160>
   /{ 
   /  '<New><Instance>IdInt' : 4559758160
   /  '<New><Instance>NodeCollectionStr' : Globals
   /  '<New><Instance>NodeIndexInt' : -1
   /  '<New><Instance>NodeKeyStr' : TopWalker
   /  '<New><Instance>NodePointDeriveNoder' : None
   /  '<New><Instance>NodePointOrderedDict' : None
   /  '<New><Instance>SwitchingParentBool' : False
   /  '<New><Instance>TreeCollectionOrderedDict' : 
   /   /{ 
   /   /  'FirstChildWalker' : < (WalkerClass), 4559757840>
   /   /   /{ 
   /   /   /  '<New><Instance>IdInt' : 4559757840
   /   /   /  '<New><Instance>NodeCollectionStr' : Tree
   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /  '<New><Instance>NodeKeyStr' : FirstChildWalker
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (WalkerClass), 4559758160>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559764448>
   /   /   /  '<New><Instance>SwitchingParentBool' : False
   /   /   /  '<New><Instance>TreeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /  'GrandChildWalker' : < (WalkerClass), 4559758224>
   /   /   /   /   /{ 
   /   /   /   /   /  '<New><Instance>IdInt' : 4559758224
   /   /   /   /   /  '<New><Instance>NodeCollectionStr' : Tree
   /   /   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /   /   /  '<New><Instance>NodeKeyStr' : GrandChildWalker
   /   /   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (WalkerClass), 4559757840>
   /   /   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559711200>
   /   /   /   /   /  '<New><Instance>SwitchingParentBool' : False
   /   /   /   /   /  '<New><Instance>TreeCollectionOrderedDict' : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /}
   /   /   /   /   /  '<Spe><Instance>ParentedDeriveParentersList' : 
   /   /   /   /   /   /[
   /   /   /   /   /   /  0 : {...}< (WalkerClass), 4559757840>
   /   /   /   /   /   /  1 : {...}< (WalkerClass), 4559758160>
   /   /   /   /   /   /]
   /   /   /   /   /  '<Spe><Instance>WalkingSocketDict' : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /  'BeforeUpdateList' : 
   /   /   /   /   /   /   /[
   /   /   /   /   /   /   /  0 : 
   /   /   /   /   /   /   /   /(
   /   /   /   /   /   /   /   /  0 : SwitchingParentBool
   /   /   /   /   /   /   /   /  1 : False
   /   /   /   /   /   /   /   /)
   /   /   /   /   /   /   /  1 : 
   /   /   /   /   /   /   /   /(
   /   /   /   /   /   /   /   /  0 : parent
   /   /   /   /   /   /   /   /  1 : 
   /   /   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /   /   /  'LiargVariablesList' : ['Tree']
   /   /   /   /   /   /   /   /   /}
   /   /   /   /   /   /   /   /)
   /   /   /   /   /   /   /]
   /   /   /   /   /   /  'GatherVariablesList' : ['<Tree>']
   /   /   /   /   /   /  'IdStr' : 4559717552
   /   /   /   /   /   /  'TopVariable' : {...}< (WalkerClass), 4559758160>
   /   /   /   /   /   /}
   /   /   /   /   /}
   /   /   /   /}
   /   /   /  '<Spe><Instance>ParentedDeriveParentersList' : 
   /   /   /   /[
   /   /   /   /  0 : {...}< (WalkerClass), 4559758160>
   /   /   /   /]
   /   /   /  '<Spe><Instance>WalkingSocketDict' : {...}< (dict), 4559717552>
   /   /   /}
   /   /  'SecondChildWalker' : < (WalkerClass), 4559758544>
   /   /   /{ 
   /   /   /  '<New><Instance>IdInt' : 4559758544
   /   /   /  '<New><Instance>NodeCollectionStr' : Tree
   /   /   /  '<New><Instance>NodeIndexInt' : 1
   /   /   /  '<New><Instance>NodeKeyStr' : SecondChildWalker
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (WalkerClass), 4559758160>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559764448>
   /   /   /  '<New><Instance>SwitchingParentBool' : False
   /   /   /  '<New><Instance>TreeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<Spe><Instance>ParentedDeriveParentersList' : 
   /   /   /   /[
   /   /   /   /  0 : {...}< (WalkerClass), 4559758160>
   /   /   /   /]
   /   /   /  '<Spe><Instance>WalkingSocketDict' : {...}< (dict), 4559717552>
   /   /   /}
   /   /}
   /  '<Spe><Instance>ParentedDeriveParentersList' : []
   /  '<Spe><Instance>WalkingSocketDict' : {...}< (dict), 4559717552>
   /}

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


Cumulater

Doc


A Cumulater pick and


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

Code



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


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


A Cumulater pick and 

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Walkers.Walker"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
import copy

#</ImportSpecificModules>

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

    #Definition
    RepresentingKeyStrsList=[
                                'CumulatedVariablesList'
                            ]

    def default_init(self,
                _CumulatedVariablesList=None,
                **_KwargVariablesDict):

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

    def do_cumulate(self):

        #debug
        '''
        self.debug(('self.',self,[
                                    'WalkingSocketDict',
                                    'WalkedTopOrderedDict'
                                ]))
        ''' 

        #Init
        if 'CumulateVariablesList' not in self.WalkedTopOrderedDict:
            self.WalkedTopOrderedDict['CumulateVariablesList']=[]


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

        #Check
        self.WalkedTopOrderedDict['CumulateVariablesList'].append(
            self.filter('/').FilteredVariablesList
        )

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

        #set
        if self.WalkingSocketDict['TopVariable']==self:
            self.CumulatedVariablesList=self.WalkedTopOrderedDict['CumulateVariablesList']
            #self.CumulatedVariablesList=copy.copy(self.WalkedTopOrderedDict['CumulateVariablesList'])


#</DefineClass>

View the Cumulater sources on Github


In [6]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Walkers import Cumulater
import operator

#Definition a Filter instance that is grouped
MyCumulater=Cumulater.CumulaterClass().update(
        [
            (
                '<Filterome>FirstChildCumulater',
                Cumulater.CumulaterClass().update(
                    [
                        (
                            '<Filterome>GrandChildFilter',
                            Cumulater.CumulaterClass()
                        )
                    ]
                )
            ),
            (
                '<Filterome>SecondChildFilter',
                Cumulater.CumulaterClass()
            ),
            (
                '<Filterome>ThirdChildFilter',
                Cumulater.CumulaterClass()
            )
        ]
    )

#Walk inside the group in order to parent
MyCumulater.walk(
            {
                'BeforeUpdateList':
                [
                    (
                        'ConcludingConditionVariable',[
                            (
                                'NodeIndexInt',
                                lambda _TestInt,_AttestInt:
                                    operator.lt(_TestInt,_AttestInt) and operator.lt(-1,_TestInt)
                                    if _TestInt!=None else False,
                                2
                            )
                        ]
                    ),
                    (
                        'PickingKeyVariablesList',['NodeKeyStr']
                    ),
                    ('cumulate',{'LiargVariablesList':[]})
                ],
                'GatherVariablesList':['<Filterome>']
            }
        )
    
#Definition the AttestedStr
SYS._attest(
    [
        'MyCumulater is '+SYS._str(
        MyCumulater,
        **{
            'RepresentingBaseKeyStrsListBool':False,
            'RepresentingAlineaIsBool':False
        }
        )
    ]
) 

#Print



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

MyCumulater is < (CumulaterClass), 4559707664>
   /{ 
   /  '<New><Instance>FilteromeCollectionOrderedDict' : 
   /   /{ 
   /   /  'FirstChildCumulater' : < (CumulaterClass), 4559707600>
   /   /   /{ 
   /   /   /  '<New><Instance>FilteromeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /  'GrandChildFilter' : < (CumulaterClass), 4559707472>
   /   /   /   /   /{ 
   /   /   /   /   /  '<New><Instance>FilteromeCollectionOrderedDict' : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /}
   /   /   /   /   /  '<New><Instance>IdInt' : 4559707472
   /   /   /   /   /  '<New><Instance>NodeCollectionStr' : Filterome
   /   /   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /   /   /  '<New><Instance>NodeKeyStr' : GrandChildFilter
   /   /   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (CumulaterClass), 4559707600>
   /   /   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559711496>
   /   /   /   /   /  '<Spe><Instance>CumulatedVariablesList' : []
   /   /   /   /   /}
   /   /   /   /}
   /   /   /  '<New><Instance>IdInt' : 4559707600
   /   /   /  '<New><Instance>NodeCollectionStr' : Filterome
   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /  '<New><Instance>NodeKeyStr' : FirstChildCumulater
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (CumulaterClass), 4559707664>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559763264>
   /   /   /  '<Spe><Instance>CumulatedVariablesList' : []
   /   /   /}
   /   /  'SecondChildFilter' : < (CumulaterClass), 4559705424>
   /   /   /{ 
   /   /   /  '<New><Instance>FilteromeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<New><Instance>IdInt' : 4559705424
   /   /   /  '<New><Instance>NodeCollectionStr' : Filterome
   /   /   /  '<New><Instance>NodeIndexInt' : 1
   /   /   /  '<New><Instance>NodeKeyStr' : SecondChildFilter
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (CumulaterClass), 4559707664>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559763264>
   /   /   /  '<Spe><Instance>CumulatedVariablesList' : []
   /   /   /}
   /   /  'ThirdChildFilter' : < (CumulaterClass), 4559705808>
   /   /   /{ 
   /   /   /  '<New><Instance>FilteromeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<New><Instance>IdInt' : 4559705808
   /   /   /  '<New><Instance>NodeCollectionStr' : Filterome
   /   /   /  '<New><Instance>NodeIndexInt' : 2
   /   /   /  '<New><Instance>NodeKeyStr' : ThirdChildFilter
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (CumulaterClass), 4559707664>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559763264>
   /   /   /  '<Spe><Instance>CumulatedVariablesList' : []
   /   /   /}
   /   /}
   /  '<New><Instance>IdInt' : 4559707664
   /  '<New><Instance>NodeCollectionStr' : Globals
   /  '<New><Instance>NodeIndexInt' : -1
   /  '<New><Instance>NodeKeyStr' : TopCumulater
   /  '<New><Instance>NodePointDeriveNoder' : None
   /  '<New><Instance>NodePointOrderedDict' : None
   /  '<Spe><Instance>CumulatedVariablesList' : 
   /   /[
   /   /  0 : []
   /   /  1 : ['FirstChildCumulater']
   /   /  2 : ['GrandChildFilter']
   /   /  3 : ['SecondChildFilter']
   /   /  4 : []
   /   /]
   /}

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


Visiter

Doc


A Visiter


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

Code



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


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


A Visiter

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Walkers.Cumulater"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>

from ShareYourSystem.Standards.Noders import Noder
#</ImportSpecificModules>

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

    #Definition
    RepresentingKeyStrsList=[
                                    'VisitingCollectionStrsList',
                                    'VisitingBeforeUpdateList',
                                    'VisitingAfterUpdateList'
                                ]

    def default_init(self,
                _VisitingCollectionStrsList=None,
                _VisitingBeforeUpdateList=None,
                _VisitingAfterUpdateList=None,
                **_KwargVariablesDict
            ):

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

    def do_visit(self):

        #Walk inside the group in order to parent
        self.walk(
                    {
                        'BeforeUpdateList':self.VisitingBeforeUpdateList,
                        'AfterUpdateList':self.VisitingAfterUpdateList,
                        'GatherVariablesList':map(
                                lambda __NodeCollectionStr:
                                Noder.NodingPrefixGetStr+__NodeCollectionStr+Noder.NodingSuffixGetStr,
                                self.VisitingCollectionStrsList
                            )
                    }
                )


#</DefineClass>

View the Visiter sources on Github


In [9]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Walkers import Cumulater,Visiter

#Definition a Visiter instance that is grouped
MyVisiter=Visiter.VisiterClass().update(
    [
        (
            '<Visitome>FirstChildVisiter',
            Visiter.VisiterClass().update(
                [
                    (
                        '<Collectome>GrandChildCumulater',
                        Cumulater.CumulaterClass()
                    )
                ]
            )
        ),
        (
            '<Visitome>SecondChildVisiter',
            Visiter.VisiterClass()
        )
    ]
)

#Walk inside the group in order to parent
MyVisiter.visit(['Visitome','Collectome'],[('TagStr','Je suis passe par la')])
    
#Definition the AttestedStr
SYS._attest(
    [
        'MyVisiter is '+SYS._str(
        MyVisiter,
        **{
            'RepresentingBaseKeyStrsListBool':False,
            'RepresentingAlineaIsBool':False
        }
        )
    ]
) 

#Print



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

MyVisiter is < (VisiterClass), 4559653264>
   /{ 
   /  '<New><Instance>CollectomeCollectionOrderedDict' : 
   /   /{ 
   /   /}
   /  '<New><Instance>IdInt' : 4559653264
   /  '<New><Instance>NodeCollectionStr' : Globals
   /  '<New><Instance>NodeIndexInt' : -1
   /  '<New><Instance>NodeKeyStr' : TopVisiter
   /  '<New><Instance>NodePointDeriveNoder' : None
   /  '<New><Instance>NodePointOrderedDict' : None
   /  '<New><Instance>TagStr' : Je suis passe par la
   /  '<New><Instance>VisitomeCollectionOrderedDict' : 
   /   /{ 
   /   /  'FirstChildVisiter' : < (VisiterClass), 4559707152>
   /   /   /{ 
   /   /   /  '<New><Instance>CollectomeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /  'GrandChildCumulater' : < (CumulaterClass), 4559759696>
   /   /   /   /   /{ 
   /   /   /   /   /  '<New><Instance>CollectomeCollectionOrderedDict' : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /}
   /   /   /   /   /  '<New><Instance>IdInt' : 4559759696
   /   /   /   /   /  '<New><Instance>NodeCollectionStr' : Collectome
   /   /   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /   /   /  '<New><Instance>NodeKeyStr' : GrandChildCumulater
   /   /   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (VisiterClass), 4559707152>
   /   /   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559762672>
   /   /   /   /   /  '<New><Instance>TagStr' : Je suis passe par la
   /   /   /   /   /  '<New><Instance>VisitomeCollectionOrderedDict' : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /}
   /   /   /   /   /  '<Spe><Class>CumulatedVariablesList' : None
   /   /   /   /   /}
   /   /   /   /}
   /   /   /  '<New><Instance>IdInt' : 4559707152
   /   /   /  '<New><Instance>NodeCollectionStr' : Visitome
   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /  '<New><Instance>NodeKeyStr' : FirstChildVisiter
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (VisiterClass), 4559653264>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559761784>
   /   /   /  '<New><Instance>TagStr' : Je suis passe par la
   /   /   /  '<New><Instance>VisitomeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<Spe><Class>VisitingAfterUpdateList' : None
   /   /   /  '<Spe><Class>VisitingBeforeUpdateList' : None
   /   /   /  '<Spe><Class>VisitingCollectionStrsList' : None
   /   /   /}
   /   /  'SecondChildVisiter' : < (VisiterClass), 4559760080>
   /   /   /{ 
   /   /   /  '<New><Instance>CollectomeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<New><Instance>IdInt' : 4559760080
   /   /   /  '<New><Instance>NodeCollectionStr' : Visitome
   /   /   /  '<New><Instance>NodeIndexInt' : 1
   /   /   /  '<New><Instance>NodeKeyStr' : SecondChildVisiter
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (VisiterClass), 4559653264>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559761784>
   /   /   /  '<New><Instance>TagStr' : Je suis passe par la
   /   /   /  '<New><Instance>VisitomeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<Spe><Class>VisitingAfterUpdateList' : None
   /   /   /  '<Spe><Class>VisitingBeforeUpdateList' : None
   /   /   /  '<Spe><Class>VisitingCollectionStrsList' : None
   /   /   /}
   /   /}
   /  '<Spe><Instance>VisitingAfterUpdateList' : []
   /  '<Spe><Instance>VisitingBeforeUpdateList' : 
   /   /[
   /   /  0 : ('TagStr', 'Je suis passe par la')
   /   /]
   /  '<Spe><Instance>VisitingCollectionStrsList' : ['Visitome', 'Collectome']
   /}

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


Recruiter

Doc


A Recruiter


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

Code



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


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


A Recruiter

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Walkers.Visiter"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>

from ShareYourSystem.Standards.Noders import Noder
#</ImportSpecificModules>

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

    #Definition
    RepresentingKeyStrsList=[
                                    'RecruitingConcludeConditionVariable',
                                    'RecruitedFlatCumulateVariablesList'
                                ]

    def default_init(self,
                _RecruitingConcludeConditionVariable=None,
                _RecruitedFlatCumulateVariablesList=None,
                **_KwargVariablesDict
            ):

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

    def do_recruit(self):

        #Check
        if type(self.VisitingBeforeUpdateList)!=list:
            self.VisitingBeforeUpdateList=[]

        #add
        self.VisitingBeforeUpdateList+=[
            (
                'PickingKeyVariablesList',['/']
            ),
            (
                'ConcludingConditionVariable',
                self.RecruitingConcludeConditionVariable
            ),
            ('cumulate',{'LiargVariablesList':[]})
        ]

        #visit
        self.visit()

        #flat
        self.RecruitedFlatCumulateVariablesList=SYS.filterNone(SYS.flat(
            self.CumulatedVariablesList
            )
        )
#</DefineClass>

View the Recruiter sources on Github


In [12]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Walkers import Cumulater,Recruiter
import operator

#Definition a Recruiter instance that is grouped
MyRecruiter=Recruiter.RecruiterClass().update(
        [
            (
                '<Visitome>FirstChildRecruiter',
                Recruiter.RecruiterClass().update(
                    [
                        (
                            '<Collectome>GrandChildCumulater',
                            Cumulater.CumulaterClass()
                        )
                    ]
                )
            ),
            (
                '<Visitome>SecondChildRecruiter',
                Recruiter.RecruiterClass()
            ),
            (
                '<Visitome>ThirdChildRecruiter',
                Recruiter.RecruiterClass()
            )
        ]
    )

#Walk inside the group in order to parent
MyRecruiter.recruit(
    [
        (
            'NodeIndexInt',
            lambda _TestIndexInt,_AttestIndexInt:operator.lt(_TestIndexInt,_AttestIndexInt)
            if _TestIndexInt!=None else False,
            2
        )
    ],
    **{'VisitingCollectionStrsList':['Visitome','Collectome']}
)
    
#Definition the AttestedStr
SYS._attest(
    [
        'MyRecruiter is '+SYS._str(
        MyRecruiter,
        **{
            'RepresentingBaseKeyStrsListBool':False,
            'RepresentingAlineaIsBool':False
        }
        )
    ]
) 

#Print



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

MyRecruiter is < (RecruiterClass), 4559760336>
   /{ 
   /  '<New><Instance>CollectomeCollectionOrderedDict' : 
   /   /{ 
   /   /}
   /  '<New><Instance>IdInt' : 4559760336
   /  '<New><Instance>NodeCollectionStr' : Globals
   /  '<New><Instance>NodeIndexInt' : -1
   /  '<New><Instance>NodeKeyStr' : TopRecruiter
   /  '<New><Instance>NodePointDeriveNoder' : None
   /  '<New><Instance>NodePointOrderedDict' : None
   /  '<New><Instance>VisitomeCollectionOrderedDict' : 
   /   /{ 
   /   /  'FirstChildRecruiter' : < (RecruiterClass), 4559760464>
   /   /   /{ 
   /   /   /  '<New><Instance>CollectomeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /  'GrandChildCumulater' : < (CumulaterClass), 4559760848>
   /   /   /   /   /{ 
   /   /   /   /   /  '<New><Instance>CollectomeCollectionOrderedDict' : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /}
   /   /   /   /   /  '<New><Instance>IdInt' : 4559760848
   /   /   /   /   /  '<New><Instance>NodeCollectionStr' : Collectome
   /   /   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /   /   /  '<New><Instance>NodeKeyStr' : GrandChildCumulater
   /   /   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (RecruiterClass), 4559760464>
   /   /   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559789616>
   /   /   /   /   /  '<New><Instance>VisitomeCollectionOrderedDict' : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /}
   /   /   /   /   /  '<Spe><Instance>CumulatedVariablesList' : []
   /   /   /   /   /}
   /   /   /   /}
   /   /   /  '<New><Instance>IdInt' : 4559760464
   /   /   /  '<New><Instance>NodeCollectionStr' : Visitome
   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /  '<New><Instance>NodeKeyStr' : FirstChildRecruiter
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (RecruiterClass), 4559760336>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559802448>
   /   /   /  '<New><Instance>VisitomeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<Spe><Class>RecruitedFlatCumulateVariablesList' : None
   /   /   /  '<Spe><Class>RecruitingConcludeConditionVariable' : None
   /   /   /}
   /   /  'SecondChildRecruiter' : < (RecruiterClass), 4559810640>
   /   /   /{ 
   /   /   /  '<New><Instance>CollectomeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<New><Instance>IdInt' : 4559810640
   /   /   /  '<New><Instance>NodeCollectionStr' : Visitome
   /   /   /  '<New><Instance>NodeIndexInt' : 1
   /   /   /  '<New><Instance>NodeKeyStr' : SecondChildRecruiter
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (RecruiterClass), 4559760336>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559802448>
   /   /   /  '<New><Instance>VisitomeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<Spe><Class>RecruitedFlatCumulateVariablesList' : None
   /   /   /  '<Spe><Class>RecruitingConcludeConditionVariable' : None
   /   /   /}
   /   /  'ThirdChildRecruiter' : < (RecruiterClass), 4559810832>
   /   /   /{ 
   /   /   /  '<New><Instance>CollectomeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<New><Instance>IdInt' : 4559810832
   /   /   /  '<New><Instance>NodeCollectionStr' : Visitome
   /   /   /  '<New><Instance>NodeIndexInt' : 2
   /   /   /  '<New><Instance>NodeKeyStr' : ThirdChildRecruiter
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (RecruiterClass), 4559760336>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559802448>
   /   /   /  '<New><Instance>VisitomeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<Spe><Class>RecruitedFlatCumulateVariablesList' : None
   /   /   /  '<Spe><Class>RecruitingConcludeConditionVariable' : None
   /   /   /}
   /   /}
   /  '<Spe><Instance>RecruitedFlatCumulateVariablesList' : 
   /   /[
   /   /  0 : {...}< (RecruiterClass), 4559760336>
   /   /  1 : {...}< (RecruiterClass), 4559760464>
   /   /  2 : {...}< (CumulaterClass), 4559760848>
   /   /  3 : {...}< (RecruiterClass), 4559810640>
   /   /]
   /  '<Spe><Instance>RecruitingConcludeConditionVariable' : 
   /   /[
   /   /  0 : 
   /   /   /(
   /   /   /  0 : NodeIndexInt
   /   /   /  1 : <function <lambda> at 0x10f9ed488>
   /   /   /  2 : 2
   /   /   /)
   /   /]
   /}

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


Mobilizer

Doc


A Mobilizer


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

Code



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


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


A Mobilizer

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Walkers.Recruiter"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
from ShareYourSystem.Standards.Classors import Deriver
from ShareYourSystem.Standards.Noders import Noder
#</ImportSpecificModules>

#<DefineFunctions>
def getMobilizedIsBoolWithParentClassAndDeriveClassesList(
    _ParentClass,_DeriveClassesList):

    #Debug
    '''
    print('Mobilizer l.37')
    print('_ParentClass is ',_ParentClass)
    print('_DeriveClassesList is ',_DeriveClassesList)
    print('')
    '''

    #Return
    return any(
                map(
                    lambda __DeriveClass:
                    Deriver.getIsDerivedBoolWithParentClassAndDeriveClass(
                        _ParentClass,
                        __DeriveClass
                    ),
                    _DeriveClassesList
                )
            )


#<DefineFunctions>

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

    #Definition
    RepresentingKeyStrsList=[
                                    'MobilizingNameStrsList'
                                ]

    def default_init(self,
                _MobilizingNameStrsList=None,
                _MobilizingCollectionSuffixStr="Figurome",
                _MobilizedAttestClassesList=None,
                **_KwargVariablesDict
            ):

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

    def do_mobilize(self):

        #Check
        if self.VisitingCollectionStrsList==None:
            self.VisitingCollectionStrsList=[
                self.CollectingCollectionStr
            ]

        #map
        self.MobilizedAttestClassesList=map(
            SYS.getClassWithNameStr,
            self.MobilizingNameStrsList
        )

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

        #append
        self.RecruitingConcludeConditionVariable.append(
                (
                    '__class__',
                    getMobilizedIsBoolWithParentClassAndDeriveClassesList,
                    self.MobilizedAttestClassesList
                )
            )

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

        #recruit
        self.recruit()

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

        #Split the different names into different collections
        map(
                lambda __RecruitedFlatCollectVariable:
                self.grasp(
                        __RecruitedFlatCollectVariable
                    ).catch(
                        __RecruitedFlatCollectVariable.__class__.NameStr+self.MobilizingCollectionSuffixStr,
                    ),
                self.RecruitedFlatCumulateVariablesList
            )
#</DefineClass>

View the Mobilizer sources on Github


In [15]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Walkers import Visiter,Recruiter,Mobilizer
import operator

#Definition a Mobilizer instance that is grouped
MyMobilizer=Mobilizer.MobilizerClass().update(
    [
        (
            '<Mobilizome>FirstChildMobilizer',
            Mobilizer.MobilizerClass().update(
                [
                    (
                        '<Recruitome>GrandChildRecruiter',
                        Recruiter.RecruiterClass()
                    ),
                    (
                        '<Recruitome>FakeGrandChildVisiter',
                        Visiter.VisiterClass()
                    )
                ]
            )
        ),
        (
            '<Mobilizome>SecondChildMobilizer',
            Mobilizer.MobilizerClass()
        ),
        (
            '<Mobilizome>ThirdChildMobilizer',
            Mobilizer.MobilizerClass()
        )
    ]
)

#Walk inside the group in order to parent
MyMobilizer.mobilize(
    [
        'Mobilizer','Recruiter'
    ],
    **{
            'VisitingCollectionStrsList':['Mobilizome','Recruitome'],
            'RecruitingConcludeConditionVariable':[
            ('NodeIndexInt',lambda _TestInt,_AttestInt:
                _TestInt!=None and operator.lt(_TestInt,_AttestInt),2)
            ]
    }
)
    
#Definition the AttestedStr
SYS._attest(
    [
        'MyMobilizer is '+SYS._str(
        MyMobilizer,
        **{
            'RepresentingBaseKeyStrsListBool':False,
            'RepresentingAlineaIsBool':False
        }
        )
    ]
) 

#Print



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

MyMobilizer is < (MobilizerClass), 4557184912>
   /{ 
   /  '<New><Instance>IdInt' : 4557184912
   /  '<New><Instance>MobilizerFiguromeCollectionOrderedDict' : 
   /   /{ 
   /   /  'TopMobilizer><TopMobilizerPointer' : < (PointerClass), 4559760912>
   /   /   /{ 
   /   /   /  '<New><Instance>IdInt' : 4559760912
   /   /   /  '<New><Instance>CatchToPointVariable' : {...}< (MobilizerClass), 4557184912>
   /   /   /  '<Spe><Class>PointedBackSetStr' : 
   /   /   /  '<Spe><Class>PointedPathBackVariable' : 
   /   /   /  '<Spe><Instance>PointedGetVariable' : {...}< (MobilizerClass), 4557184912>
   /   /   /  '<Spe><Instance>PointedLocalSetStr' : CatchToPointVariable
   /   /   /  '<Spe><Instance>PointingBackSetStr' : 
   /   /   /  '<Spe><Instance>PointingGetVariable' : {...}< (MobilizerClass), 4557184912>
   /   /   /  '<Spe><Instance>PointingSetPathStr' : CatchToPointVariable
   /   /   /}
   /   /  '>UnknowPath<Pointer' : < (PointerClass), 4559704464>
   /   /   /{ 
   /   /   /  '<New><Instance>IdInt' : 4559704464
   /   /   /  '<New><Instance>CatchToPointVariable' : < (MobilizerClass), 4559760400>
   /   /   /   /{ 
   /   /   /   /  '<New><Instance>IdInt' : 4559760400
   /   /   /   /  '<New><Instance>MobilizomeCollectionOrderedDict' : 
   /   /   /   /   /{ 
   /   /   /   /   /}
   /   /   /   /  '<New><Instance>NodeCollectionStr' : Mobilizome
   /   /   /   /  '<New><Instance>NodeIndexInt' : 1
   /   /   /   /  '<New><Instance>NodeKeyStr' : SecondChildMobilizer
   /   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (MobilizerClass), 4557184912>
   /   /   /   /  '<New><Instance>NodePointOrderedDict' : 
   /   /   /   /   /{ 
   /   /   /   /   /  'FirstChildMobilizer' : < (MobilizerClass), 4559652240>
   /   /   /   /   /   /{ 
   /   /   /   /   /   /  '<New><Instance>IdInt' : 4559652240
   /   /   /   /   /   /  '<New><Instance>MobilizomeCollectionOrderedDict' : 
   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /}
   /   /   /   /   /   /  '<New><Instance>NodeCollectionStr' : Mobilizome
   /   /   /   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /   /   /   /  '<New><Instance>NodeKeyStr' : FirstChildMobilizer
   /   /   /   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (MobilizerClass), 4557184912>
   /   /   /   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559786656>
   /   /   /   /   /   /  '<New><Instance>RecruitomeCollectionOrderedDict' : 
   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /  'GrandChildRecruiter' : < (RecruiterClass), 4559760080>
   /   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /   /  '<New><Instance>IdInt' : 4559760080
   /   /   /   /   /   /   /   /  '<New><Instance>MobilizomeCollectionOrderedDict' : 
   /   /   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /   /   /}
   /   /   /   /   /   /   /   /  '<New><Instance>NodeCollectionStr' : Recruitome
   /   /   /   /   /   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /   /   /   /   /   /  '<New><Instance>NodeKeyStr' : GrandChildRecruiter
   /   /   /   /   /   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (MobilizerClass), 4559652240>
   /   /   /   /   /   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559787544>
   /   /   /   /   /   /   /   /  '<New><Instance>RecruitomeCollectionOrderedDict' : 
   /   /   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /   /   /}
   /   /   /   /   /   /   /   /  '<Spe><Class>RecruitedFlatCumulateVariablesList' : None
   /   /   /   /   /   /   /   /  '<Spe><Class>RecruitingConcludeConditionVariable' : None
   /   /   /   /   /   /   /   /}
   /   /   /   /   /   /   /  'FakeGrandChildVisiter' : < (VisiterClass), 4559759632>
   /   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /   /  '<New><Instance>IdInt' : 4559759632
   /   /   /   /   /   /   /   /  '<New><Instance>MobilizomeCollectionOrderedDict' : 
   /   /   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /   /   /}
   /   /   /   /   /   /   /   /  '<New><Instance>NodeCollectionStr' : Recruitome
   /   /   /   /   /   /   /   /  '<New><Instance>NodeIndexInt' : 1
   /   /   /   /   /   /   /   /  '<New><Instance>NodeKeyStr' : FakeGrandChildVisiter
   /   /   /   /   /   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (MobilizerClass), 4559652240>
   /   /   /   /   /   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559787544>
   /   /   /   /   /   /   /   /  '<New><Instance>RecruitomeCollectionOrderedDict' : 
   /   /   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /   /   /}
   /   /   /   /   /   /   /   /  '<Spe><Class>VisitingAfterUpdateList' : None
   /   /   /   /   /   /   /   /  '<Spe><Class>VisitingBeforeUpdateList' : None
   /   /   /   /   /   /   /   /  '<Spe><Class>VisitingCollectionStrsList' : None
   /   /   /   /   /   /   /   /}
   /   /   /   /   /   /   /}
   /   /   /   /   /   /  '<Spe><Class>MobilizingNameStrsList' : None
   /   /   /   /   /   /}
   /   /   /   /   /  'SecondChildMobilizer' : {...}< (MobilizerClass), 4559760400>
   /   /   /   /   /  'ThirdChildMobilizer' : < (MobilizerClass), 4559757776>
   /   /   /   /   /   /{ 
   /   /   /   /   /   /  '<New><Instance>IdInt' : 4559757776
   /   /   /   /   /   /  '<New><Instance>MobilizomeCollectionOrderedDict' : 
   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /}
   /   /   /   /   /   /  '<New><Instance>NodeCollectionStr' : Mobilizome
   /   /   /   /   /   /  '<New><Instance>NodeIndexInt' : 2
   /   /   /   /   /   /  '<New><Instance>NodeKeyStr' : ThirdChildMobilizer
   /   /   /   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (MobilizerClass), 4557184912>
   /   /   /   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559786656>
   /   /   /   /   /   /  '<New><Instance>RecruitomeCollectionOrderedDict' : 
   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /}
   /   /   /   /   /   /  '<Spe><Class>MobilizingNameStrsList' : None
   /   /   /   /   /   /}
   /   /   /   /   /}
   /   /   /   /  '<New><Instance>RecruitomeCollectionOrderedDict' : 
   /   /   /   /   /{ 
   /   /   /   /   /}
   /   /   /   /  '<Spe><Class>MobilizingNameStrsList' : None
   /   /   /   /}
   /   /   /  '<Spe><Class>PointedBackSetStr' : 
   /   /   /  '<Spe><Class>PointedPathBackVariable' : 
   /   /   /  '<Spe><Instance>PointedGetVariable' : {...}< (MobilizerClass), 4559760400>
   /   /   /  '<Spe><Instance>PointedLocalSetStr' : CatchToPointVariable
   /   /   /  '<Spe><Instance>PointingBackSetStr' : 
   /   /   /  '<Spe><Instance>PointingGetVariable' : {...}< (MobilizerClass), 4559760400>
   /   /   /  '<Spe><Instance>PointingSetPathStr' : CatchToPointVariable
   /   /   /}
   /   /}
   /  '<New><Instance>MobilizomeCollectionOrderedDict' : {...}< (OrderedDict), 4559786656>
   /  '<New><Instance>NodeCollectionStr' : Globals
   /  '<New><Instance>NodeIndexInt' : -1
   /  '<New><Instance>NodeKeyStr' : TopMobilizer
   /  '<New><Instance>NodePointDeriveNoder' : None
   /  '<New><Instance>NodePointOrderedDict' : None
   /  '<New><Instance>RecruiterFiguromeCollectionOrderedDict' : 
   /   /{ 
   /   /  '>UnknowPath<Pointer' : < (PointerClass), 4559760528>
   /   /   /{ 
   /   /   /  '<New><Instance>IdInt' : 4559760528
   /   /   /  '<New><Instance>CatchToPointVariable' : {...}< (RecruiterClass), 4559760080>
   /   /   /  '<Spe><Class>PointedBackSetStr' : 
   /   /   /  '<Spe><Class>PointedPathBackVariable' : 
   /   /   /  '<Spe><Instance>PointedGetVariable' : {...}< (RecruiterClass), 4559760080>
   /   /   /  '<Spe><Instance>PointedLocalSetStr' : CatchToPointVariable
   /   /   /  '<Spe><Instance>PointingBackSetStr' : 
   /   /   /  '<Spe><Instance>PointingGetVariable' : {...}< (RecruiterClass), 4559760080>
   /   /   /  '<Spe><Instance>PointingSetPathStr' : CatchToPointVariable
   /   /   /}
   /   /}
   /  '<New><Instance>RecruitomeCollectionOrderedDict' : 
   /   /{ 
   /   /}
   /  '<Spe><Instance>MobilizingNameStrsList' : ['Mobilizer', 'Recruiter']
   /}

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


Router

Doc


A Router


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

Code



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


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


A Router

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Walkers.Mobilizer"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
import copy
import collections
from ShareYourSystem.Standards.Itemizers import Pather
#</ImportSpecificModules>

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

    #Definition
    RepresentingKeyStrsList=[
                                    'RoutingPickKeyVariablesList',
                                    'RoutedVariablesOrderedDict'
                                ]

    def default_init(self,
                _RoutingPickKeyVariablesList=None,
                _RoutedVariablesOrderedDict=None,
                **_KwargVariablesDict):

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

    def do_route(self):

        #debug
        '''
        self.debug(('self.',self,['WalkingSocketDict','WalkedTopOrderedDict']))
        '''

        #Init
        if 'RouteTopOrderedDict' not in self.WalkedTopOrderedDict:
            self.WalkedTopOrderedDict['RouteTopOrderedDict']=self.WalkingSocketDict['TopVariable'].RoutedVariablesOrderedDict

        #Init
        if 'PickKeyVariablesList' not in self.WalkedTopOrderedDict:
            self.WalkedTopOrderedDict['PickKeyVariablesList']=self.WalkingSocketDict['TopVariable'].RoutingPickKeyVariablesList

        #Pick and set in the dict
        RouteVariablesOrderedDict=collections.OrderedDict()
        map(
                lambda __PickKeyVariable,__PickValueVariable:
                RouteVariablesOrderedDict.update(
                    {__PickKeyVariable:__PickValueVariable}
                ),
                self.WalkedTopOrderedDict['PickKeyVariablesList'],
                self.pick(self.WalkedTopOrderedDict['PickKeyVariablesList'])
            )

        #debug
        '''
        self.debug(
            (
                'self.WalkedTopOrderedDict ',
                self.WalkedTopOrderedDict,
                [
                    'RouteTopOrderedDict',
                    'TopIntsList'
                ]
            )
        )
        '''

        #set
        Pather.setWithPathVariableAndKeyVariable(
            self.WalkedTopOrderedDict['RouteTopOrderedDict'],
            self.WalkedTopOrderedDict['TopIntsList'],
            RouteVariablesOrderedDict
        )

        #debug
        '''
        self.debug(
                    [
                        'After set...',
                        (
                            'self.WalkedTopOrderedDict ',
                            self.WalkedTopOrderedDict,
                            ['RouteTopOrderedDict']
                        )
                    ]
                )
        '''


#</DefineClass>

View the Router sources on Github


In [18]:
#ImportModules
import ShareYourSystem as SYS

from ShareYourSystem.Standards.Walkers import Router

#Definition a Router instance that has Tree nodes
MyRouter=Router.RouterClass().update(
    [
        (
            '<Tree>FirstChildRouter',
            Router.RouterClass().update(
                [
                    (
                        '<Tree>GrandChildRouter',
                        Router.RouterClass()
                    )
                ]
            )
        ),
        (
            '<Tree>SecondChildRouter',
            Router.RouterClass()
        )
    ]
)

#Walk inside the Tree in order to parent
MyRouter.walk(
    {
        'BeforeUpdateList':
        [
            ('route',{'LiargVariablesList':[
                                                ['NodedTreeInt','NodedTreeKeyStr']
                                                #['/']
                                            ]
                    })
        ],
        'GatherVariablesList':['<Tree>']
    }
)

#Definition the AttestedStr
SYS._attest(
    [
        'MyRouter is '+SYS._str(
        MyRouter,
        **{
            'RepresentingBaseKeyStrsListBool':False,
            'RepresentingAlineaIsBool':False
        }
        )
    ]
) 

#Print



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

MyRouter is < (RouterClass), 4559705552>
   /{ 
   /  '<New><Instance>IdInt' : 4559705552
   /  '<New><Instance>NodeCollectionStr' : Globals
   /  '<New><Instance>NodeIndexInt' : -1
   /  '<New><Instance>NodeKeyStr' : TopRouter
   /  '<New><Instance>NodePointDeriveNoder' : None
   /  '<New><Instance>NodePointOrderedDict' : None
   /  '<New><Instance>TreeCollectionOrderedDict' : 
   /   /{ 
   /   /  'FirstChildRouter' : < (RouterClass), 4559707152>
   /   /   /{ 
   /   /   /  '<New><Instance>IdInt' : 4559707152
   /   /   /  '<New><Instance>NodeCollectionStr' : Tree
   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /  '<New><Instance>NodeKeyStr' : FirstChildRouter
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (RouterClass), 4559705552>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559323216>
   /   /   /  '<New><Instance>TreeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /  'GrandChildRouter' : < (RouterClass), 4559706064>
   /   /   /   /   /{ 
   /   /   /   /   /  '<New><Instance>IdInt' : 4559706064
   /   /   /   /   /  '<New><Instance>NodeCollectionStr' : Tree
   /   /   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /   /   /  '<New><Instance>NodeKeyStr' : GrandChildRouter
   /   /   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (RouterClass), 4559707152>
   /   /   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559806000>
   /   /   /   /   /  '<New><Instance>TreeCollectionOrderedDict' : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /}
   /   /   /   /   /  '<Spe><Instance>RoutedVariablesOrderedDict' : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /}
   /   /   /   /   /  '<Spe><Instance>RoutingPickKeyVariablesList' : ['NodedTreeInt', 'NodedTreeKeyStr']
   /   /   /   /   /}
   /   /   /   /}
   /   /   /  '<Spe><Instance>RoutedVariablesOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<Spe><Instance>RoutingPickKeyVariablesList' : {...}< (list), 4559768392>
   /   /   /}
   /   /  'SecondChildRouter' : < (RouterClass), 4559707536>
   /   /   /{ 
   /   /   /  '<New><Instance>IdInt' : 4559707536
   /   /   /  '<New><Instance>NodeCollectionStr' : Tree
   /   /   /  '<New><Instance>NodeIndexInt' : 1
   /   /   /  '<New><Instance>NodeKeyStr' : SecondChildRouter
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (RouterClass), 4559705552>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559323216>
   /   /   /  '<New><Instance>TreeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<Spe><Instance>RoutedVariablesOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<Spe><Instance>RoutingPickKeyVariablesList' : {...}< (list), 4559768392>
   /   /   /}
   /   /}
   /  '<Spe><Instance>RoutedVariablesOrderedDict' : 
   /   /{ 
   /   /  'NodedTreeInt' : None
   /   /  'NodedTreeKeyStr' : None
   /   /  '0' : 
   /   /   /{ 
   /   /   /  'NodedTreeInt' : None
   /   /   /  'NodedTreeKeyStr' : None
   /   /   /  '1' : 
   /   /   /   /{ 
   /   /   /   /  'NodedTreeInt' : None
   /   /   /   /  'NodedTreeKeyStr' : None
   /   /   /   /}
   /   /   /}
   /   /  '2' : 
   /   /   /{ 
   /   /   /  'NodedTreeInt' : None
   /   /   /  'NodedTreeKeyStr' : None
   /   /   /}
   /   /}
   /  '<Spe><Instance>RoutingPickKeyVariablesList' : {...}< (list), 4559768392>
   /}

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


Grabber

Doc


A Grabber


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

Code



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


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


A Grabber

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Walkers.Router"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
import copy
import collections
from ShareYourSystem.Functers import Argumenter
from ShareYourSystem.Standards.Noders import Noder
#</ImportSpecificModules>

#<DefineLocals>
#</DefineLocals>

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

    #Definition
    RepresentingKeyStrsList=[
                                    'GrabbingNodeStr',
                                    'GrabbingPickVariablesList',
                                    'GrabbedVariablesOrderedDict'
                                ]

    def default_init(self,
                _GrabbingNodeStr=None,
                _GrabbingPickVariablesList=None,
                _GrabbedVariablesOrderedDict=None,
                **_KwargVariablesDict):

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

    #@Argumenter.ArgumenterClass()
    def do_grab(self):

        #Init
        if self.GrabbedVariablesOrderedDict==None:
            self.GrabbedVariablesOrderedDict=collections.OrderedDict()

        #debug
        '''
        self.debug(('self.',self,['GrabbingNodeStr','GrabbingPickVariablesList']))
        '''

        #Walk inside the Tree in order to parent
        self.walk(
                    {
                        'BeforeUpdateList':
                        [
                            ('route',{'LiargVariablesList':[
                                                                self.GrabbingPickVariablesList
                                                            ]
                                        })
                        ],
                        'GatherVariablesList':[
                        Noder.NodingPrefixGetStr+self.GrabbingNodeStr+Noder.NodingSuffixGetStr]
                    }
                )

        #Link
        self.GrabbedVariablesOrderedDict=self.RoutedVariablesOrderedDict


#</DefineClass>

View the Grabber sources on Github


In [21]:
#ImportModules
import ShareYourSystem as SYS

from ShareYourSystem.Standards.Walkers import Grabber

#Definition a Grabber instance that has Tree nodes
MyGrabber=Grabber.GrabberClass().update(
        [
            (
                '<Tree>FirstChildGrabber',
                Grabber.GrabberClass().update(
                    [
                        (
                            '<Tree>GrandChildGrabber',
                            Grabber.GrabberClass()
                        )
                    ]
                )
            ),
            (
                '<Tree>SecondChildGrabber',
                Grabber.GrabberClass()
            )
        ]
    )

#Grab
MyGrabber.grab("Tree",['NodedTreeInt','NodedTreeKeyStr'])

#Definition the AttestedStr
SYS._attest(
    [
        'MyGrabber is '+SYS._str(
        MyGrabber,
        **{
            'RepresentingBaseKeyStrsListBool':False,
            'RepresentingAlineaIsBool':False
        }
        )
    ]
) 

#Print



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

MyGrabber is < (GrabberClass), 4559812368>
   /{ 
   /  '<New><Instance>IdInt' : 4559812368
   /  '<New><Instance>NodeCollectionStr' : Globals
   /  '<New><Instance>NodeIndexInt' : -1
   /  '<New><Instance>NodeKeyStr' : TopGrabber
   /  '<New><Instance>NodePointDeriveNoder' : None
   /  '<New><Instance>NodePointOrderedDict' : None
   /  '<New><Instance>TreeCollectionOrderedDict' : 
   /   /{ 
   /   /  'FirstChildGrabber' : < (GrabberClass), 4559812880>
   /   /   /{ 
   /   /   /  '<New><Instance>IdInt' : 4559812880
   /   /   /  '<New><Instance>NodeCollectionStr' : Tree
   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /  '<New><Instance>NodeKeyStr' : FirstChildGrabber
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (GrabberClass), 4559812368>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559332000>
   /   /   /  '<New><Instance>TreeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /  'GrandChildGrabber' : < (GrabberClass), 4559706448>
   /   /   /   /   /{ 
   /   /   /   /   /  '<New><Instance>IdInt' : 4559706448
   /   /   /   /   /  '<New><Instance>NodeCollectionStr' : Tree
   /   /   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /   /   /  '<New><Instance>NodeKeyStr' : GrandChildGrabber
   /   /   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (GrabberClass), 4559812880>
   /   /   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559331408>
   /   /   /   /   /  '<New><Instance>TreeCollectionOrderedDict' : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /}
   /   /   /   /   /  '<Spe><Class>GrabbedVariablesOrderedDict' : None
   /   /   /   /   /  '<Spe><Class>GrabbingNodeStr' : None
   /   /   /   /   /  '<Spe><Class>GrabbingPickVariablesList' : None
   /   /   /   /   /}
   /   /   /   /}
   /   /   /  '<Spe><Class>GrabbedVariablesOrderedDict' : None
   /   /   /  '<Spe><Class>GrabbingNodeStr' : None
   /   /   /  '<Spe><Class>GrabbingPickVariablesList' : None
   /   /   /}
   /   /  'SecondChildGrabber' : < (GrabberClass), 4559813584>
   /   /   /{ 
   /   /   /  '<New><Instance>IdInt' : 4559813584
   /   /   /  '<New><Instance>NodeCollectionStr' : Tree
   /   /   /  '<New><Instance>NodeIndexInt' : 1
   /   /   /  '<New><Instance>NodeKeyStr' : SecondChildGrabber
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (GrabberClass), 4559812368>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4559332000>
   /   /   /  '<New><Instance>TreeCollectionOrderedDict' : 
   /   /   /   /{ 
   /   /   /   /}
   /   /   /  '<Spe><Class>GrabbedVariablesOrderedDict' : None
   /   /   /  '<Spe><Class>GrabbingNodeStr' : None
   /   /   /  '<Spe><Class>GrabbingPickVariablesList' : None
   /   /   /}
   /   /}
   /  '<Spe><Instance>GrabbedVariablesOrderedDict' : 
   /   /{ 
   /   /  'NodedTreeInt' : None
   /   /  'NodedTreeKeyStr' : None
   /   /  '0' : 
   /   /   /{ 
   /   /   /  'NodedTreeInt' : None
   /   /   /  'NodedTreeKeyStr' : None
   /   /   /  '1' : 
   /   /   /   /{ 
   /   /   /   /  'NodedTreeInt' : None
   /   /   /   /  'NodedTreeKeyStr' : None
   /   /   /   /}
   /   /   /}
   /   /  '2' : 
   /   /   /{ 
   /   /   /  'NodedTreeInt' : None
   /   /   /  'NodedTreeKeyStr' : None
   /   /   /}
   /   /}
   /  '<Spe><Instance>GrabbingNodeStr' : Tree
   /  '<Spe><Instance>GrabbingPickVariablesList' : ['NodedTreeInt', 'NodedTreeKeyStr']
   /}

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