From c189df9547017fa049977d44ed1637f6a929a20e Mon Sep 17 00:00:00 2001 From: Florin Tobler Date: Thu, 2 Jan 2025 02:08:49 +0100 Subject: [PATCH] save string to file for command line debug --- utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils.py b/utils.py index 4936a6a..467d880 100644 --- a/utils.py +++ b/utils.py @@ -1,10 +1,19 @@ import json import sys +import datetime + def load_json_file(filepath: str) -> any: with open(filepath, "r") as f: return json.load(f) +def save_string_as_file(content: str, filepath: str = None) -> None: + if filepath == None: + filepath = "temp_" + datetime.datetime.now().strftime("%Y%m%d_%H%M%S") + ".txt" + + with open(filepath, "w") as f: + f.write(content) + def print_error(*args, **kwargs):