Findoer (sorry Finder is already an important module in python standards, so just to be sure to not override...) instances helps to find in a hdf5 table RowedVariablesList corresponding to the FindingConditionVariable.
View the Recoverer notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Recoverer.ipynb)
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
Findoer (sorry Finder is already an important module in python standards, so just to be sure to not override...)
instances helps to find in a hdf5 table RowedVariablesList corresponding to the FindingConditionVariable.
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Modelers.Findoer"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
from ShareYourSystem.Functers import Argumenter,Hooker
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class RecovererClass(
BaseClass
):
#Definition
RepresentingKeyStrsList=[
'RecoveredDict'
]
def default_init(self,
_RecoveredDict=None,
**_KwargVariablesDict
):
#Call the parent init method
BaseClass.__init__(self,**_KwargVariablesDict)
#@Hooker.HookerClass(**{'HookingAfterVariablesList':[{'MethodCallingStr':"find"}]})
#@Argumenter.ArgumenterClass()
def do_recover(self):
#debug
'''
self.debug(
[
'Is the self.RecoveredDict already setted ?',
'len(self.RecoveredDict) is '+str(len(self.RecoveredDict))
]
)
'''
#<NotHook>
#find first
self.find()
#</NotHook>
#Check
if len(self.RecoveredDict)==0:
#debug
'''
self.debug(
[
'The RecoveredDict is not yet setted',
'Look if we have found only one FilteredRowedDict',
'len(self.FoundFilterRowDictsList) is '+str(len(self.FoundFilterRowDictsList))
]
)
'''
#Check
if len(self.FoundFilterRowDictsList)==1:
#debug
'''
self.debug('It is good, there is one solution !')
'''
#set the RecoveredDict
self.RecoveredDict.update(self.FoundFilterRowDictsList[0])
#debug
'''
self.debug(
[
'Now we update with the self.RecoveredDict',
'self.RecoveredDict is '+str(self.RecoveredDict)
]
)
'''
#set the RetrievingIndexesList and retrieve
self.RetrievingIndexesList=(
0,
self.RecoveredDict['RowInt']
)
#Now we can retrieve
self.retrieve()
#<NotHook>
#Return self
#return self
#</NotHook>
#</DefineClass>
View the Recoverer sources on Github
In [3]:
#ImportModules
import operator,tables
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Noders import Structurer
from ShareYourSystem.Standards.Modelers import Recoverer
#Definition of a Structurer instance with a noded datar
MyStructurer=Structurer.StructurerClass().collect(
"Datome",
"Things",
Recoverer.RecovererClass().update(
[
(
'Attr_ModelingDescriptionTuplesList',
[
#GetStr #ColumnStr #Col
('MyInt','MyInt',tables.Int64Col()),
('MyStr','MyStr',tables.StringCol(10)),
('MyIntsList','MyIntsList',(tables.Int64Col(shape=3)))
]
),
('Attr_RowingGetStrsList',['MyInt','MyStr','MyIntsList'])
]
)
)
MyStructurer.update(
[
('MyInt',1),
('MyStr',"bonjour"),
('MyIntsList',[0,0,1])
]
)['<Datome>ThingsRecoverer'].insert()
MyStructurer.update(
[
('MyInt',0),
('MyStr',"guten tag"),
('MyIntsList',[0,0,1])
]
)['<Datome>ThingsRecoverer'].insert()
MyStructurer.update(
[
('MyInt',1),
('MyStr',"bonjour"),
('MyIntsList',[0,0,0])
]
)['<Datome>ThingsRecoverer'].insert()
#Retrieve
MyStructurer['<Datome>ThingsRecoverer'].recover(
**{
'FindingConditionVariable':
[
('MyInt',(operator.eq,1)),
('MyIntsList',(SYS.getIsEqualBool,[0,0,1]))
]
}
)
#Definition the AttestedStr
SYS._attest(
[
'MyStructurer is '+SYS._str(
MyStructurer,
**{
'RepresentingBaseKeyStrsListBool':False,
'RepresentingAlineaIsBool':False
}
),
'hdf5 file is : '+MyStructurer.hdfview().hdfclose().HdformatedConsoleStr
]
)
#Print