def read_file(filepath): _filepath = resolve_file_path(filepath) if os.path.exists(_filepath): fc = open(_filepath, 'r') obj = json.load(fc, encoding='utf-8') fc.close() return obj else: return None
def write_file(filepath, obj): _filepath = resolve_file_path(filepath) fc = open(_filepath, 'w') status = json.dump(obj, fc, encoding='utf-8') fc.close() return status