Skip to content

Commit 5c6f4f2

Browse files
committed
Improve deprecated data-path syntax detection in DictionaryDomain
Namely, detect previous-style data paths if: - they contain '`', and, - their first fragment (after split on '`') is identical to the name of one dictionary from the domain.
1 parent 82ee065 commit 5c6f4f2

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

khiops/core/dictionary.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -325,17 +325,21 @@ def get_dictionary_at_data_path(self, data_path):
325325
`ValueError`
326326
If the path is not found.
327327
"""
328-
# If data_path includes "`" but not "/", assume legacy data path
329-
if "`" in data_path and not "/" in data_path:
330-
warnings.warn(
331-
deprecation_message(
332-
"'`'-based dictionary data path convention",
333-
"11.0.1",
334-
replacement="'/'-based dictionary data path convention",
335-
quote=False,
328+
# If data_path includes "`" and starts with an existing dictionary,
329+
# assume legacy data path
330+
if "`" in data_path:
331+
data_path_parts = data_path.split("`")
332+
source_dictionary_name = data_path_parts[0]
333+
if any(kdic.name == source_dictionary_name for kdic in self.dictionaries):
334+
warnings.warn(
335+
deprecation_message(
336+
"'`'-based dictionary data path convention",
337+
"11.0.1",
338+
replacement="'/'-based dictionary data path convention",
339+
quote=False,
340+
)
336341
)
337-
)
338-
return self._get_dictionary_at_data_path_legacy(data_path)
342+
return self._get_dictionary_at_data_path_legacy(data_path)
339343
return self._get_dictionary_at_data_path(data_path)
340344

341345
def _get_dictionary_at_data_path_legacy(self, data_path):

0 commit comments

Comments
 (0)