def set_shortcuts(user_context, shortcuts): # make the list of shortcuts under a nested "shortcuts" key with each index formatted_obj = {'shortcuts': {str(i): item for i, item in enumerate(shortcuts)}} byte_str = vdf.binary_dumps(formatted_obj) with open(paths.shortcuts_path(user_context), 'wb') as fp: fp.write(byte_str)
def get_shortcuts(user_context): with open(paths.shortcuts_path(user_context), 'rb') as fp: vdf_dict = vdf.binary_loads(fp.read()) return list(vdf_dict.get('shortcuts').values())
def set_shortcuts(user_context, shortcuts): write_shortcuts(paths.shortcuts_path(user_context), shortcuts)
def get_shortcuts(user_context): return read_shortcuts(paths.shortcuts_path(user_context))