# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
An Adder maps an append
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Noders.Instancer"
DecorationModuleStr="ShareYourSystem.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class AdderClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
#'AddingVariablesList'
]
def default_init(self,
_AddingVariablesList=None,
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
#@Argumenter.ArgumenterClass(**{'ArgumentingDoStr':'Add'})
def __add__(self,_VariablesList):
"""Apply the append to the <_AddingVariablesList>"""
#Call the add method
self.add(_VariablesList)
#Return
return self
def do_add(self):
"""Apply the append to the <_AddingVariablesList>"""
#debug
'''
self.debug(('self.',self,['AddingVariablesList']))
'''
#Apply
self.map('append',map(
lambda __AddingVariable:
{'LiargVariablesList':[__AddingVariable]},
self.AddingVariablesList
)
)
#</DefineClass>
View the Adder sources on Github
In [3]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Noders import Adder
#Definition an Tree instance
MyAdder=Adder.AdderClass()+[
[
('NodeCollectionStr','Tree'),
('NodeKeyStr','MyTuplesList'),
('MyStr','Hello')
],
{
'NodeCollectionStr':'Tree',
'NodeKeyStr':'MyDict',
'MyOtherStr':'Bonjour'
},
Adder.AdderClass().update(
[
('NodeCollectionStr','Tree'),
('NodeKeyStr','MyChildAppender')
]
)
]
#Definition the AttestedStr
SYS._attest(
[
'MyAdder is '+SYS._str(
MyAdder,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print