From 57a1b3aca86253d130848fdfcd2accbed861b5ee Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Mon, 9 Nov 2020 17:07:00 +0100 Subject: [PATCH] escape using helper function --- beetsplug/fish.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/beetsplug/fish.py b/beetsplug/fish.py index abe3c3d71..9883ed693 100644 --- a/beetsplug/fish.py +++ b/beetsplug/fish.py @@ -132,6 +132,11 @@ class FishPlugin(BeetsPlugin): with open(completion_file_path, 'w') as fish_file: fish_file.write(totstring) +def _escape(name): + # Escape ? in fish + if name == "?": + name = "\\" + name + def get_cmds_list(cmds_names): # Make a list of all Beets core & plugin commands @@ -201,9 +206,7 @@ def get_subcommands(cmd_name_and_help, nobasicfields, extravalues): # Formatting for Fish to complete our fields/values word = "" for cmdname, cmdhelp in cmd_name_and_help: - # Escape ? in fish - if cmdname == "?": - cmdname = "\\" + cmdname + cmdname = _escape(cmdname) word += "\n" + "# ------ {} -------".format( "fieldsetups for " + cmdname) + "\n" @@ -236,9 +239,7 @@ def get_all_commands(beetcmds): names = [alias for alias in cmd.aliases] names.append(cmd.name) for name in names: - # Escape ? in fish - if name == "?": - name = "\\" + name + name = _escape(name) word += "\n" word += ("\n" * 2) + "# ====== {} =====".format(