@@ -16,23 +16,24 @@ def __init__(self, url=None, start_time=None, proposed_limit=100):
1616 self .current_offset = 0
1717
1818 def __call__ (self ):
19- api = RemoteCKAN (
19+ with RemoteCKAN (
2020 self .url ,
21- user_agent = "data-subscription/latest (API call for CKAN recent activity pull)" ,
22- )
23- self .activity_list = []
24- while True :
25- response = api .action .recently_changed_packages_activity_list (
26- limit = self .server_limit , offset = self .current_offset
27- )
28- self .activity_list += self .filter_response_for_time_range (response )
29- if self .current_offset == 0 :
30- self .server_limit = len (response )
31- self .current_offset += self .server_limit
32- if self .has_reached_the_end (response ):
33- break
34- RemoteCKAN .close (api )
35- return self .activity_list
21+ user_agent =
22+ "data-subscription/latest (API call for CKAN recent activity pull)" ,
23+ ) as api :
24+
25+ self .activity_list = []
26+ while True :
27+ response = api .action .recently_changed_packages_activity_list (
28+ limit = self .server_limit , offset = self .current_offset
29+ )
30+ self .activity_list += self .filter_response_for_time_range (response )
31+ if self .current_offset == 0 :
32+ self .server_limit = len (response )
33+ self .current_offset += self .server_limit
34+ if self .has_reached_the_end (response ):
35+ break
36+ return self .activity_list
3637
3738 def filter_response_for_time_range (self , response ):
3839 def is_in_time_range (item ):
0 commit comments