bug fix: object merger
This commit is contained in:
parent
870b703296
commit
760eba62e1
|
@ -512,17 +512,26 @@ class Parser (Process):
|
|||
_claim['index'] = index #len(claims)
|
||||
# claims.append(dict(DEFAULT_VALUE,**_claim))
|
||||
#
|
||||
schema = [key for key in _claim.keys() if type(_claim[key]) == list]
|
||||
if schema :
|
||||
schema = {"properties":dict.fromkeys(schema,{"mergeStrategy":"append"})}
|
||||
# schema = [ {key:{"mergeStrategy":"append" if list( type(_claim[key])) else "overwrite"}} for key in _claim.keys()] # if type(_claim[key]) == list]
|
||||
# _schema = set(DEFAULT_VALUE.keys()) - schema
|
||||
# if schema :
|
||||
# schema = {"properties":dict.fromkeys(schema,{"mergeStrategy":"append"})}
|
||||
|
||||
else:
|
||||
schema = None
|
||||
# else:
|
||||
|
||||
# schema = {"properties":{}}
|
||||
|
||||
# schema = jsonmerge.merge(schema['properties'],dict.fromkeys(_schema,{"mergeStrategy":"overwrite"}))
|
||||
schema = {"properties":{}}
|
||||
for attr in _claim.keys() :
|
||||
schema['properties'][attr] = {"mergeStrategy": "append" if type(_claim[attr]) == list else "overwrite" }
|
||||
merger = jsonmerge.Merger(schema)
|
||||
if not schema :
|
||||
merger = jsonmerge
|
||||
_baseclaim = None
|
||||
_baseclaim = merger.merge(_baseclaim,DEFAULT_VALUE.copy())
|
||||
_claim = merger.merge(_baseclaim,_claim)
|
||||
|
||||
# _claim = merger.merge(DEFAULT_VALUE.copy(),_claim)
|
||||
|
||||
_claim = merger.merge(DEFAULT_VALUE.copy(),_claim)
|
||||
claims.append( _claim)
|
||||
segment = [row]
|
||||
|
||||
|
@ -539,22 +548,30 @@ class Parser (Process):
|
|||
claim = self.apply(segment,_code)
|
||||
if claim :
|
||||
claim['index'] = len(claims)
|
||||
schema = [key for key in claim.keys() if type(claim[key]) == list]
|
||||
if schema :
|
||||
schema = {"properties":dict.fromkeys(schema,{"mergeStrategy":"append"})}
|
||||
# schema = [key for key in claim.keys() if type(claim[key]) == list]
|
||||
# if schema :
|
||||
# schema = {"properties":dict.fromkeys(schema,{"mergeStrategy":"append"})}
|
||||
|
||||
else:
|
||||
schema = None
|
||||
# else:
|
||||
# print (claim.keys())
|
||||
# schema = {}
|
||||
#
|
||||
# @TODO: Fix merger related to schema (drops certain fields ... NOT cool)
|
||||
if not schema :
|
||||
merger = jsonmerge
|
||||
merger = jsonmerge.Merger(schema)
|
||||
|
||||
# merger = jsonmerge.Merger(schema)
|
||||
# top_row_claim = self.apply(_toprows,_code)
|
||||
|
||||
# claim = merger.merge(claim,self.apply(_toprows,_code))
|
||||
# claims.append(dict(DEFAULT_VALUE,**claim))
|
||||
claims.append(merger.merge(DEFAULT_VALUE.copy(),claim))
|
||||
schema = {"properties":{}}
|
||||
for attr in _claim.keys() :
|
||||
schema['properties'][attr] = {"mergeStrategy": "append" if type(_claim[attr]) == list else "overwrite" }
|
||||
_baseclaim = None
|
||||
_baseclaim = merger.merge(_baseclaim,DEFAULT_VALUE.copy())
|
||||
claim = merger.merge(_baseclaim,claim)
|
||||
claims.append(claim)
|
||||
|
||||
# claims.append(merger.merge(DEFAULT_VALUE.copy(),claim))
|
||||
if type(file) != list :
|
||||
file.close()
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -8,7 +8,7 @@ import sys
|
|||
def read(fname):
|
||||
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
||||
args = {
|
||||
"name":"healthcareio","version":"1.6.2.18",
|
||||
"name":"healthcareio","version":"1.6.2.20",
|
||||
"author":"Vanderbilt University Medical Center",
|
||||
"author_email":"steve.l.nyemba@vumc.org",
|
||||
"include_package_data":True,
|
||||
|
|
Loading…
Reference in New Issue