From 22aaba370c2a07bbf54c5666a09781a434438118 Mon Sep 17 00:00:00 2001 From: tdruez Date: Mon, 16 Jun 2025 18:58:01 +0400 Subject: [PATCH] Rename the parent_path function to parent_directory #1691 In preparation of adding parent_path as a field #1691 Signed-off-by: tdruez --- scanpipe/models.py | 6 +++--- scanpipe/tests/test_models.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scanpipe/models.py b/scanpipe/models.py index 93e31448f..1670eba00 100644 --- a/scanpipe/models.py +++ b/scanpipe/models.py @@ -2849,7 +2849,7 @@ def get_path_segments_with_subpath(self): return part_and_subpath - def parent_path(self): + def parent_directory(self): """Return the parent path for this CodebaseResource or None.""" return parent_directory(self.path, with_trail=False) @@ -2858,7 +2858,7 @@ def has_parent(self): Return True if this CodebaseResource has a parent CodebaseResource or False otherwise. """ - parent_path = self.parent_path() + parent_path = self.parent_directory() if not parent_path: return False if self.project.codebaseresources.filter(path=parent_path).exists(): @@ -2873,7 +2873,7 @@ def parent(self, codebase=None): `codebase` is not used in this context but required for compatibility with the commoncode.resource.Codebase class API. """ - parent_path = self.parent_path() + parent_path = self.parent_directory() return parent_path and self.project.codebaseresources.get(path=parent_path) def siblings(self, codebase=None): diff --git a/scanpipe/tests/test_models.py b/scanpipe/tests/test_models.py index a0eadf5cd..f1252942a 100644 --- a/scanpipe/tests/test_models.py +++ b/scanpipe/tests/test_models.py @@ -2053,7 +2053,7 @@ def test_scanpipe_codebase_resource_model_walk_method(self): path="asgiref-3.3.0.whl-extract/asgiref/compatibility.py" ) expected_parent_path = "asgiref-3.3.0.whl-extract/asgiref" - self.assertEqual(expected_parent_path, asgiref_resource.parent_path()) + self.assertEqual(expected_parent_path, asgiref_resource.parent_directory()) self.assertTrue(asgiref_resource.has_parent()) expected_parent = self.project_asgiref.codebaseresources.get( path="asgiref-3.3.0.whl-extract/asgiref"