From 3fc3b5e033eeacb691fa077869391f54a3d46d6c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 1 Jan 2018 11:31:46 +1100 Subject: [PATCH] colors: More readable loop --- pywal/colors.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pywal/colors.py b/pywal/colors.py index 44e5c70..333bf04 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -36,22 +36,22 @@ def gen_colors(img, color_count): "error: wal requires imagemagick to function.") sys.exit(1) - raw_colors = imagemagick(color_count, img, magick_command) - - index = 0 - while len(raw_colors) - 1 < color_count: - index += 1 + for index in range(0, 20, 1): raw_colors = imagemagick(color_count + index, img, magick_command) - print("colors: Imagemagick couldn't generate a", color_count, - "color palette, trying a larger palette size", - color_count + index) + if len(raw_colors) > 16: + break - if index > 20: + elif index == 20: print("colors: Imagemagick couldn't generate a suitable scheme", "for the image. Exiting...") sys.exit(1) + else: + print("colors: Imagemagick couldn't generate a", color_count, + "color palette, trying a larger palette size", + color_count + index) + # Remove the first element because it isn't a color code. del raw_colors[0]