import os
import json
import fileutil

def read_settings(filename):
    return json.loads(fileutil.read_file(filename))

def write_settings(filename, settings):
    fileutil.mkpath(os.path.dirname(filename))
    data = json.dumps(settings, indent=2, sort_keys=True)
    fileutil.atomic_write_file(filename, data)

import os
import json
import fileutil

def read_settings(filename):
    return json.loads(fileutil.read_file(filename))

def write_settings(filename, settings):
    fileutil.mkpath(os.path.dirname(filename))
    data = json.dumps(settings, indent=2, sort_keys=True)
    fileutil.atomic_write_file(filename, data)
