# -*- 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 [2]:
#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