Skip to content

Commit

Permalink
fix: Apply fix from #3, closes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Feb 6, 2025
1 parent 2338fe9 commit d4efb45
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 40 deletions.
35 changes: 0 additions & 35 deletions docs/make.bat

This file was deleted.

9 changes: 4 additions & 5 deletions nightingale/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ def transform_row(
:param result: Existing result dictionary to update.
:return: Transformed row dictionary.
"""
if array_counters is None:
array_counters = {}

# XXX: some duplication in code present maybe refactoring needed
def set_nested_value(nested_dict, keys, value, schema, add_new=False, append_once=False):
value = self.map_codelist_value(keys, schema, codelists, value)
Expand Down Expand Up @@ -192,14 +189,16 @@ def set_nested_value(nested_dict, keys, value, schema, add_new=False, append_onc
# case for /parties/roles
set_nested_value(result, keys, value, flattened_schema, add_new=True, append_once=True)
continue
elif array_counters is None:
array_counters = {}
elif array_path in array_counters:
if add_new := is_new_array(array_counters, child_path, last_key_name, array_value, array_path):
array_counters[array_path] = array_value
set_nested_value(result, keys[:-1], {}, flattened_schema, add_new=add_new)
else:
if last_key_name == "id":
array_counters[array_path] = array_value
set_nested_value(result, keys[:-1], [{}], flattened_schema)
set_nested_value(result, keys[:-1], {}, flattened_schema, True)

current = result
for i, key in enumerate(keys[:-1]):
Expand All @@ -223,7 +222,7 @@ def set_nested_value(nested_dict, keys, value, schema, add_new=False, append_onc
def shift_current_array(self, current, array_path, array_counters):
if not current:
current.append({})
return find_array_element_by_id(current, array_counters.get(array_path))
return find_array_element_by_id(current, array_counters.get(array_path) if array_counters else None)

def make_release_id(self, curr_row: dict) -> None:
"""
Expand Down

0 comments on commit d4efb45

Please sign in to comment.