def write(filename, data, undisclosed=False):
"""
Write JSON data to (owner only readable) file.
This will also create missing directories.
Args:
filename (str): file path
data (str): data to write
undisclosed (bool): whether data should be owner only readable
"""
makedirs(os.path.dirname(filename))
with open(filename, 'w') as fp:
if undisclosed:
os.chmod(filename, stat.S_IRUSR | stat.S_IWUSR)
json.dump(data, fp)
评论列表
文章目录