Skip to content

Commit

Permalink
Add mitigation for do_lowercase_strings being applied to everything i…
Browse files Browse the repository at this point in the history
…n the source node interpretation
  • Loading branch information
zprobst committed Jul 30, 2024
1 parent 760ef38 commit baa9cd2
Show file tree
Hide file tree
Showing 4 changed files with 6,211 additions and 6,176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,39 @@ def __init__(
additional_indexes: Optional[List[str]] = None,
additional_types: Optional[List[str]] = None,
normalization: Optional[Dict[str, Any]] = None,
properties_normalization: Optional[Dict[str, Any]] = None,
key_normalization: Optional[Dict[str, Any]] = None,
allow_create: bool = True,
):
if normalization and (properties_normalization or key_normalization):
raise ValueError(
"You cannot specify normalization both at the root and at the key/properties level."
)

properties_normalization = properties_normalization or normalization
key_normalization = key_normalization or normalization
self.key_normalization = {
**DEFAULT_NORMALIZATION_ARGUMENTS,
**(key_normalization or {}),
}
self.properties_normalization = properties_normalization or {}
self.node_type = ValueProvider.guarantee_value_provider(node_type)
self.key = PropertyMapping.from_file_data(key or {})
self.properties = PropertyMapping.from_file_data(properties or {})
self.additional_indexes = additional_indexes or []
self.additional_types = tuple(additional_types or [])
self.norm_args = {**DEFAULT_NORMALIZATION_ARGUMENTS, **(normalization or {})}
if allow_create:
self.creation_rule = NodeCreationRule.EAGER
else:
self.creation_rule = NodeCreationRule.MATCH_ONLY

def interpret(self, context: ProviderContext):
normalized_key: PropertySet = PropertySet()
self.key.apply_to(context, normalized_key, self.norm_args)
self.key.apply_to(context, normalized_key, self.key_normalization)
normalized_properties: PropertySet = PropertySet()
self.properties.apply_to(context, normalized_properties, self.norm_args)
self.properties.apply_to(
context, normalized_properties, self.properties_normalization
)

context.desired_ingest.add_source_node(
self.node_type.single_value(context),
Expand Down
Loading

0 comments on commit baa9cd2

Please sign in to comment.