summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2018-01-01 11:31:46 +1100
committerDylan Araps <dylan.araps@gmail.com>2018-01-01 11:31:46 +1100
commit3fc3b5e033eeacb691fa077869391f54a3d46d6c (patch)
tree83b6e824163b8ccb0374d00272e221368db500b9
parent7984fd40afc330b193d202263b0aea23ac601e05 (diff)
colors: More readable loop
-rw-r--r--pywal/colors.py18
1 files 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]