fix: Refactor the methods to avoid returning the same value

equipment being a dict, no need to use 'return' to have the changes
applied.

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: Ic5a4247bbaa0b4af3fca5b6cb0a74a2f434b1b6a
This commit is contained in:
EstherLerouzic
2024-12-16 21:34:36 +01:00
parent e55f7a5d4c
commit ccab4835fc

View File

@@ -439,14 +439,14 @@ def load_initial_spectrum(filename: Path) -> dict:
return _spectrum_from_json(json_data['spectrum'])
def _update_dual_stage(equipment: dict) -> dict:
def _update_dual_stage(equipment: dict):
"""Update attributes of all dual stage amps with the preamp and booster attributes
(defined in the equipment dictionary)
Returns the updated equiment dictionary
"""
if 'Edfa' not in equipment:
return equipment
return
edfa_dict = equipment['Edfa']
for edfa in edfa_dict.values():
if edfa.type_def == 'dual_stage':
@@ -465,11 +465,11 @@ def _update_dual_stage(equipment: dict) -> dict:
return equipment
def _update_band(equipment: dict) -> dict:
def _update_band(equipment: dict):
"""Creates a list of bands for this amplifier, and remove other parameters which are not applicable
"""
if 'Edfa' not in equipment:
return equipment
return
amp_dict = equipment['Edfa']
for amplifier in amp_dict.values():
if amplifier.type_def != 'multi_band':
@@ -489,8 +489,6 @@ def _update_band(equipment: dict) -> dict:
'nf_fit_coeff', 'nf_ripple', 'dgt', 'gain_ripple']:
delattr(amplifier, key)
return equipment
def _roadm_restrictions_sanity_check(equipment: dict):
"""verifies that booster and preamp restrictions specified in roadm equipment are listed in the edfa."""
@@ -567,8 +565,8 @@ def _equipment_from_json(json_data: dict, extra_configs: Dict[str, Path]) -> dic
else:
raise EquipmentConfigError(f'Unrecognized network element type "{key}"')
_check_fiber_vs_raman_fiber(equipment)
equipment = _update_dual_stage(equipment)
equipment = _update_band(equipment)
_update_dual_stage(equipment)
_update_band(equipment)
_roadm_restrictions_sanity_check(equipment)
_si_sanity_check(equipment)
return equipment