Skip to content

Commit

Permalink
Feature/improved write json method (#69)
Browse files Browse the repository at this point in the history
* improved write json method

* improved write json method
  • Loading branch information
l8556 authored Oct 17, 2024
1 parent 4d62dfb commit 4edc653
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion host_tools/utils/File.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,14 @@ def write_json(
mode: str = 'w',
indent: int = 2,
ensure_ascii: bool = True,
encoding: str = 'utf-8'
encoding: str = 'utf-8',
ends_with_blank_line: bool = False
) -> None:
Dir.create(dirname(path), stdout=False)
with open(path, mode, encoding=encoding) as file:
json.dump(data, file, ensure_ascii=ensure_ascii, indent=indent)
if ends_with_blank_line:
file.write('\n')

@staticmethod
def unpacking(archive_path: str, execute_path: str, delete_archive: bool = False, stdout: bool = True) -> None:
Expand Down

0 comments on commit 4edc653

Please sign in to comment.