Refactored code

This commit is contained in:
Kevin Veen-Birkenbach 2025-01-10 02:39:33 +01:00
parent e2aee76f54
commit cdfefe5a63

View File

@ -74,6 +74,7 @@ class ConfigurationResolver:
KeyError: If the path cannot be resolved.
ValueError: If the resolved entry is not of the expected type.
"""
print(f"Current path being resolved: {path}")
parts = path.split('.') # Split the path into segments
current = config
@ -115,9 +116,8 @@ class ConfigurationResolver:
)
# Stop navigating into `subitems` unless explicitly required by the path
if isinstance(current, dict) and "subitems" in current and isinstance(current["subitems"], list):
if part != "subitems":
break # Stop navigation if `subitems` is not explicitly in the path
if isinstance(current, dict) and "subitems" in current and isinstance(current["subitems"], list) and part != "subitems":
break # Stop navigation if `subitems` is not explicitly in the path
# Ensure the resolved target is a dictionary or string
if not isinstance(current, (dict, str)):