yes-man-today
commited on
Commit
•
d664719
1
Parent(s):
db36a72
force stopping
Browse files- regulatory_comments_api.py +10 -0
regulatory_comments_api.py
CHANGED
@@ -85,7 +85,12 @@ class RegulationsDataFetcher:
|
|
85 |
def collect_data(self):
|
86 |
"""Collect data and reshape into nested dictionary format."""
|
87 |
data = self.fetch_comments()
|
|
|
|
|
|
|
88 |
docket_info = self.get_docket_info()
|
|
|
|
|
89 |
|
90 |
# Initialize the nested dictionary structure
|
91 |
nested_data = {
|
@@ -264,6 +269,11 @@ class RegCommentsAPI(datasets.GeneratorBasedBuilder):
|
|
264 |
for docket_id in dockets:
|
265 |
fetcher = RegulationsDataFetcher(docket_id, api_key) # Initialize with the API key
|
266 |
docket_data = fetcher.collect_data()
|
|
|
|
|
|
|
|
|
|
|
267 |
if len(docket_data["comments"]) != 0:
|
268 |
yield docket_id, docket_data
|
269 |
|
|
|
85 |
def collect_data(self):
|
86 |
"""Collect data and reshape into nested dictionary format."""
|
87 |
data = self.fetch_comments()
|
88 |
+
if data is None:
|
89 |
+
return None # Early return if fetching comments fails
|
90 |
+
|
91 |
docket_info = self.get_docket_info()
|
92 |
+
if docket_info is None:
|
93 |
+
return None
|
94 |
|
95 |
# Initialize the nested dictionary structure
|
96 |
nested_data = {
|
|
|
269 |
for docket_id in dockets:
|
270 |
fetcher = RegulationsDataFetcher(docket_id, api_key) # Initialize with the API key
|
271 |
docket_data = fetcher.collect_data()
|
272 |
+
|
273 |
+
if docket_data is None:
|
274 |
+
print(f"API Rate Limit Reached.")
|
275 |
+
break
|
276 |
+
|
277 |
if len(docket_data["comments"]) != 0:
|
278 |
yield docket_id, docket_data
|
279 |
|