python package restructuring

This commit is contained in:
2025-01-14 20:29:29 +01:00
parent 0c022d4731
commit 7224111a0b
27 changed files with 97 additions and 74 deletions

20
chatbug/utils.py Normal file
View File

@@ -0,0 +1,20 @@
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):
print(*args, file=sys.stderr, **kwargs)