MCPcopy
hub / github.com/omkarcloud/botasaurus / write_output

Function write_output

botasaurus/decorators_common.py:181–214  ·  view source on GitHub ↗
(output, output_formats, data, result, fn_name)

Source from the content-addressed store, hash-verified

179
180
181def write_output(output, output_formats, data, result, fn_name):
182 written_filenames = []
183
184 if output is None:
185 # Output is disabled
186 return result
187
188 if callable(output):
189 # Dynamic output handling
190 output(data, result)
191 else:
192 # Default format is JSON if not specified
193 output_formats = output_formats or ["JSON"]
194
195 if output == "default":
196 default_filename = fn_name
197 else:
198 default_filename = output
199
200 for fm in output_formats:
201 if fm == Formats.JSON:
202 filename = fix_json_filename(default_filename)
203 written_filenames.append(filename)
204 write_json(result, filename, False)
205 elif fm == Formats.CSV:
206 filename = fix_csv_filename(default_filename)
207 written_filenames.append(filename)
208 write_csv(result, filename, False)
209 elif fm == Formats.EXCEL:
210 filename = fix_excel_filename(default_filename)
211 written_filenames.append(filename)
212 write_excel(result, filename, False)
213
214 print_filenames(written_filenames)
215
216
217def clean_error_logs(error_logs_dir, sort_key):

Callers 6

wrapper_requestsFunction · 0.90
_workerFunction · 0.90
wrapper_browserFunction · 0.90
_workerFunction · 0.90
wrapper_requestsFunction · 0.90
_workerFunction · 0.90

Calls 7

fix_json_filenameFunction · 0.85
fix_csv_filenameFunction · 0.85
write_csvFunction · 0.85
fix_excel_filenameFunction · 0.85
write_excelFunction · 0.85
print_filenamesFunction · 0.85
write_jsonFunction · 0.70

Tested by

no test coverage detected