mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-27 21:24:16 -04:00
add proper typechecked json parsing and dumping
This commit is contained in:
parent
35c05c321f
commit
73f46b0b29
3 changed files with 75 additions and 22 deletions
archivebox
|
@ -675,8 +675,8 @@ class ExtendedEncoder(JSONEncoder):
|
|||
return JSONEncoder.default(self, obj)
|
||||
|
||||
|
||||
def atomic_write(contents: Union[dict, str], path: str):
|
||||
"""Safe atomic file write and swap using a tmp file"""
|
||||
def atomic_write(contents: Union[dict, str], path: str) -> None:
|
||||
"""Safe atomic write to filesystem by writing to temp file + atomic rename"""
|
||||
try:
|
||||
tmp_file = '{}.tmp'.format(path)
|
||||
with open(tmp_file, 'w+', encoding='utf-8') as f:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue