bug fix: adding references using cache
This commit is contained in:
parent
0870e3da6a
commit
2e815a0a0d
|
@ -217,9 +217,9 @@ class Parser (Process):
|
||||||
self._custom_config = self.get_custom(path)
|
self._custom_config = self.get_custom(path)
|
||||||
self.config = _config['parser']
|
self.config = _config['parser']
|
||||||
self.store = _config['store']
|
self.store = _config['store']
|
||||||
|
self.cache = {}
|
||||||
self.files = []
|
self.files = []
|
||||||
self.set = void()
|
self.set = void()
|
||||||
self.set.files = self.set_files
|
self.set.files = self.set_files
|
||||||
self.emit = void()
|
self.emit = void()
|
||||||
self.emit.pre = None
|
self.emit.pre = None
|
||||||
|
@ -349,6 +349,24 @@ class Parser (Process):
|
||||||
# object_value = {label:object_value}
|
# object_value = {label:object_value}
|
||||||
|
|
||||||
return object_value
|
return object_value
|
||||||
|
def set_cache(self,tmp,_info) :
|
||||||
|
"""
|
||||||
|
insert into cache a value that the, these are in reference to a loop
|
||||||
|
"""
|
||||||
|
if 'cache' in _info :
|
||||||
|
key = _info['cache']['key']
|
||||||
|
value=_info['cache']['value']
|
||||||
|
field = _info['cache']['field']
|
||||||
|
if value in tmp :
|
||||||
|
self.cache [key] = {field:tmp[value]}
|
||||||
|
pass
|
||||||
|
def get_cache(self,row) :
|
||||||
|
"""
|
||||||
|
retrieve cache element for a current
|
||||||
|
"""
|
||||||
|
key = row[0]
|
||||||
|
return self.cache[key] if key in self.cache else {}
|
||||||
|
pass
|
||||||
def apply(self,content,_code) :
|
def apply(self,content,_code) :
|
||||||
"""
|
"""
|
||||||
:content content of a file i.e a segment with the envelope
|
:content content of a file i.e a segment with the envelope
|
||||||
|
@ -375,12 +393,15 @@ class Parser (Process):
|
||||||
|
|
||||||
_info = jsonmerge.merge(_info,_cinfo)
|
_info = jsonmerge.merge(_info,_cinfo)
|
||||||
tmp = self.get.value(row,_info)
|
tmp = self.get.value(row,_info)
|
||||||
#
|
|
||||||
# let's prune the objects not found
|
|
||||||
|
|
||||||
|
|
||||||
if not tmp :
|
if not tmp :
|
||||||
continue
|
continue
|
||||||
|
#
|
||||||
|
# At this point we have the configuration and the row parsed into values
|
||||||
|
# We should check to see if we don't have anything in the cache to be added to it
|
||||||
|
#
|
||||||
|
if row[0] in self.cache :
|
||||||
|
tmp = jsonmerge.merge(tmp,self.get_cache(row))
|
||||||
|
|
||||||
if 'label' in _info :
|
if 'label' in _info :
|
||||||
label = _info['label']
|
label = _info['label']
|
||||||
|
@ -417,6 +438,14 @@ class Parser (Process):
|
||||||
print (e.args[0])
|
print (e.args[0])
|
||||||
# print ('__',(dir(e.args)))
|
# print ('__',(dir(e.args)))
|
||||||
pass
|
pass
|
||||||
|
#
|
||||||
|
# At this point the object is completely built,
|
||||||
|
# if there ar any attributes to be cached it will be done here
|
||||||
|
#
|
||||||
|
|
||||||
|
if 'cache' in _info :
|
||||||
|
|
||||||
|
self.set_cache(tmp,_info)
|
||||||
|
|
||||||
return value if value else {}
|
return value if value else {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue