From cdf0aa19264a1cbe1dc341fb82d8b9c4b3968a91 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Sat, 17 Aug 2013 03:16:44 +0100 Subject: [PATCH] Remove duplicates from the list of cheatsheets. --- cheat | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cheat b/cheat index b4a3249..72559f0 100755 --- a/cheat +++ b/cheat @@ -24,6 +24,16 @@ if 'CHEATPATH' in os.environ and os.environ['CHEATPATH']: path = os.environ['CHEATPATH'].split(os.pathsep) if os.path.isdir(path): cheatsheets += [(f, path) for f in os.listdir(path) if '.' not in f] + +# remove any duplicates +def remove_duplicates(cheats): + sheets = [] + for i, sheet in enumerate(cheats): + if sheet[0] not in [c[0] for c in sheets]: + sheets.append(sheet) + return sheets + +cheatsheets = remove_duplicates(cheatsheets) cheatsheets.sort() # assemble a keyphrase out of all params passed to the script