Skip to content

Commit

Permalink
fix sonar cloud
Browse files Browse the repository at this point in the history
DCO Remediation Commit for Martijn Govers <[email protected]>

I, Martijn Govers <[email protected]>, hereby add my Signed-off-by to this commit: a148355
I, Martijn Govers <[email protected]>, hereby add my Signed-off-by to this commit: bec331e

Signed-off-by: Martijn Govers <[email protected]>
  • Loading branch information
mgovers committed Oct 6, 2023
1 parent 9234238 commit ed81435
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/power_grid_model_io/converters/pgm_json_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,23 @@ def _extract_extra_info(

for component, component_data in original_data.items():
for entry in component_data:
entry_id = entry["id"]
reserialized_entry = self._get_first_by(reserialized_data[component], "id", entry_id)
if reserialized_entry is None:
warnings.warn(f"The extra info cannot be determined for component '{component}' with ID {entry_id}")
continue
self._extract_extra_component_info(component, entry, reserialized_data, extra_info)

for attribute, value in entry.items():
if attribute in reserialized_entry:
continue
def _extract_extra_component_info(
self, component: str, attributes: Dict[str, Any], reserialized_data: SingleDataset, extra_info: ExtraInfo
):
entry_id = attributes["id"]
reserialized_entry = self._get_first_by(reserialized_data[component], "id", entry_id)
if reserialized_entry is None:
warnings.warn(f"The extra info cannot be determined for component '{component}' with ID {entry_id}")
return

if entry_id not in extra_info:
extra_info[entry_id] = {}
for attribute, value in attributes.items():
if attribute not in reserialized_entry:
if entry_id not in extra_info:
extra_info[entry_id] = {}

extra_info[entry_id][attribute] = value
extra_info[entry_id][attribute] = value

@staticmethod
def _get_first_by(data: List[Dict[str, Any]], field: str, value: Any) -> Optional[Dict[str, Any]]:
Expand Down

0 comments on commit ed81435

Please sign in to comment.