Reduced extractData.generateIndex() code size
This commit is contained in:
parent
de04fe734d
commit
eaaaae65b0
@ -174,42 +174,29 @@ class extractData:
|
|||||||
|
|
||||||
for obj in json.loads(self.infoJson):
|
for obj in json.loads(self.infoJson):
|
||||||
indexDict = {}
|
indexDict = {}
|
||||||
|
# Initialize keys with empty value
|
||||||
|
for k, v in i2IMap.items():
|
||||||
|
if v[1] == "string":
|
||||||
|
indexDict[v[0]] = ""
|
||||||
|
elif v[1] == "array":
|
||||||
|
indexDict[v[0]] = ()
|
||||||
|
else:
|
||||||
|
print(unexpectedInputError, v[1])
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
for k, v in obj.items():
|
for k, v in obj.items():
|
||||||
if k in i2IMap:
|
if k in i2IMap:
|
||||||
|
# Add/Append to existing entries/keys
|
||||||
# add new entry/key to app index
|
if i2IMap[k][1] == "string":
|
||||||
if k not in indexDict:
|
indexDict[i2IMap[k][0]] = (
|
||||||
if i2IMap[k][1] == "string":
|
indexDict[i2IMap[k][0]]+' '+v).strip(' ')
|
||||||
indexDict[i2IMap[k][0]] = v
|
elif i2IMap[k][1] == "array":
|
||||||
elif i2IMap[k][1] == "array":
|
if v.find(';') >= 0:
|
||||||
if v.find(';') >= 0:
|
indexDict[i2IMap[k][0]] += tuple(v.split(';'))
|
||||||
indexDict[i2IMap[k][0]] = v.split(';')
|
|
||||||
else:
|
|
||||||
indexDict[i2IMap[k][0]] = v.split()
|
|
||||||
|
|
||||||
# Append to existing entry/key to app index
|
|
||||||
else:
|
|
||||||
if i2IMap[k][1] == "string":
|
|
||||||
indexDict[i2IMap[k][0]] += ' '+v
|
|
||||||
elif i2IMap[k][1] == "array":
|
|
||||||
if v.find(';') >= 0:
|
|
||||||
indexDict[i2IMap[k][0]] += v.split(';')
|
|
||||||
else:
|
|
||||||
indexDict[i2IMap[k][0]] += v.split()
|
|
||||||
else:
|
else:
|
||||||
print(unexpectedInputError, i2IMap[k][1])
|
indexDict[i2IMap[k][0]] += tuple(v.split())
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Create entry/key with empty value for keys not present
|
|
||||||
# in activity.info
|
|
||||||
for k, v in i2IMap.items():
|
|
||||||
if v[0] not in indexDict:
|
|
||||||
if v[1] == "string":
|
|
||||||
indexDict[v[0]] = ""
|
|
||||||
elif v[1] == "array":
|
|
||||||
indexDict[v[0]] = ()
|
|
||||||
else:
|
else:
|
||||||
print(unexpectedInputError, v[1])
|
print(unexpectedInputError, i2IMap[k][1])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
self.indexDictList.append(indexDict)
|
self.indexDictList.append(indexDict)
|
||||||
|
Loading…
Reference in New Issue
Block a user