in parse_copybook_to_json.py [0:0]
def CreateExtraction(obj, altstack=[], keylength=0):
global lrecl
for k in obj:
if type(obj[k]) is dict:
t = 1 if 'occurs' not in obj[k] else obj[k]['occurs']
iTimes = 0
while iTimes < t:
iTimes +=1
if 'redefines' not in obj[k]:
if obj[k]['group'] == True:
altstack.append(k)
CreateExtraction(obj[k], altstack, keylength)
altstack.remove(k)
else:
item = {}
item['type'] = obj[k]['type']
item['bytes'] = obj[k]['bytes']
item['offset'] = lrecl
item['dplaces'] = obj[k]['dplaces']
item['name'] = k
item['key'] = True if (lrecl + obj[k]['bytes']) <= keylength else False
transf.append(item)
lrecl = lrecl + obj[k]['bytes']
else:
add2alt = True
for x in altlay:
if x[list(x)[0]]['newname'] == k:
add2alt = False
if add2alt:
red = {}
red[obj[k]['redefines']] = obj[k].copy()
red[obj[k]['redefines']]['newname'] = k
red[obj[k]['redefines']]['stack'] = altstack.copy()
altlay.append(red)