File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88import json
99from typing import List
10+ from urllib .parse import urlparse
1011
1112import requests
1213
@@ -55,13 +56,22 @@ def is_not_empty(self) -> bool:
5556 """Return True if the queue contains any URIs."""
5657 return len (self .queue ) > 0
5758
59+ def sorted_queue (self ) -> List [str ]:
60+ """Return a list of queued URIs sorted by path depth (deepest first)."""
61+ return sorted (self .queue , key = self ._path_depth , reverse = True )
62+
63+ @staticmethod
64+ def _path_depth (uri : str ) -> int :
65+ """Return number of non-empty path segments in the URI."""
66+ return len ([part for part in urlparse (uri ).path .split ("/" ) if part ])
67+
5868 def execute (self ):
5969 """Execute all queued deletions.
6070
6171 Each queued URI will be deleted using `_delete_resource`.
6272 """
6373 _delete_list (
64- list (self .queue ),
74+ list (self .sorted_queue () ),
6575 self .databus_key ,
6676 force = True ,
6777 )
You can’t perform that action at this time.
0 commit comments