A Noder defines Child ordered dicts with
as KeyStr. The items inside are automatically setted with Noded and have a Pointer to the parent InstanceVariable. This is the beginning for buiding high arborescent and (possibly circular) structures of objects.
View the Noder notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Noder.ipynb)
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Noder defines Child ordered dicts with <DoStr> as KeyStr.
The items inside are automatically setted with Noded<DoStr><TypeStr> and have
a Pointer to the parent InstanceVariable. This is the beginning for buiding high
arborescent and (possibly circular) structures of objects.
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Applyiers.Filterer"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
import collections
from ShareYourSystem.Standards.Itemizers import Pather
#</ImportSpecificModules>
#<DefineLocals>
NodingPrefixGetStr='<'
NodingSuffixGetStr='>'
NodingCollectionPrefixStr="Node"
#</DefineLocals>
#<DefineClass>
@DecorationClass()
class NoderClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'NodingCollectionStr',
'NodedCollectionOrderedDict',
'NodedCollectionStr',
'NodedKeyStr',
'NodedCollectionIndexInt'
]
def default_init(self,
_NodingCollectionStr="",
_NodedCollectionOrderedDict=None,
_NodedCollectionStr="",
_NodedKeyStr="",
_NodedCollectionIndexInt=-1,
**_KwargVariablesDict
):
#Call the parent init method
BaseClass.__init__(self,**_KwargVariablesDict)
#global
global NodingCollectionPrefixStr
NodedMethodStr='__setattr__'
NodedMethod=getattr(self,NodedMethodStr)
#Int and Set Child attributes
NodedMethod(
NodingCollectionPrefixStr+'CollectionStr',
"Globals"
)
NodedMethod(
NodingCollectionPrefixStr+'IndexInt',
-1
)
"""
NodedMethod(
NodingCollectionPrefixStr+'KeyStr',
SYS._filter(
lambda __ListedVariable:
id(__ListedVariable)==self.IdStr,
sys.modules['__main__'].globals().values()
)
)
"""
NodedMethod(
NodingCollectionPrefixStr+'KeyStr',
'Top'+self.__class__.NameStr
)
self.point(
None,
NodingCollectionPrefixStr+'PointOrderedDict'
)
self.point(
None,
NodingCollectionPrefixStr+'PointDeriveNoder'
)
def do_node(self):
#debug
'''
self.debug(("self.",self,['NodingCollectionStr']))
'''
#Get the NodedStr
if self.NodingCollectionStr!="":
#set the Noded OrderedDict and KeyStr
NodedCollectionOrderedSetTagStr=self.NodingCollectionStr+'CollectionOrderedDict'
#self.NodeKeyStrKeyStr=self.NodedPrefixStr+'KeyStr'
try:
self.NodedCollectionOrderedDict=getattr(self,NodedCollectionOrderedSetTagStr)
except AttributeError:
self.__setattr__(
NodedCollectionOrderedSetTagStr,
collections.OrderedDict()
)
self.NodedCollectionOrderedDict=getattr(self,NodedCollectionOrderedSetTagStr)
def mimic_get(self):
#debug
'''
self.debug(("self.",self,['GettingKeyVariable']))
'''
#Definition
OutputDict={'HookingIsBool':True}
#Appending set
if self.GettingKeyVariable.startswith(NodingPrefixGetStr):
#Definition the SplittedStrsList
SplittedStrsList=self.GettingKeyVariable.split(NodingSuffixGetStr)
#Definition the NodingCollectionStr
NodingCollectionStr=NodingPrefixGetStr.join(
SplittedStrsList[0].split(NodingPrefixGetStr)[1:])
#debug
'''
self.debug(
[
'NodingCollectionStr is '+NodingCollectionStr,
'We are going to node'
]
)
'''
#Nodify
self.node(
NodingCollectionStr,
#**{'IsNoderBool':False}
)
#Definition of the KeyStr
GetKeyStr=NodingSuffixGetStr.join(SplittedStrsList[1:])
#debug
'''
self.debug(
[
'node is done',
'GetKeyStr is '+GetKeyStr,
'self.NodedCollectionOrderedDict is '+str(self.NodedCollectionOrderedDict)
]
)
'''
#Get with a digited KeyStr case
if GetKeyStr.isdigit():
#Definition the GetInt
GetInt=(int)(GetKeyStr)
#Check if the size is ok
if GetInt<len(self.NodedCollectionOrderedDict):
#Get the GettedVariable
self.GettedValueVariable=SYS.get(
self.NodedCollectionOrderedDict,
'values',
GetInt
)
#Return
OutputDict['HookingIsBool']=False
#<Hook>return OutputDict
#Get in the ValueVariablesList
elif GetKeyStr=="":
#Get the GettedVariable
self.GettedValueVariable=self.NodedCollectionOrderedDict.values()
#Return
OutputDict['HookingIsBool']=False
#<Hook>return OutputDict
elif GetKeyStr in self.NodedCollectionOrderedDict:
#Get the GettedVariable
self.GettedValueVariable=self.NodedCollectionOrderedDict[GetKeyStr]
#Return
OutputDict['HookingIsBool']=False
#<Hook>return OutputDict
#Call the parent get method
if OutputDict['HookingIsBool']:
#debug
'''
self.debug(
[
('self.',self,['GettingKeyVariable']),
'BaseClass.get is '+str(BaseClass.get)
]
)
'''
#Call
return BaseClass.get(self)
else:
#return
return OutputDict
#<Hook>@Hooker.HookerClass(**{'HookingAfterVariablesList':[BaseClass.set]})
#@Imitater.ImitaterClass()
def mimic_set(self):
""" """
#debug
'''
self.debug(('self.',self,[
'SettingKeyVariable',
#'SettingValueVariable'
]))
'''
#Definition
OutputDict={'HookingIsBool':True}
#Appending set
if self.SettingKeyVariable.startswith(NodingPrefixGetStr):
#Definition the SplittedStrsList
SplittedStrsList=self.SettingKeyVariable.split(NodingSuffixGetStr)
#Definition the NodingCollectionStr
NodingCollectionStr=NodingPrefixGetStr.join(
SplittedStrsList[0].split(NodingPrefixGetStr)[1:])
#Check if it is an append of Nodes
IsNoderBool='NoderClass' in map(
lambda __Class:
__Class.__name__,
type(self.SettingValueVariable).__mro__
)
#debug
'''
self.debug(('vars ',vars(),['NodingCollectionStr','IsNoderBool']))
'''
#Nodify
self.node(
NodingCollectionStr,
#**{'IsNoderBool':IsNoderBool}
)
#Definition the KeyStr
SetTagStr=NodingSuffixGetStr.join(SplittedStrsList[1:])
#debug
'''
self.debug('SetTagStr is '+SetTagStr)
'''
#Append (or set if it is already in)
Pather.setWithPathVariableAndKeyVariable(
self.NodedCollectionOrderedDict,
Pather.PathPrefixStr+SetTagStr,
self.SettingValueVariable
)
if Pather.PathPrefixStr not in SetTagStr:
#debug
'''
self.debug(('self.',self,['SettingValueVariable']))
'''
#If it is an object
if IsNoderBool:
#global
global NodingCollectionPrefixStr
NodedMethodStr='__setattr__'
NodedMethod=getattr(self.SettingValueVariable,NodedMethodStr)
#Int and Set Child attributes
NodedMethod(
NodingCollectionPrefixStr+'CollectionStr',
self.NodingCollectionStr
)
NodedMethod(
NodingCollectionPrefixStr+'IndexInt',
len(self.NodedCollectionOrderedDict)-1
)
NodedMethod(
NodingCollectionPrefixStr+'KeyStr',
SetTagStr
)
self.SettingValueVariable.point(
self.NodedCollectionOrderedDict,
NodingCollectionPrefixStr+'PointOrderedDict'
)
self.SettingValueVariable.point(
self,
NodingCollectionPrefixStr+'PointDeriveNoder'
)
#set
OutputDict['HookingIsBool']=False
#return
return OutputDict
#Call the parent get method
if OutputDict['HookingIsBool']:
return BaseClass.set(self)
#</DefineClass>
View the Noder sources on Github
In [3]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Noder
#Definition of a Noder instance
MyNoder=Noder.NoderClass()
#Short expression for setting in the appended manner a structured object
MyNoder['<Nodome>FirstChildNoder']=Noder.NoderClass()
#Short expression for setting in the appended manner a structured object
MyNoder['<Nodome>SecondChildNoder']=Noder.NoderClass()
#Definition the AttestedStr
SYS._attest(
[
'MyNoder is '+SYS._str(
MyNoder,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
An Appender append by doing a set in a NodedOrderedDict thanks to the <AppendedNodeCollectionStr><AppendedNodeKeyStr>
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Noder"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
import collections
from ShareYourSystem.Applyiers import Updater
Noder=BaseModule
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class AppenderClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'AppendingCollectionVariable',
'AppendedNodeCollectionStr',
'AppendedNodeKeyStr'
]
def default_init(self,
_AppendingCollectionVariable=None,
_AppendedNodeCollectionStr="",
_AppendedNodeKeyStr="",
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_append(self):
""" """
#debug
'''
self.debug('self.AppendingCollectionVariable is '+str(self.AppendingCollectionVariable))
'''
#TuplesList Case
if SYS.getIsTuplesListBool(self.AppendingCollectionVariable):
#debug
'''
self.debug('This is a tuples list')
'''
#Definition the KeyStrsList
AppendedKeyStrsList=SYS.unzip(self.AppendingCollectionVariable,[0])
#Look for an AppendingNodeCollectionStr
try:
NodeCollectionStrIndexInt=AppendedKeyStrsList.index(
"NodeCollectionStr"
)
self.AppendedNodeCollectionStr=self.AppendingCollectionVariable[
NodeCollectionStrIndexInt
][1]
'''
#self.AppendedKeyStrKeyStr='Noded'+self.AppendedNodeCollectionStr+'KeyStr'
try:
AppendedKeyStrIndexInt=AppendedKeyStrsList.index(
self.AppendedKeyStrKeyStr
)
self.AppendedKeyStr=self.AppendingCollectionVariable[KeyStrIndexInt][1]
except:
pass
'''
NodeKeyStrIndexInt=AppendedKeyStrsList.index(
"NodeKeyStr"
)
self.AppendedNodeKeyStr=self.AppendingCollectionVariable[
NodeKeyStrIndexInt
][1]
except:
pass
else:
#Objects Case
if "AppenderClass" in map(
lambda __Class:
__Class.__name__,
type(self.AppendingCollectionVariable).__mro__
):
#debug
'''
self.debug('This is a derived object from an Appender')
'''
#set
AppendedDict=self.AppendingCollectionVariable.__dict__
#dict Case
elif type(self.AppendingCollectionVariable) in [dict,collections.OrderedDict]:
AppendedDict=self.AppendingCollectionVariable
try:
#set
self.AppendedNodeCollectionStr=AppendedDict["NodeCollectionStr"]
self.AppendedNodeKeyStr=AppendedDict[
'NodeKeyStr'
]
except:
pass
#Init the SettingVariable and Add the NodifyingStr
AppendedSettingKeyVariable=Noder.NodingPrefixGetStr+self.AppendedNodeCollectionStr+Noder.NodingSuffixGetStr+self.AppendedNodeKeyStr
#debug
self.debug([
('self.',self,[
'AppendedNodeCollectionStr',
'AppendedNodeKeyStr'
])
]
)
#Then set
if AppendedSettingKeyVariable!=Noder.NodingPrefixGetStr+Noder.NodingSuffixGetStr:
self.__setitem__(
AppendedSettingKeyVariable,
self.AppendingCollectionVariable
)
#Return self
#return self
#</DefineClass>
View the Appender sources on Github
In [7]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Appender
#Append with a TuplesList
MyAppender=Appender.AppenderClass().append([
('NodeCollectionStr','Tree'),
('NodeKeyStr','MyTuplesList'),
('MyStr','Hello')
]
)
#Append with a dict
MyAppender.append({
'NodeCollectionStr':'Tree',
'NodeKeyStr':'MyDict',
'MyOtherStr':'Bonjour'
}
)
#Append with an instance
MyAppender.append(
Appender.AppenderClass().update(
[
('NodeCollectionStr','Tree'),
('NodeKeyStr','MyAppender')
]
)
)
#Definition the AttestedStr
SYS._attest(
[
'MyAppender is '+SYS._str(
MyAppender,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
An Appender append by doing a set in a NodedOrderedDict thanks to the <AppendedNodeStr><AppendedNodeKeyStr>
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Appender"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
Appender=BaseModule
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class InstancerClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'InstancingVariable',
'InstancingClass',
'InstancingIsBool',
'InstancedVariable'
]
def default_init(self,
_InstancingVariable=None,
_InstancingClass=None,
_InstancingIsBool=False,
_InstancedVariable=None,
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
#@Imitater.ImitaterClass()
def mimic_append(self):
#Instance first
self.instance()
#Append then
Appender.AppenderClass.append(self,self.InstancedVariable)
#Return self
return self
def do_instance(self):
""" """
#Check
if self.InstancingIsBool:
#Init
InstancingClass=None
#TuplesList Case
if SYS.getIsTuplesListBool(self.InstancingVariable):
#debug
'''
self.debug('This is a tuples list')
'''
if self.InstancingClass==None:
#debug
'''
self.debug('Find the instancing class')
'''
#Definition the KeyStrsList
KeyStrsList=SYS.unzip(self.InstancingVariable,[0])
try:
InstancingClass=self.InstancingVariable[KeyStrsList.index('InstancingClass')][1]
except:
pass
else:
InstancingClass=self.InstancingClass
#Check
if InstancingClass!=None:
#Init
self.InstancedVariable=InstancingClass()
#Map
map(
lambda __ItemTuple:
self.InstancedVariable.__setattr__(*__ItemTuple),
self.InstancingVariable
)
#debug
'''
self.debug(('vars ',vars(),['InstancedVariable']))
'''
elif hasattr(self.InstancingVariable,'items'):
#debug
'''
self.debug('This is an itemizing thing')
'''
if self.InstancingClass==None:
#debug
'''
self.debug('Find the instancing class')
'''
try:
InstancingClass=self.InstancingVariable['InstancingClass']
except:
pass
else:
#Definition
InstancingClass=self.InstancingClass
if InstancingClass!=None:
#Init
self.InstancedVariable=InstancingClass()
#Map
map(
lambda __ItemTuple:
self.InstancedVariable.__setattr__(*__ItemTuple),
self.InstancingVariable.items()
)
elif hasattr(self.InstancingVariable,'__dict__'):
#Check
if self.InstancingClass!=None:
#Init
self.InstancedVariable=self.InstancingClass()
#Return self
#return self
#</DefineClass>
View the Instancer sources on Github
In [10]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Appender,Instancer
#Append with a TuplesList
MyInstancer=Instancer.InstancerClass(**{'InstancingIsBool':True}).instance([
('AppendingNodeCollectionStr','Structure'),
('NodeKeyStr','MyInstancedAppender'),
('MyStr','Hello'),
('InstancingClass',Appender.AppenderClass)
]
)
#Definition the AttestedStr
SYS._attest(
[
'MyInstancer is '+SYS._str(
MyInstancer,
**{
'RepresentingBaseKeyStrsListBool':False
}
)
]
)
#Print
# -*- 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.Standards.Noders.Instancer"
DecorationModuleStr="ShareYourSystem.Standards.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 [14]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.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
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Distinguisher is a bit the opposite of a Commander, it updates
for every child nodes with a distinguished tuples list.
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Adder"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
from ShareYourSystem.Standards.Noders import Noder
#</ImportSpecificModules>
#<DefineLocals>
DistinguishingPrefixStr="Dis_"
#</DefineLocals
#<DefineClass>
@DecorationClass()
class DistinguisherClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'DistinguishingNodeStr',
'DistinguishingUpdatesList',
'DistinguishedCollectionOrderedDict'
]
def default_init(self,
_DistinguishingNodeStr="",
_DistinguishingUpdatesList=None,
_DistinguishedCollectionOrderedDict=None,
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
def mimic_set(self):
""" """
#debug
'''
self.debug(('self.',self,['SettingKeyVariable','SettingValueVariable']))
'''
#Definition
OutputDict={'HookingIsBool':True}
#Deep set
if self.SettingKeyVariable.startswith(DistinguishingPrefixStr):
#debug
'''
self.debug('We are going to distinguish')
'''
#set arguments
self.DistinguishingNodeStr=Noder.NodingSuffixGetStr.join(
(
Noder.NodingPrefixGetStr.join(
self.SettingKeyVariable.split(
Noder.NodingPrefixGetStr
)[1:]
)
).split(Noder.NodingSuffixGetStr)[:-1]
)
self.DistinguishingUpdatesList=self.SettingValueVariable
#debug
'''
self.debug(('self.',self,[
'DistinguishingNodeStr',
'DistinguishingUpdatesList'
]))
'''
#distinguish
self.distinguish()
#Stop the setting
OutputDict["HookingIsBool"]=False
#<Hook>return OutputDict
#Call the parent get method
if OutputDict['HookingIsBool']:
BaseClass.set(self)
def do_distinguish(self):
""" """
#Check
if self.DistinguishingNodeStr!="":
#debug
'''
self.debug(('self.',self,['DistinguishingNodeStr']))
'''
#get
self.DistinguishedCollectionOrderedDict=getattr(
self,
self.DistinguishingNodeStr+'CollectionOrderedDict'
)
#Map the distinguished updates
map(
lambda __NodeVariable,__UpdateTuplesList:
__NodeVariable.update(__UpdateTuplesList),
self.DistinguishedCollectionOrderedDict.values(),
self.DistinguishingUpdatesList
)
#</DefineClass>
View the Distinguisher sources on Github
In [18]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Distinguisher
import copy
#Definition a tree of Distinguishers.
MyDistinguisher=Distinguisher.DistinguisherClass().__add__(
[
Distinguisher.DistinguisherClass().update(
[
('NodeCollectionStr','Tree'),
('NodeKeyStr',str(Int1))
]
) for Int1 in xrange(2)
]
)
#distinguish
MyDistinguisher.distinguish("Tree",[
[('MyStr',"hello")],
[('MyInt',0)]
])
#distinguish through setting
MyDistinguisher.__setitem__(
"Dis_<Tree>",
[
[('MyOtherStr',"bonjour")],
[('MyOtherInt',1)]
]
)
#Definition the AttestedStr
SYS._attest(
[
'MyDistinguisher is '+SYS._str(
MyDistinguisher,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print
# -*- 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 acts only at one level.
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Distinguisher"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
import copy
from ShareYourSystem.Standards.Itemizers import Pather
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass(
**{'ClassingSwitchMethodStrsList':['parent']}
)
class ParenterClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'ParentingWalkBool',
'ParentedDeriveParentersList',
'ParentedNodeCollectionStrsList',
'ParentedNodePathStr'
]
def default_init(self,
_ParentingWalkBool=True,
_ParentedDeriveParentersList=None,
_ParentedNodeCollectionStrsList=None,
_ParentedNodePathStr="",
**_KwargVariablesDict):
#Call the parent init method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_parent(self):
#debug
'''
self.debug(('self.',self,['ParentingNodeStr','NodePointDeriveNoder']))
'''
#Check of a parent pointer
if self.NodePointDeriveNoder!=None:
#debug
'''
self.debug('We are going to node the parent pointer')
'''
#Parent the parent maybe
if self.ParentingWalkBool:
#parent the parent
self.NodePointDeriveNoder.parent()
#set
self.ParentedDeriveParentersList=[self.NodePointDeriveNoder
]+self.NodePointDeriveNoder.ParentedDeriveParentersList
self.ParentedNodeCollectionStrsList=[self.NodedCollectionStr
]+self.NodePointDeriveNoder.ParentedNodeCollectionStrsList
self.ParentedNodeCollectionStrsList.reverse()
#definition
ParentedNodePathStrsList=map(
lambda __ParentedDeriveParenter:
__ParentedDeriveParenter.NodeKeyStr,
self.ParentedDeriveParentersList
)
ParentedNodePathStrsList.reverse()
#Debug
'''
self.debug('ParentedNodePathStrsList is '+str(ParentedNodePathStrsList))
'''
#set
self.ParentedNodePathStr=Pather.PathPrefixStr.join(ParentedNodePathStrsList)
#Return self
#return self
#</DefineClass>
View the Parenter sources on Github
In [22]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Parenter
#Short expression and set in the appended manner
MyParenter=Parenter.ParenterClass().__setitem__(
'<Tree>ChildParenter',
Parenter.ParenterClass().__setitem__(
'<Tree>GrandChildParenter',
Parenter.ParenterClass()
)
)
#Parent for the children
#MyParenter['<Tree>ChildParenter'].parent('Tree')
MyParenter['<Tree>ChildParenter']['<Tree>GrandChildParenter'].parent()
#Definition the AttestedStr
SYS._attest(
[
'MyParenter is '+SYS._str(
MyParenter,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
Collecter instances
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Parenter"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
from ShareYourSystem.Standards.Classors import Doer
from ShareYourSystem.Standards.Noders import Noder
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class CollecterClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'CollectingCollectionStr',
'CollectingNodeKeyStr',
'CollectingNodeVariable',
'CollectedGetStr',
'CollectedSuffixStr',
'CollectedSetTagStr'
]
#@Hooker.HookerClass(**{'HookingAfterVariablesList':[{'CallingVariable':BaseClass.__init__}]})
def default_init(self,
_CollectingCollectionStr="",
_CollectingNodeKeyStr="",
_CollectingNodeVariable=None,
_CollectedGetStr="",
_CollectedSuffixStr="",
_CollectedSetTagStr="",
**_KwargVariablesDict
):
#Call the parent init method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_collect(self):
#debug
'''
self.debug(('self.',self,[
'CollectingCollectionStr',
'CollectingNodeKeyStr',
'CollectingNodeVariable'
]))
'''
#Set
self.CollectedGetStr=Noder.NodingPrefixGetStr+self.CollectingCollectionStr+Noder.NodingSuffixGetStr
#Add a typing suffix Str
if hasattr(self.CollectingNodeVariable.__class__,'NameStr'):
self.CollectedSuffixStr=self.CollectingNodeVariable.__class__.NameStr
else:
CollectedTypeStr=type(self.CollectingNodeVariable).__name__
self.CollectedSuffixStr=CollectedTypeStr[0].upper()+CollectedTypeStr[1:]
#set
self.CollectedSetTagStr=self.CollectedGetStr+self.CollectingNodeKeyStr+self.CollectedSuffixStr
#debug
'''
self.debug(('self.',self,['CollectedSetTagStr']))
'''
#node
self[self.CollectedSetTagStr]=self.CollectingNodeVariable
#</DefineClass>
View the Collecter sources on Github
In [25]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Noder,Collecter
#Definition of an instance
MyCollecter=Collecter.CollecterClass().collect(
'Nodome',
'First',
Noder.NoderClass()
).collect(
'Nodome',
'Second',
Noder.NoderClass()
)
#Definition the AttestedStr
SYS._attest(
[
'MyCollecter is '+SYS._str(
MyCollecter,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
Catcher instances grasps a Variable, sets a Pointer on it that will be then collected
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Applyiers.Producer"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
from ShareYourSystem.Standards.Itemizers import Pointer
from ShareYourSystem.Standards.Noders import Noder
import collections
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class CatcherClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'CatchingCollectionStr',
'CatchingUpdateVariable',
'CatchingNodeKeyStr',
'CatchingDefaultNodeKeyStrBool',
'CatchingDerivePointerClass',
'CatchingPointBackSetStr',
'CatchedGraspVariable',
'CatchedNodeKeyStr',
'CatchedDerivePointerVariable'
]
def default_init(self,
_CatchingCollectionStr="",
_CatchingUpdateVariable=None,
_CatchingNodeKeyStr="",
_CatchingDefaultNodeKeyStrBool=True,
_CatchingDerivePointerClass=Pointer.PointerClass,
_CatchingPointBackSetStr="",
_CatchedGraspVariable=None,
_CatchedNodeKeyStr="",
_CatchedDerivePointerVariable=None,
**_KwargVariablesDict
):
#Call the parent init method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_catch(self):
#debug
'''
self.debug(
('self.',self,[
'CollectingCollectionStr',
'GraspingClueVariable'
])
)
'''
#grasp
'''
self.grasp(
self.GraspingClueVariable
)
'''
#link
if type(self.GraspingClueVariable)==SYS.GraspDictClass:
self.CatchingUpdateVariable=self.GraspingClueVariable
#Defaut set for the collection keyStr
if self.CatchingDefaultNodeKeyStrBool:
#Check
CatchedGetStr=">UnknowPath<"
if type(self.GraspingClueVariable) in SYS.StrTypesList:
#set
CatchedGetStr=self.GraspingClueVariable
elif type(self.GraspingClueVariable)==SYS.GraspDictClass and type(
self.GraspingClueVariable['HintVariable']) in SYS.StrTypesList:
#set
CatchedGetStr=self.GraspingClueVariable['HintVariable']
elif hasattr(self.GraspedAnswerVariable,'parent'):
#Get the up
CatchedUpNodeKeyStrsList=(self.parent(
).ParentedNodePathStr+'/'+self.NodeKeyStr).split('/')
CatchedUpNodeKeyStrsList.reverse()
CatchedUpPathStr='/'.join(CatchedUpNodeKeyStrsList[:-1])
#Get the down
CatchedDownNodeKeyStrsList=(self.GraspedAnswerVariable.parent(
).ParentedNodePathStr+'/'+self.GraspedAnswerVariable.NodeKeyStr).split('/')
CatchedDownPathStr='/'.join(CatchedDownNodeKeyStrsList[1:])
#Get the top
CatchedTopStr=CatchedUpNodeKeyStrsList[-1]
if CatchedUpNodeKeyStrsList[-1]==CatchedDownNodeKeyStrsList[0]:
#set
CatchedGetStr=CatchedUpPathStr+'>'+CatchedTopStr+'<'+CatchedDownPathStr
#set
self.CatchedNodeKeyStr=CatchedGetStr
else:
#Look for one
self.CatchedNodeKeyStr=self.CatchingNodeKeyStr
#adapt the
self.CatchedNodeKeyStr=self.CatchedNodeKeyStr.replace('/','_')
#debug
'''
self.debug(
('self.',self,[
'CatchingCollectionStr',
'CatchedNodeKeyStr'
])
)
'''
#Check
if self.CatchingCollectionStr=="":
self.CatchingCollectionStr=self.CollectingCollectionStr
#init
self.CatchedDerivePointerVariable=self.CatchingDerivePointerClass(
**{
'PointingBackSetStr':self.CatchingPointBackSetStr
}
).point(
self.GraspedAnswerVariable,
'CatchToPointVariable'
)
#debug
'''
self.debug(
('self.',self,[
'CatchedDerivePointerVariable'
])
)
'''
#collect and update
self.collect(
self.CatchingCollectionStr,
self.CatchedNodeKeyStr,
self.CatchedDerivePointerVariable
)
#set
self.CatchedDerivePointerVariable.update(
self.CatchingUpdateVariable
)
#</DefineClass>
View the Catcher sources on Github
In [29]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Applyiers import Producer
from ShareYourSystem.Standards.Noders import Catcher
#Definition of an instance
MyProducer=Producer.ProducerClass().produce(
['First','Second'],
Catcher.CatcherClass,
**{'CollectingCollectionStr':"Pointome"}
)
#point
MyProducer['<Pointome>FirstCatcher'].grasp(
'/NodePointDeriveNoder/<Pointome>SecondCatcher'
).catch(
_PointBackSetStr='MyBackVariable',
**{
'CollectingCollectionStr':'Relatome',
}
)
#Definition the AttestedStr
SYS._attest(
[
'MyProducer is '+SYS._str(
MyProducer,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
Attentioner instances grasp a Variable and make inside a catch to the original
instance
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Catcher"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
from ShareYourSystem.Standards.Classors import Doer
from ShareYourSystem.Standards.Noders import Noder
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class AttentionerClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'AttentioningCollectionStr'
]
def default_init(self,
_AttentioningCollectionStr="",
**_KwargVariablesDict
):
#Call the parent init method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_attention(self):
#debug
'''
self.debug(('self.',self,['CatchingCollectionStr']))
'''
#set
if self.AttentioningCollectionStr=="":
self.AttentioningCollectionStr=self.CollectingCollectionStr
#debug
self.debug(
('self.',self,[
'AttentioningCollectionStr',
'GraspingClueVariable'
])
)
#poitn in the other way
self.GraspedAnswerVariable.grasp(
self
).catch(
self.AttentioningCollectionStr
)
#</DefineClass>
View the Attentioner sources on Github
In [32]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Applyiers import Producer
from ShareYourSystem.Standards.Noders import Attentioner
#Definition of an instance
MyProducer=Producer.ProducerClass().produce(
['First','Second'],
Attentioner.AttentionerClass,
**{'CollectingCollectionStr':"Pointome"}
)
#attention
MyProducer['<Pointome>FirstAttentioner'].grasp(
'/NodePointDeriveNoder/<Pointome>SecondAttentioner'
).attention(
'BackRelatome'
)
#Definition the AttestedStr
SYS._attest(
[
'MyProducer is '+SYS._str(
MyProducer,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Coupler
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Attentioner"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
from ShareYourSystem.Standards.Itemizers import Pather
from ShareYourSystem.Standards.Noders import Noder
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class CouplerClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'CouplingNodeStr',
'CouplingGetStr',
'CoupledGetStr'
]
def default_init(self,
_CouplingNodeStr="",
_CouplingGetStr="",
_CoupledGetStr="",
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_couple(self):
#debug
'''
self.debug(('self.',self,[
'CouplingNodeStr',
'CouplingGetStr',
'PointingBackBool'
]))
'''
#set
self.CoupledGetStr=Noder.NodingPrefixGetStr+self.CouplingNodeStr+Noder.NodingSuffixGetStr
self.PointingSetPathStr=self.CoupledGetStr+self.CouplingGetStr.split(
Noder.NodingSuffixGetStr
)[-1]
#debug
'''
self.debug(('self.',self,['CoupledGetStr','PointingSetPathStr']))
'''
#point
self.point(
self.CouplingGetStr,
self.PointingSetPathStr
)
#Return self
#return self
#</DefineClass>
View the Coupler sources on Github
In [35]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Coupler
#store
MyCoupler=Coupler.CouplerClass().collect(
'Couplome',
'FirstChild',
Coupler.CouplerClass()
).collect(
'Couplome',
'SecondChild',
Coupler.CouplerClass()
)
#couple
MyCoupler['<Couplome>SecondChildCoupler'].couple(
'Relatome',
'/NodePointDeriveNoder/<Couplome>FirstChildCoupler'
)
#Return
SYS._attest(
[
'MyCoupler is '+SYS._str(
MyCoupler,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Settler
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Coupler"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
import copy
from ShareYourSystem.Standards.Itemizers import Pather
from ShareYourSystem.Applyiers import Linker
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass(**{'ClassingSwitchMethodStrsList':['settle']})
class SettlerClass(
BaseClass,
Linker.LinkerClass
):
#Definition
RepresentingKeyStrsList=[
'SettlingParentBool',
'SettlingLinkBool'
]
def default_init(self,
_SettlingParentBool=False,
_SettlingLinkBool=False,
**_KwargVariablesDict):
#Call the parent init method
BaseClass.__init__(self,**_KwargVariablesDict)
#@Switcher.SwitcherClass()
def do_settle(self):
#debug
'''
self.debug('We settle here')
'''
#Parent first
if self.SettlingParentBool:
#debug
'''
self.debug('We parent here')
'''
#parent
self.parent()
#link
if self.SettlingLinkBool:
#debug
'''
self.debug('We link here')
'''
#link
self.link()
#Return self
#return self
#@Imitater.ImitaterClass()
def mimic_set(self):
#debug
#Call the parent method
OutputDict=BaseClass.set(self)
#debug
'''
self.debug(('self.',self,[
'SettingKeyVariable',
'SettingValueVariable'
]))
'''
#Check
if self.SettingKeyVariable=='NodePointDeriveNoder' and self.SettingValueVariable!=None:
#debug
'''
self.debug(('self.',self,['NodePointDeriveNoder']))
'''
#settle
self.settle()
#return
#return OutputDict
#</DefineClass>
View the Settler sources on Github
In [39]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Settler
#Short expression and set in the appended manner
MySettler=Settler.SettlerClass().__setitem__(
'<Settlome>ChildSettler',
Settler.SettlerClass()
).update(
[
(
'<Settlome>GrandFirstChildSettler',
Settler.SettlerClass()
),
(
'<Settlome>GrandSecondChildSettler',
Settler.SettlerClass(**{
'SettlingParentBool':True,
'SettlingLinkBool':True
}
).__setitem__(
'LinkingPointListsList',
[
('/NodePointDeriveNoder/<Settlome>GrandFirstChildSettler','GrandFirstChildSettler')
]
)
)
]
)
#Definition the AttestedStr
SYS._attest(
[
'MySettler is '+SYS._str(
MySettler,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
Connecter instances catch grasped variables and makes an attention also on it.
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Walkers.Mobilizer"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class ConnecterClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'ConnectingGraspClueVariablesList',
'ConnectedCatchDerivePointersList'
]
def default_init(self,
_ConnectingGraspClueVariablesList=None,
_ConnectedCatchDerivePointersList=None,
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_connect(self):
#debug
'''
self.debug(('self.',self,['ConnectingGraspClueVariablesList']))
'''
#catch
self.ConnectedCatchDerivePointersList=map(
lambda __ConnectingGraspVariable:
self.grasp(
__ConnectingGraspVariable
).catch(
).attention(
).GraspedAnswerVariable,
self.ConnectingGraspClueVariablesList
)
#</DefineClass>
View the Connecter sources on Github
In [43]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Applyiers import Producer
from ShareYourSystem.Standards.Noders import Connecter
#Definition of an instance
MyProducer=Producer.ProducerClass().produce(
['First','Second'],
Connecter.ConnecterClass,
**{'CollectingCollectionStr':"Connectome"}
)
#connect
MyProducer['<Connectome>FirstConnecter'].connect(
[
'/NodePointDeriveNoder/<Connectome>SecondConnecter',
SYS.GraspDictClass(**{'MyInt':0,'HintVariable':MyProducer['<Connectome>FirstConnecter']})
],
**{
'CatchingCollectionStr':"PostRelatome",
'AttentioningCollectionStr':"PreRelatome",
}
)
#Definition the AttestedStr
SYS._attest(
[
'MyProducer is '+SYS._str(
MyProducer,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Networker
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Connecter"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
from ShareYourSystem.Standards.Noders import Noder
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass(**{'ClassingSwitchMethodStrsList':["network"]})
class NetworkerClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'NetworkedDeriveConnectersList',
'NetworkedConnectionTuplesList'
]
#@Hooker.HookerClass(**{'HookingAfterVariablesList':[{'CallingVariable':BaseClass.__init__}]})
def default_init(self,
_NetworkingSuffixStr="Connectome",
_NetworkingCatchStr="Post",
_NetworkingAttentionStr="Pre",
_NetworkedDeriveConnectersList=None,
_NetworkedConnectionTuplesList=None,
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
#map
map(
lambda __KeyStr:
self.__setattr__(
__KeyStr,
""
),
map(
lambda __TagStr:
'Newtork'+__TagStr+'Str',
['Collection','Catch','Attention']
)
)
def do_network(self):
#recruit first
if self.VisitingCollectionStrsList==None:
self.VisitingCollectionStrsList=[self.CollectingCollectionStr]
#debug
'''
self.debug(('self.',self,['VisitingCollectionStrsList']))
'''
#recruit
self.recruit()
self.NetworkedDeriveConnectersList=self.RecruitedFlatCumulateVariablesList
#debug
'''
self.debug(('self.',self,['NetworkedDeriveConnectersList']))
'''
#map a connect
self.NetworkedConnectionTuplesList=map(
lambda __NodedDeriveConnecter:
(
__NodedDeriveConnecter,
__NodedDeriveConnecter.connect(
**{
'CatchingCollectionStr':self.NetworkingCatchStr+self.NetworkingSuffixStr,
'AttentioningCollectionStr':self.NetworkingAttentionStr+self.NetworkingSuffixStr
}
).update(
[
('NetworkCollectionStr',self.NetworkingSuffixStr),
('NetworkCatchStr',self.NetworkingCatchStr),
('NetworkAttentionStr',self.NetworkingAttentionStr)
]
).pick(
[
'ConnectedAttentionDeriveConnectersList',
'ConnectedCatchDerivePointersList'
]
)
),
self.NetworkedDeriveConnectersList
)
#</DefineClass>
View the Networker sources on Github
In [46]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Connecter,Networker
import operator
#Definition of a brian structure
MyNetworker=Networker.NetworkerClass(
).push(
[
(
'First',
Connecter.ConnecterClass().update(
[
('ConnectingGraspClueVariablesList',
[
'/NodePointDeriveNoder/<Connectome>SecondConnecter'
]
),
('TagStr','Networked')
]
)
),
(
'Second',
Connecter.ConnecterClass().__setitem__(
'TagStr',
'Networked'
)
)
],
**{
'CollectingCollectionStr':'Connectome'
}
).network(
**{
'RecruitingConcludeConditionVariable':[
('__class__.NameStr',operator.eq,'Connecter')
]
}
)
#Definition the AttestedStr
SYS._attest(
[
'MyNetworker is '+SYS._str(
MyNetworker,
**{
'RepresentingBaseKeyStrsList':False,
'RepresentingAlineaIsBool':False
}
),
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Transmitter
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Networker"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
import copy
from ShareYourSystem.Standards.Itemizers import Pather
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class TransmitterClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'TransmittingUpdateList',
'TransmittingCollectionStrsList',
'TransmittedVariablesList',
'TransmittingSelfIsBool'
]
def default_init(self,
_TransmittingUpdateList=None,
_TransmittingCollectionStrsList=None,
_TransmittingSelfIsBool=True,
_TransmittedVariablesList=None,
**_KwargVariablesDict
):
#Call the parent init method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_transmit(self):
#debug
'''
self.debug(('self.',self,['TransmittingSelfIsBool']))
'''
#Check
if self.TransmittingSelfIsBool:
#update
self.update(self.TransmittingUpdateList)
#map
self.TransmittedVariablesList=SYS.flat(
map(
lambda __TransmittingCollectionStr:
map(
lambda __DeriveNoderPointer:
__DeriveNoderPointer.CatchToPointVariable,
getattr(
self,
__TransmittingCollectionStr+'CollectionOrderedDict'
).values()
) if hasattr(self,__TransmittingCollectionStr+'CollectionOrderedDict')
else [],
self.TransmittingCollectionStrsList
)
)
#command
self.command(
self.TransmittingUpdateList,
self.TransmittedVariablesList,
_GatherIsBool=False
)
#Return self
#return self
#</DefineClass>
View the Transmitter sources on Github
In [50]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Transmitter
import operator
#Definition of a brian structure
MyTransmitter=Transmitter.TransmitterClass(
).push(
[
(
'First',
Transmitter.TransmitterClass().update(
[
('ConnectingCatchGetStrsList',
[
'/NodePointDeriveNoder/<Transmitome>SecondTransmitter'
]
),
('ConnectingGraspClueVariablesList',
[
'/NodePointDeriveNoder/<Transmitome>SecondTransmitter'
]
),
('TagStr','Networked')
]
)
),
(
'Second',
Transmitter.TransmitterClass().__setitem__(
'TagStr',
'Networked'
)
)
],
**{
'CollectingCollectionStr':'Transmitome'
}
).network(
**{
'RecruitingConcludeConditionVariable':[
('__class__.NameStr',operator.eq,'Transmitter')
]
}
)
#transmit
MyTransmitter['<Transmitome>FirstTransmitter'].transmit(
[('MyInt',0)],
['PostConnectome']
)
#Definition the AttestedStr
SYS._attest(
[
'MyTransmitter is '+SYS._str(
MyTransmitter,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
)
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Grouper establishes a group of parenting nodes for which
each level is setted in equivalent hdf5 structure.
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Transmitter"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
import functools
from ShareYourSystem.Standards.Classors import Doer
#</ImportSpecificModules>
#<DefineFunctions>
def getGroupedPathStrWithPathStrsList(_PathStrsList):
#Reduce
PathStr=functools.reduce(
lambda _TotalPathStr,_PathStr:
_TotalPathStr+_PathStr
if (len(_TotalPathStr)>0 and _TotalPathStr[-1]=='/') and (len(_PathStr)>0 and _PathStr[0]!='/'
) or (len(_TotalPathStr)>0 and _TotalPathStr[-1]!='/') and (len(_PathStr)>0 and _PathStr[0]=='/')
else
_TotalPathStr[:-1]+_PathStr
if (len(_TotalPathStr)>0 and _TotalPathStr[-1]=='/') and (len(_PathStr)>0 and _PathStr[0]=='/'
)
else _TotalPathStr+'/'+_PathStr
if '/' not in [_PathStr,_TotalPathStr]
else "",
_PathStrsList
)
#Maybe add / at the beginning
if (len(PathStr)>0 and PathStr[0]!='/') or PathStr=="":
PathStr='/'+PathStr
#Return
return PathStr
#</DefineFunctions>
#<DefineClass>
@DecorationClass()
class GrouperClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'GroupedParentVariable',
'GroupedInt',
'GroupedKeyStr',
'GroupedDeriveParentersList',
'GroupedPathStrsList',
'GroupedPathStr'
]
#@Hooker.HookerClass(**{'HookingAfterVariablesList':[{'CallingVariable':BaseClass.__init__}]})
def default_init(
self,
_GroupedParentVariable=None,
_GroupedInt=-1,
_GroupedKeyStr="",
_GroupedDeriveParentersList=None,
_GroupedPathStrsList=None,
_GroupedPathStr="/",
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
#set
self.HdformatingFileKeyStr=SYS.InflectEngine.plural(
Doer.DoerStrToDoStrOrderedDict[
self.__class__.NameStr
]
)+'.hdf5'
def do_group(self):
#debug
'''
self.debug(('self.',self,['ParentingNodeStr']))
'''
#Parent
self.parent()
#Check
if len(self.ParentedDeriveParentersList)>0:
UppestParentPointer=self.ParentedDeriveParentersList[-1]
else:
UppestParentPointer=self
#Then get also from the UppestParentPointer its UppestGroupedParentVariable
if hasattr(UppestParentPointer,'GroupedDeriveParentersList'):
if len(UppestParentPointer.GroupedDeriveParentersList)>0:
UppestGroupedParentVariable=UppestParentPointer.GroupedDeriveParentersList.GroupedDeriveParentersList[-1]
else:
UppestGroupedParentVariable=UppestParentPointer
#Link
self.HdformatedFileVariable=UppestGroupedParentVariable.HdformatedFileVariable
#debug
#print('self.HdformatedFileVariable is ',self.HdformatedFileVariable)
#Create a group in the hdf5 file
if self.HdformatedFileVariable!=None:
#debug
'''
self.debug(
[
'UppestGroupedParentVariable.GroupedPathStr is '+UppestGroupedParentVariable.GroupedPathStr,
('self.',self,[
'ParentedNodePathStr',
'NodedKeyStr'
])
]
)
'''
#set the GroupedPathStr
if UppestParentPointer==self:
self.GroupedPathStr="/"
else:
self.GroupedPathStr=getGroupedPathStrWithPathStrsList(
[
UppestGroupedParentVariable.GroupedPathStr,
self.ParentedNodePathStr,
self.NodeKeyStr
]
)
#debug
'''
self.debug(('self.',self,['GroupedPathStr']))
'''
#Check if the Path exists
if self.GroupedPathStr not in self.HdformatedFileVariable:
#set all the intermediate Paths before
PathStrsList=self.GroupedPathStr.split('/')[1:]
ParsingChildPathStr="/"
#set the PathStr from the top to the down (integrativ loop)
for ChildPathStr in PathStrsList:
#Go deeper
NewParsingChildPathStr=ParsingChildPathStr+ChildPathStr
#Create the group if not already
if NewParsingChildPathStr not in self.HdformatedFileVariable:
if self.HdformatingModuleStr=="tables":
self.HdformatedFileVariable.create_group(ParsingChildPathStr,ChildPathStr)
elif self.HdformatingModuleStr=="h5py":
Group=self.HdformatedFileVariable[ParsingChildPathStr]
Group.create_group(ChildPathStr)
#Prepare the next group
ParsingChildPathStr=NewParsingChildPathStr+'/'
#Return self
#return self
#</DefineClass>
View the Grouper sources on Github
In [54]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Grouper
#Definition a structure of Grouper
MyGrouper=Grouper.GrouperClass().hdformat().update(
[
(
'<Tree>FirstChildGrouper',
Grouper.GrouperClass().update(
[
('<Tree>GrandChildGrouper',
Grouper.GrouperClass())
]
)
),
(
'<Tree>SecondChildGrouper',
Grouper.GrouperClass()
)
]
)
#Walk to set the same structure in the hdf5
MyGrouper.walk(
{
'BeforeUpdateList':
[
('parent',{'LiargVariablesList':['Tree']}),
('group',{'LiargVariablesList':[]})
],
'GatherVariablesList':['<Tree>']
}
).hdfclose()
#Definition the AttestedStr
SYS._attest(
[
'MyGrouper is '+SYS._str(
MyGrouper,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
),
'MyGrouper.hdfview().HdformatedConsoleStr is '+MyGrouper.hdfview().HdformatedConsoleStr
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Structurer is the last level of class that helps for building
hierarchic structures. For a certain <StructuringNodeStr> it walks to group
everybody in the hfd5.
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Grouper"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
from ShareYourSystem.Standards.Noders import Noder
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class StructurerClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'StructuringNodeCollectionStrsList',
'StructuringBeforeUpdateList'
]
#@Hooker.HookerClass(**{'HookingAfterVariablesList':[{'CallingVariable':BaseClass.__init__}]})
def default_init(self,
_StructuringNodeCollectionStrsList=[],
_StructuringBeforeUpdateList=None,
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
#@Hooker.HookerClass(**{'HookingAfterVariablesList':[{'CallingMethodStr':'hdformat'}]})
def do_structure(self):
#debug
'''
self.debug(('self.',self,['ParentingNodeStr']))
'''
#<NotHook>
#hdformat first
self.hdformat()
#</NotHook>
"""
print([
('parent',{'LiargVariablesList':[self.ParentingNodeStr]}),
('group',{'LiargVariablesList':[]})
]+self.StructuringBeforeUpdateList)
"""
#Walk while parentizing and grouping
self.walk(
{
'BeforeUpdateList':
[
('parent',{'LiargVariablesList':[]}),
('group',{'LiargVariablesList':[]})
]+self.StructuringBeforeUpdateList,
'GatherVariablesList':map(
lambda __StructuringNodeCollectionStr:
Noder.NodingPrefixGetStr+__StructuringNodeCollectionStr+Noder.NodingSuffixGetStr,
self.StructuringNodeCollectionStrsList
)
}
)
#Return self
#return self
#</DefineClass>
View the Structurer sources on Github
In [58]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Structurer
#Definition a "graph" structure
MyStructurer=Structurer.StructurerClass().update(
[
(
'<Graph>FirstChildStructurer',
Structurer.StructurerClass().update(
[
('<Graph>GrandChildStructurer',
Structurer.StructurerClass())
])
),
(
'<Graph>SecondChildStructurer',
Structurer.StructurerClass().update(
[
('<Tree>OtherGrandChildStructurer',
Structurer.StructurerClass())
])
)
]
).structure(['Graph','Tree']).hdfclose()
#Definition the AttestedStr
SYS._attest(
[
'MyStructurer is '+SYS._str(
MyStructurer,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
),
'MyStructurer.hdfview().HdformatedConsoleStr is '+MyStructurer.hdfview().HdformatedConsoleStr
]
)
#Print
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
Organizer instances
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Structurer"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
from ShareYourSystem.Standards.Modelers import Modeler
from ShareYourSystem.Standards.Noders import Noder
import operator
#</ImportSpecificModules>
#<DefineLocals>
#</DefineLocals>
#<DefineClass>
@DecorationClass(**{
'ClassingSwitchMethodStrsList':['organize']
})
class OrganizerClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'OrganizingModelsCollectionStr',
'OrganizingComponentsCollectionStr',
'OrganizingOutKeyStrsList',
'OrganizingInKeyStrsList',
'OrganizingOutStr',
'OrganizingInStr',
'OrganizedTopDeriveDatabaserVariable',
'OrganizedInstallIsBool',
'OrganizedDataGetStr',
'OrganizedComponentsGetStr',
'OrganizedDataGetStr',
'OrganizedComponentsGetStr',
'OrganizedInConnectAttentionGetStrsList',
'OrganizedOutConnectAttentionGetStrsList'
]
def default_init(self,
_OrganizingModelsCollectionStr="Data",
_OrganizingComponentsCollectionStr="Component",
_OrganizingOutKeyStrsList=None,
_OrganizingInKeyStrsList=None,
_OrganizingOutStr="Results",
_OrganizingInStr="Parameters",
_OrganizedTopDeriveDatabaserVariable=None,
_OrganizedInstallIsBool=False,
_OrganizedDataGetStr="",
_OrganizedComponentsGetStr="",
_OrganizedInConnectAttentionGetStrsList=None,
_OrganizedOutConnectAttentionGetStrsList=None,
_OrganizedComponentCollectionOrderedDict=None,
**_KwargVariablesDict
):
#Call the parent init method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_organize(self):
#Check
if len(self.OrganizingInKeyStrsList)==0:
self.OrganizingInKeyStrsList=self.__class__.DoingAttributeVariablesOrderedDict.keys()
if len(self.OrganizingOutKeyStrsList)==0:
self.OrganizingOutKeyStrsList=self.__class__.DoneAttributeVariablesOrderedDict.keys()
#set
self.OrganizedDataGetStr=Noder.NodingPrefixGetStr+self.OrganizingModelsCollectionStr+Noder.NodingSuffixGetStr
self.OrganizedComponentsGetStr=Noder.NodingPrefixGetStr+self.OrganizingComponentsCollectionStr+Noder.NodingSuffixGetStr
#Make the hierarchical joins for the ins
self.OrganizedInConnectAttentionGetStrsList=map(
lambda __DeriveNoder:
'/NodePointDeriveNoder/'+self.OrganizedComponentsGetStr+__DeriveNoder.NodeKeyStr+'/'+self.OrganizedDataGetStr+self.OrganizingInStr+'Hierarchizer',
self[self.OrganizedComponentsGetStr]
)
#Set
self.OrganizedComponentCollectionOrderedDict=getattr(
self,
self.OrganizingComponentsCollectionStr+'CollectionOrderedDict'
)
#map
self.OrganizedOutConnectAttentionGetStrsList=[
'/NodePointDeriveNoder/'+self.OrganizedDataGetStr+self.OrganizingInStr+'Hierarchizer'
]
#debug
'''
self.debug(
('self.',self,[
'OrganizedInConnectAttentionGetStrsList',
'OrganizedOutConnectAttentionGetStrsList'
])
)
'''
#import
from ShareYourSystem.Standards.Modelers import Hierarchizer
#Set a parameters and a results database
self.push(
[
(
self.OrganizingInStr,
Hierarchizer.HierarchizerClass().update(
[
(
'Attr_ModelingSealTuplesList',
map(
Modeler.getModelingColumnTupleWithGetKeyStr,
self.OrganizingInKeyStrsList
)
),
(
'Attr_RowingGetStrsList',
self.__class__.DoingAttributeVariablesOrderedDict.keys()
),
(
'ConnectingGraspClueVariablesList',
self.OrganizedInConnectAttentionGetStrsList
)
]
)
),
(
self.OrganizingOutStr,
Hierarchizer.HierarchizerClass().update(
[
(
'Attr_ModelingSealTuplesList',
map(
Modeler.getModelingColumnTupleWithGetKeyStr,
self.OrganizingOutKeyStrsList
)
),
(
'ConnectingGraspClueVariablesList',
self.OrganizedOutConnectAttentionGetStrsList
),
('TagStr','Networked')
]
)
)
],
**{'CollectingCollectionStr':self.OrganizingModelsCollectionStr}
)
#set
self.OrganizedTopDeriveDatabaserVariable=getattr(
self,
self.OrganizingModelsCollectionStr+'CollectionOrderedDict'
).values()[-1]
#</DefineClass>
View the Organizer sources on Github
In [62]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Classors import Classer
from ShareYourSystem.Standards.Modelers import Hierarchizer
from ShareYourSystem.Standards.Noders import Organizer
import numpy as np
import operator
#Define a Sumer class
@Classer.ClasserClass()
class SumerClass(Organizer.OrganizerClass):
#Definition
RepresentingKeyStrsList=[
'SumingFirstInt',
'SumingSecondInt',
'SumedTotalInt'
]
def default_init(self,
_SumingFirstInt=0,
_SumingSecondInt=0,
_SumedTotalInt=0,
):
#Call the parent init method
self.__class__.__bases__[0].__init__(self)
def do_sum(self):
#debug
'''
self.debug(('self.',self,['SumingFirstInt','SumingSecondInt']))
'''
#set the SumedTotalInt
self.SumedTotalInt=self.SumingFirstInt+self.SumingSecondInt
#Define a Factorizer class
@Classer.ClasserClass()
class FactorizerClass(Organizer.OrganizerClass):
#Definition
RepresentingKeyStrsList=[
'FactorizingPowerFloat',
'FactorizedTotalFloat'
]
def default_init(self,
_FactorizingPowerFloat=1.,
_FactorizedTotalFloat=0.
):
#Call the parent init method
self.__class__.__bases__[0].__init__(self)
#Build the output hierarchy
self.produce(
['X','Y'],
SumerClass,
**{'CollectingCollectionStr':self.OrganizingComponentsCollectionStr}
)
def do_factorize(self):
#debug
'''
self.debug('We factorize here')
'''
#set the FactorizedTotalFloat
self.FactorizedTotalFloat=np.power(
sum(
map(
lambda __DeriveSumer:
__DeriveSumer.SumedTotalInt,
self['<Component>']
)
),
self.FactorizingPowerFloat
)
#Definition of a Factorizer instance, organize structure and network
MyFactorizer=FactorizerClass().walk(
{
'AfterUpdateList':[
('organize',{'LiargVariablesList':[]})
],
'GatherVariablesList':['<Component>']
}
).structure(
['Component']
).network(
**{
'VisitingCollectionStrsList':[
'Data','Component'
],
'RecruitingConcludeConditionVariable':[
(
'__class__.__mro__',
operator.contains,Hierarchizer.HierarchizerClass
)
]
}
)
#Update transmit the do method and insert in the results
MyFactorizer.__setitem__(
"Dis_<Component>",
[
[
('SumingFirstInt',1),
('SumingSecondInt',2)
],
[
('SumingFirstInt',1),
('SumingSecondInt',3)
]
]
).walk(
{
'AfterUpdateList':[
('callDo',{'LiargVariablesList':[]})
],
'GatherVariablesList':['<Component>']
}
)['<Data>ResultsHierarchizer'].insert()
#Update and insert in the results
MyFactorizer.__setitem__(
"Dis_<Component>",
[
[
('SumingFirstInt',2)
],
[
('SumingSecondInt',4)
]
]
).walk(
{
'AfterUpdateList':[
('callDo',{'LiargVariablesList':[]})
],
'GatherVariablesList':['<Component>']
}
)['<Data>ResultsHierarchizer'].insert()
#Definition the AttestedStr
SYS._attest(
[
'MyFactorizer is '+SYS._str(
MyFactorizer,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
),
'hdf5 file is : '+MyFactorizer.hdfview().hdfclose().HdformatedConsoleStr
]
)
#Print