changes to improve quality

minor name refactor
indent corrections
minor fixes for spacing

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
This commit is contained in:
EstherLerouzic
2019-05-31 17:16:51 +01:00
parent 609cd94798
commit dfa0a26a28
3 changed files with 70 additions and 69 deletions

View File

@@ -162,7 +162,8 @@ class Result_element(Element):
},
{
'metric-type': 'SNR-0.1nm',
'accumulative-value': round(mean(self.computed_path[-1].snr+lin2db(self.path_request.baud_rate/12.5e9)),2)
'accumulative-value': round(mean(self.computed_path[-1]. snr + \
lin2db(self.path_request.baud_rate/12.5e9)), 2)
},
{
'metric-type': 'OSNR-bandwidth',
@@ -402,10 +403,10 @@ def jsontocsv(json_data,equipment,fileout):
tspjsondata = equipment['Transceiver']
#print(tspjsondata)
for p in json_data['response']:
path_id = p['response-id']
for pth_el in json_data['response']:
path_id = pth_el['response-id']
try:
if p['no-path'] :
if pth_el['no-path'] :
source = ''
destination = ''
tsp = ''
@@ -421,13 +422,14 @@ def jsontocsv(json_data,equipment,fileout):
total_cost = ''
pth = ''
except KeyError:
source = p['path-properties']['path-route-objects'][0]\
source = pth_el['path-properties']['path-route-objects'][0]\
['path-route-object']['num-unnum-hop']['node-id']
destination = p['path-properties']['path-route-objects'][-2]\
destination = pth_el['path-properties']['path-route-objects'][-2]\
['path-route-object']['num-unnum-hop']['node-id']
# selects only roadm nodes
temp = []
for e in p['path-properties']['path-route-objects'] :
for e in pth_el['path-properties']['path-route-objects']:
try :
temp.append(e['path-route-object']['num-unnum-hop']['node-id'])
except KeyError:
@@ -446,19 +448,18 @@ def jsontocsv(json_data,equipment,fileout):
for m in equipment['Transceiver'][tsp].mode if m['format']==mode)
# else:
# [minosnr, baud_rate, bit_rate] = ['','','','']
output_snr = next(e['accumulative-value']
for e in p['path-properties']['path-metric'] if e['metric-type'] == 'SNR-0.1nm')
for e in pth_el['path-properties']['path-metric'] if e['metric-type'] == 'SNR-0.1nm')
output_snrbandwidth = next(e['accumulative-value']
for e in p['path-properties']['path-metric'] if e['metric-type'] == 'SNR-bandwidth')
for e in pth_el['path-properties']['path-metric'] if e['metric-type'] == 'SNR-bandwidth')
output_osnr = next(e['accumulative-value']
for e in p['path-properties']['path-metric'] if e['metric-type'] == 'OSNR-0.1nm')
for e in pth_el['path-properties']['path-metric'] if e['metric-type'] == 'OSNR-0.1nm')
output_osnrbandwidth = next(e['accumulative-value']
for e in p['path-properties']['path-metric'] if e['metric-type'] == 'OSNR-bandwidth')
for e in pth_el['path-properties']['path-metric'] if e['metric-type'] == 'OSNR-bandwidth')
power = next(e['accumulative-value']
for e in p['path-properties']['path-metric'] if e['metric-type'] == 'reference_power')
for e in pth_el['path-properties']['path-metric'] if e['metric-type'] == 'reference_power')
path_bandwidth = next(e['accumulative-value']
for e in p['path-properties']['path-metric'] if e['metric-type'] == 'path_bandwidth')
for e in pth_el['path-properties']['path-metric'] if e['metric-type'] == 'path_bandwidth')
if isinstance(output_snr, str):
isok = False
nb_tsp = 0

View File

@@ -56,7 +56,7 @@
"link-tp-id": null
}
}
},
}
]
}
}