ripple-down-rules 0.5.85__py3-none-any.whl → 0.5.86__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- __version__ = "0.5.85"
1
+ __version__ = "0.5.86"
2
2
 
3
3
  import logging
4
4
  logger = logging.Logger("rdr")
@@ -863,14 +863,14 @@ def get_relative_import(target_file_path, imported_module_path: Optional[str] =
863
863
  # Convert to absolute paths
864
864
  target_path = Path(target_file_path).resolve()
865
865
  if package_name is not None:
866
- target_path = Path(get_path_starting_from(str(target_path), package_name))
866
+ target_path = Path(get_path_starting_from_latest_encounter_of(str(target_path), package_name))
867
867
  if module is not None:
868
868
  imported_module_path = sys.modules[module].__file__
869
869
  if imported_module_path is None:
870
870
  raise ValueError("Either imported_module_path or module must be provided")
871
871
  imported_path = Path(imported_module_path).resolve()
872
872
  if package_name is not None:
873
- imported_path = Path(get_path_starting_from(str(imported_path), package_name))
873
+ imported_path = Path(get_path_starting_from_latest_encounter_of(str(imported_path), package_name))
874
874
 
875
875
  # Compute relative path from target to imported module
876
876
  rel_path = os.path.relpath(imported_path.parent, target_path.parent)
@@ -878,15 +878,18 @@ def get_relative_import(target_file_path, imported_module_path: Optional[str] =
878
878
  # Convert path to Python import format
879
879
  rel_parts = [part.replace('..', '.') for part in Path(rel_path).parts]
880
880
  rel_parts = rel_parts if rel_parts else ['']
881
+ dot_parts = [part for part in rel_parts if part == '.']
882
+ non_dot_parts = [part for part in rel_parts if part != '.']
883
+
881
884
 
882
885
  # Join the parts and add the module name
883
- joined_parts = "".join(rel_parts) + f".{imported_path.stem}"
886
+ joined_parts = "".join(dot_parts) + ".".join(non_dot_parts) + f".{imported_path.stem}"
884
887
  joined_parts = f".{joined_parts}" if not joined_parts.startswith(".") else joined_parts
885
888
 
886
889
  return joined_parts
887
890
 
888
891
 
889
- def get_path_starting_from(path: str, package_name: str) -> Optional[str]:
892
+ def get_path_starting_from_latest_encounter_of(path: str, package_name: str) -> Optional[str]:
890
893
  """
891
894
  Get the path starting from the package name.
892
895
 
@@ -895,7 +898,7 @@ def get_path_starting_from(path: str, package_name: str) -> Optional[str]:
895
898
  :return: The path starting from the package name or None if not found.
896
899
  """
897
900
  if package_name in path:
898
- idx = path.index(package_name)
901
+ idx = path.rfind(package_name)
899
902
  return path[idx:]
900
903
  return None
901
904
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ripple_down_rules
3
- Version: 0.5.85
3
+ Version: 0.5.86
4
4
  Summary: Implements the various versions of Ripple Down Rules (RDR) for knowledge representation and reasoning.
5
5
  Author-email: Abdelrhman Bassiouny <abassiou@uni-bremen.de>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,11 +1,11 @@
1
- ripple_down_rules/__init__.py,sha256=49RvNTpGUXv7fYtLSLpbwGCoAhuRvpyyEmnErrZRwHs,100
1
+ ripple_down_rules/__init__.py,sha256=yHGpD2EOFIRVmTQHKqc3fRmy_stAXTnnT3m1K9MGr6o,100
2
2
  ripple_down_rules/experts.py,sha256=bwozulI1rv0uyaMZQqEgapDO-s8wvW0D6Jqxmvu5fik,12610
3
3
  ripple_down_rules/helpers.py,sha256=v4oE7C5PfQUVJfSUs1FfLHEwrJXEHJLn4vJhJMvyCR8,4453
4
4
  ripple_down_rules/rdr.py,sha256=C6bvlq6MsKa2Mym1wW6JUMj705aCaoihTP279TM6eT0,55218
5
5
  ripple_down_rules/rdr_decorators.py,sha256=amXUjgc-rfYxPKFW16Xm8Z9vfaaslNl5OvDOg9fKaTg,9447
6
6
  ripple_down_rules/rules.py,sha256=iVevv6iZ-6L2IPI0ZYbBjxBymXEQMmJGRFhiKUS-NmA,20352
7
7
  ripple_down_rules/start-code-server.sh,sha256=otClk7VmDgBOX2TS_cjws6K0UwvgAUJhoA0ugkPCLqQ,949
8
- ripple_down_rules/utils.py,sha256=VMOjMU2YyhUMDfBSZSjQlqi6ka-0cu014hl3OGTu3pQ,60962
8
+ ripple_down_rules/utils.py,sha256=ZDyrStxnIBcjlgrwOQt-6fPkZXy_WMZwn3na5JCFqEw,61173
9
9
  ripple_down_rules/datastructures/__init__.py,sha256=V2aNgf5C96Y5-IGghra3n9uiefpoIm_QdT7cc_C8cxQ,111
10
10
  ripple_down_rules/datastructures/callable_expression.py,sha256=f3wUPTrLa1INO-1qfgVz87ryrCABronfyq0_JKWoZCs,12800
11
11
  ripple_down_rules/datastructures/case.py,sha256=1zSaXUljaH6z3SgMGzYPoDyjotNam791KpYgvxuMh90,15463
@@ -17,8 +17,8 @@ ripple_down_rules/user_interface/ipython_custom_shell.py,sha256=Jrf7NxOdlrwGXH0X
17
17
  ripple_down_rules/user_interface/object_diagram.py,sha256=FEa2HaYR9QmTE6NsOwBvZ0jqmu3DKyg6mig2VE5ZP4Y,4956
18
18
  ripple_down_rules/user_interface/prompt.py,sha256=AkkltdDIaioN43lkRKDPKSjJcmdSSGZDMYz7AL7X9lE,8082
19
19
  ripple_down_rules/user_interface/template_file_creator.py,sha256=xWUt-RHRqrvoMo74o-bMLo8xNxil68wgbOZAMADZp2A,13570
20
- ripple_down_rules-0.5.85.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
21
- ripple_down_rules-0.5.85.dist-info/METADATA,sha256=1tFTBGloFOMxSnYhJT6h5obVH_-UNfKQumICBkDmmwU,48214
22
- ripple_down_rules-0.5.85.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- ripple_down_rules-0.5.85.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
24
- ripple_down_rules-0.5.85.dist-info/RECORD,,
20
+ ripple_down_rules-0.5.86.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
21
+ ripple_down_rules-0.5.86.dist-info/METADATA,sha256=zQp8XNkCxkNEZu9rxpj4KpSYF2wtqua9cVR2d73gEbM,48214
22
+ ripple_down_rules-0.5.86.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ ripple_down_rules-0.5.86.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
24
+ ripple_down_rules-0.5.86.dist-info/RECORD,,