update
This commit is contained in:
parent
136be5f05f
commit
11f01610c3
@ -12,14 +12,18 @@ def write_to_file(content, file_path: Path, json_dumps=False, indent=None):
|
||||
file_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(file_path, mode="w") as f:
|
||||
if json_dumps:
|
||||
return f.write(
|
||||
json.dumps(
|
||||
content, indent=indent, ensure_ascii=False, default=serialize_sets
|
||||
)
|
||||
)
|
||||
return f.write(json.dumps(content, indent=indent, ensure_ascii=False, default=serialize_sets))
|
||||
return f.write(content)
|
||||
|
||||
|
||||
def write_to_json_file(content, file_path: str, indent: int | None =4):
|
||||
pwd = Path(__file__).resolve().parent.parent
|
||||
file = pwd / file_path
|
||||
file.parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(file, mode="w") as f:
|
||||
return f.write(json.dumps(content, indent=indent, ensure_ascii=False, default=serialize_sets))
|
||||
|
||||
|
||||
def append_to_file(content: str, file_path: Path):
|
||||
file_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(file_path, mode="a") as f:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user