def IgnoreMenu(kind, rating_key, title=None, sure=False, todo="not_set"): is_ignored = rating_key in ignore_list[kind] if not sure: oc = ObjectContainer( no_history=True, replace_parent=True, title1="%s %s %s %s the ignore list" % ( "Add" if not is_ignored else "Remove", ignore_list.verbose(kind), title, "to" if not is_ignored else "from", ), title2="Are you sure?", ) oc.add( DirectoryObject( key=Callback( IgnoreMenu, kind=kind, rating_key=rating_key, title=title, sure=True, todo="add" if not is_ignored else "remove", ), title=pad_title("Are you sure?"), ) ) return oc rel = ignore_list[kind] dont_change = False if todo == "remove": if not is_ignored: dont_change = True else: rel.remove(rating_key) Log.Info("Removed %s (%s) from the ignore list", title, rating_key) ignore_list.remove_title(kind, rating_key) ignore_list.save() state = "removed from" elif todo == "add": if is_ignored: dont_change = True else: rel.append(rating_key) Log.Info("Added %s (%s) to the ignore list", title, rating_key) ignore_list.add_title(kind, rating_key, title) ignore_list.save() state = "added to" else: dont_change = True if dont_change: return fatality(force_title=" ", header="Didn't change the ignore list", no_history=True) return fatality(force_title=" ", header="%s %s the ignore list" % (title, state), no_history=True)
def IgnoreMenu(kind, rating_key, title=None, sure=False, todo="not_set"): """ displays the ignore options for a menu :param kind: :param rating_key: :param title: :param sure: :param todo: :return: """ is_ignored = rating_key in ignore_list[kind] if not sure: oc = SubFolderObjectContainer(no_history=True, replace_parent=True, title1="%s %s %s %s the ignore list" % ( "Add" if not is_ignored else "Remove", ignore_list.verbose(kind), title, "to" if not is_ignored else "from"), title2="Are you sure?") oc.add(DirectoryObject( key=Callback(IgnoreMenu, kind=kind, rating_key=rating_key, title=title, sure=True, todo="add" if not is_ignored else "remove"), title=pad_title("Are you sure?"), )) return oc rel = ignore_list[kind] dont_change = False if todo == "remove": if not is_ignored: dont_change = True else: rel.remove(rating_key) Log.Info("Removed %s (%s) from the ignore list", title, rating_key) ignore_list.remove_title(kind, rating_key) ignore_list.save() state = "removed from" elif todo == "add": if is_ignored: dont_change = True else: rel.append(rating_key) Log.Info("Added %s (%s) to the ignore list", title, rating_key) ignore_list.add_title(kind, rating_key, title) ignore_list.save() state = "added to" else: dont_change = True if dont_change: return fatality(force_title=" ", header="Didn't change the ignore list", no_history=True) return fatality(force_title=" ", header="%s %s the ignore list" % (title, state), no_history=True)