From baf0b3a7cae2ea0eff257d611613a4a7f415c72c Mon Sep 17 00:00:00 2001 From: Gra Date: Thu, 28 May 2009 14:33:47 +0200 Subject: [PATCH] Fixed the number of suggestions. Now it's OK if the number of suggs found is below the max. --- pl.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pl.py b/pl.py index 86af355..bc99cc4 100755 --- a/pl.py +++ b/pl.py @@ -241,8 +241,9 @@ def playlist_is_ok(playlist, options): new=missing_item[len(options.target):]) else: print "could be" - nbr_of_suggestions = 5 - for sugg_idx in range(nbr_of_suggestions): + max_suggs = 5 + nbr_suggs = min(max_suggs, len(suggs)) + for sugg_idx in range(nbr_suggs): if options.fix: print sugg_idx + 1, print format_item(suggs[sugg_idx], @@ -250,7 +251,7 @@ def playlist_is_ok(playlist, options): indent=4) if options.fix: message = 'Which one to use? [%s, nothing to ignore] ' - seq = ''.join([str(num + 1) for num in range(nbr_of_suggestions)]) + seq = ''.join([str(num + 1) for num in range(nbr_suggs)]) replace = raw_input(message % seq) if replace.strip(): try: @@ -258,7 +259,7 @@ def playlist_is_ok(playlist, options): except: number = -1 else: - if 0 <= number < nbr_of_suggestions: + if 0 <= number < nbr_suggs: new_playlist = replace_in_pl( pl=new_playlist, entry=missing_item[len(options.target):], -- 2.45.1