Merged in hotfix/defensive-crosswalk (pull request #632)
Hotfix/defensive crosswalk handling * Enhance crosswalk functionality with flatten_to_strings helper and improve value handling in apply_crosswalk * Improve apply_crosswalk function to return original value as fallback when no mapping is found * Enhance apply_crosswalk function to handle empty values and improve defensive programming tests * move flatten_to_strings helper function to string_utils Approved-by: Katon Minhas
This commit is contained in:
@@ -587,3 +587,24 @@ def normalize_state_to_abbreviation(state_value: str) -> str:
|
||||
|
||||
# If no match found, return original value
|
||||
return state_value
|
||||
|
||||
def flatten_to_strings(items) -> list[str]:
|
||||
"""Helper function to flatten and stringify any nested structure
|
||||
|
||||
Args:
|
||||
items (Any): The input items; can be a list, tuple, or single value
|
||||
|
||||
Returns:
|
||||
list[str]: A flattened list of stringified items
|
||||
"""
|
||||
result = []
|
||||
if isinstance(items, (list, tuple)):
|
||||
for item in items:
|
||||
if isinstance(item, (list, tuple)):
|
||||
result.extend(flatten_to_strings(item))
|
||||
else:
|
||||
result.append(str(item).strip())
|
||||
else:
|
||||
result.append(str(items).strip())
|
||||
|
||||
return result
|
||||
Reference in New Issue
Block a user