Skip to content

Commit c8df4e3

Browse files
committed
Add a new Resource.parent_path() function
This was removed in a previous commit. Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 6ad70df commit c8df4e3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/commoncode/resource.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,11 +1352,18 @@ def has_parent(self):
13521352
"""
13531353
return not self.is_root
13541354

1355+
def parent_path(self):
1356+
"""
1357+
Return the parent Resource object for this Resource or None.
1358+
"""
1359+
return self.has_parent() and parent_directory(self.path, with_trail=False)
1360+
13551361
def parent(self, codebase):
13561362
"""
13571363
Return the parent Resource object for this Resource or None.
13581364
"""
1359-
return codebase.get_resource(parent_directory(self.path, with_trail=False))
1365+
parent_path = self.parent_path()
1366+
return parent_path and codebase.get_resource(parent_path)
13601367

13611368
def has_siblings(self, codebase):
13621369
"""

0 commit comments

Comments
 (0)