Fix "dumping" message to work correctly for .gz files
This commit is contained in:
parent
abc6b9459a
commit
8f214aec89
@ -47,14 +47,16 @@ def file_dump_json(filename: Path, data, is_zip=False) -> None:
|
|||||||
:param data: JSON Data to save
|
:param data: JSON Data to save
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
logger.info(f'dumping json to "{filename}"')
|
|
||||||
|
|
||||||
if is_zip:
|
if is_zip:
|
||||||
if filename.suffix != '.gz':
|
if filename.suffix != '.gz':
|
||||||
filename = filename.with_suffix('.gz')
|
filename = filename.with_suffix('.gz')
|
||||||
|
logger.info(f'dumping json to "{filename}"')
|
||||||
|
|
||||||
with gzip.open(filename, 'w') as fp:
|
with gzip.open(filename, 'w') as fp:
|
||||||
rapidjson.dump(data, fp, default=str, number_mode=rapidjson.NM_NATIVE)
|
rapidjson.dump(data, fp, default=str, number_mode=rapidjson.NM_NATIVE)
|
||||||
else:
|
else:
|
||||||
|
logger.info(f'dumping json to "{filename}"')
|
||||||
with open(filename, 'w') as fp:
|
with open(filename, 'w') as fp:
|
||||||
rapidjson.dump(data, fp, default=str, number_mode=rapidjson.NM_NATIVE)
|
rapidjson.dump(data, fp, default=str, number_mode=rapidjson.NM_NATIVE)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user