Weaver

Doc


A Weaver


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

Code



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


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


A Weaver

"""

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

#<ImportSpecificModules>
#</ImportSpecificModules>

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

    #Definition
    RepresentingKeyStrsList=[
                                    'WeavingInteractTuplesList'
                                ]

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

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

    def do_weave(self):
        """ """

        #debug
        '''
        self.debug("self.UpdatingItemVariable is "+Representer.represent(
            self.UpdatingItemVariable,**{'RepresentingAlineaIsBool':False}))
        '''

        #Apply
        self.map('interact',map(
                                    lambda __WeavingInteractTuple:
                                    {'LiargVariablesList':__WeavingInteractTuple},
                                    self.WeavingInteractTuplesList
                                )
        )

        #Return
        #return self
#</DefineClass>

View the Weaver 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.Itemizers import Pointer
from ShareYourSystem.Applyiers import Weaver

#Update several things
MyWeaver=Weaver.WeaverClass().update(
    map(
            lambda __Int:
            (
                str(__Int)+'Pointer',
                Pointer.PointerClass()
            ),
            xrange(3)
        )
).weave(
        map(
                lambda __Int:
                (
                    [
                        str(__Int)+'Pointer',
                        str(__Int-1)+'Pointer',
                    ],
                    str(__Int)+'-'+str(__Int-1)+'Pointer',
                    Pointer.PointerClass()
                )
                if __Int>0
                else
                (
                    [
                        str(0)+'Pointer',
                        str(2)+'Pointer',
                    ],
                    str(0)+'-'+str(2)+'Pointer',
                    Pointer.PointerClass()
                ),
                xrange(3)
            )
        )
    
#Definition the AttestedStr
SYS._attest(
    [
        'MyWeaver is '+SYS._str(
        MyWeaver,
        **{
            'RepresentingBaseKeyStrsListBool':False,
            'RepresentingAlineaIsBool':False
        }
        )
    ]
)  

#Print



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

MyWeaver is < (WeaverClass), 4556355920>
   /{ 
   /  '<New><Instance>0Pointer' : < (PointerClass), 4556365264>
   /   /{ 
   /   /  '<New><Instance>IdInt' : 4556365264
   /   /  '<Spe><Class>PointedBackSetStr' : 
   /   /  '<Spe><Class>PointedGetVariable' : None
   /   /  '<Spe><Class>PointedLocalSetStr' : 
   /   /  '<Spe><Class>PointedPathBackVariable' : 
   /   /  '<Spe><Class>PointingBackSetStr' : 
   /   /  '<Spe><Class>PointingGetVariable' : None
   /   /  '<Spe><Class>PointingSetPathStr' : 
   /   /}
   /  '<New><Instance>1Pointer' : < (PointerClass), 4555019024>
   /   /{ 
   /   /  '<New><Instance>IdInt' : 4555019024
   /   /  '<Spe><Class>PointedBackSetStr' : 
   /   /  '<Spe><Class>PointedGetVariable' : None
   /   /  '<Spe><Class>PointedLocalSetStr' : 
   /   /  '<Spe><Class>PointedPathBackVariable' : 
   /   /  '<Spe><Class>PointingBackSetStr' : 
   /   /  '<Spe><Class>PointingGetVariable' : None
   /   /  '<Spe><Class>PointingSetPathStr' : 
   /   /}
   /  '<New><Instance>2Pointer' : < (PointerClass), 4555019536>
   /   /{ 
   /   /  '<New><Instance>IdInt' : 4555019536
   /   /  '<Spe><Class>PointedBackSetStr' : 
   /   /  '<Spe><Class>PointedGetVariable' : None
   /   /  '<Spe><Class>PointedLocalSetStr' : 
   /   /  '<Spe><Class>PointedPathBackVariable' : 
   /   /  '<Spe><Class>PointingBackSetStr' : 
   /   /  '<Spe><Class>PointingGetVariable' : None
   /   /  '<Spe><Class>PointingSetPathStr' : 
   /   /}
   /  '<New><Instance>IdInt' : 4556355920
   /  '<Spe><Instance>WeavingInteractTuplesList' : 
   /   /[
   /   /  0 : 
   /   /   /(
   /   /   /  0 : ['0Pointer', '2Pointer']
   /   /   /  1 : 0-2Pointer
   /   /   /  2 : < (PointerClass), 4556222416>
   /   /   /   /{ 
   /   /   /   /  '<New><Instance>IdInt' : 4556222416
   /   /   /   /  '<Spe><Class>PointedBackSetStr' : 
   /   /   /   /  '<Spe><Class>PointedGetVariable' : None
   /   /   /   /  '<Spe><Class>PointedLocalSetStr' : 
   /   /   /   /  '<Spe><Class>PointedPathBackVariable' : 
   /   /   /   /  '<Spe><Class>PointingBackSetStr' : 
   /   /   /   /  '<Spe><Class>PointingGetVariable' : None
   /   /   /   /  '<Spe><Class>PointingSetPathStr' : 
   /   /   /   /}
   /   /   /)
   /   /  1 : 
   /   /   /(
   /   /   /  0 : ['1Pointer', '0Pointer']
   /   /   /  1 : 1-0Pointer
   /   /   /  2 : < (PointerClass), 4556221648>
   /   /   /   /{ 
   /   /   /   /  '<New><Instance>IdInt' : 4556221648
   /   /   /   /  '<Spe><Class>PointedBackSetStr' : 
   /   /   /   /  '<Spe><Class>PointedGetVariable' : None
   /   /   /   /  '<Spe><Class>PointedLocalSetStr' : 
   /   /   /   /  '<Spe><Class>PointedPathBackVariable' : 
   /   /   /   /  '<Spe><Class>PointingBackSetStr' : 
   /   /   /   /  '<Spe><Class>PointingGetVariable' : None
   /   /   /   /  '<Spe><Class>PointingSetPathStr' : 
   /   /   /   /}
   /   /   /)
   /   /  2 : 
   /   /   /(
   /   /   /  0 : ['2Pointer', '1Pointer']
   /   /   /  1 : 2-1Pointer
   /   /   /  2 : < (PointerClass), 4556355024>
   /   /   /   /{ 
   /   /   /   /  '<New><Instance>IdInt' : 4556355024
   /   /   /   /  '<Spe><Class>PointedBackSetStr' : 
   /   /   /   /  '<Spe><Class>PointedGetVariable' : None
   /   /   /   /  '<Spe><Class>PointedLocalSetStr' : 
   /   /   /   /  '<Spe><Class>PointedPathBackVariable' : 
   /   /   /   /  '<Spe><Class>PointingBackSetStr' : 
   /   /   /   /  '<Spe><Class>PointingGetVariable' : None
   /   /   /   /  '<Spe><Class>PointingSetPathStr' : 
   /   /   /   /}
   /   /   /)
   /   /]
   /}

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