From f12386d49130beb269ddb7f47744c6385b1ccd29 Mon Sep 17 00:00:00 2001 From: Gra Date: Thu, 28 May 2009 14:52:31 +0200 Subject: [PATCH] Added the --nb_suggs option. It controls the max number of suggestions to display (defaults to 5). --- pl.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pl.py b/pl.py index 718f610..a7b7dcd 100755 --- a/pl.py +++ b/pl.py @@ -63,7 +63,7 @@ def main(): parser = optparse.OptionParser() parser.usage = "%prog [OPTIONS...] ACTION PLAYLIST [OTHER_PLAYLIST]\n" + \ " [-defhtV] [--delete] [--error-stop] [--fix]\n" + \ - " [-p PREFIX] [-s SCORE] [-t TARGET]\n" + \ + " [-n NB_SUGGS] [-p PREFIX] [-s SCORE] [-t TARGET]\n" + \ " [--prefix PREFIX] [--score SCORE] [--target TARGET]\n" + \ " [--help] [--version]\n" + \ " AVAILABLE ACTIONS:\n" + \ @@ -91,6 +91,9 @@ def main(): parser.add_option('-f', '--fix', default=False, action='store_true', dest='fix', help="check - prompt for fixes among suggestions") + parser.add_option('-n', '--nb-suggs', default=0, + action='store', dest='nb_suggs', type='int', + help="check - max number of suggestions to display") parser.add_option('-p', '--prefix', default='', action='store', dest='prefix', type='string', help="the string that will replace TARGET in the created playlist, " @@ -127,6 +130,10 @@ def main(): # default min score for fixing if (options.fix or options.auto_fix) and options.score == 1: options.score = 0.8 + # default number of suggestions to display + if (options.score < 1 or options.fix or options.auto_fix) and \ + options.nb_suggs == 0: + options.nb_suggs = 5 if options.auto_fix: options.fix = True if options.delete: @@ -253,8 +260,7 @@ def playlist_is_ok(playlist, options): indent=4) else: print "could be" - max_suggs = 5 - nbr_suggs = min(max_suggs, len(suggs)) + nbr_suggs = min(options.nb_suggs, len(suggs)) for sugg_idx in range(nbr_suggs): if options.fix: print sugg_idx + 1, -- 2.45.1