diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2018-01-02 09:34:22 +1100 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2018-01-02 09:34:22 +1100 |
| commit | d6515868618d6faa02ff96b5febd7351a453a74a (patch) | |
| tree | bd569885c46e180d41003e9b4feed8e1d46eea64 /pywal | |
| parent | 3841544a5fc9cea9ba4d9c847d628b000662c888 (diff) | |
colors: Cleanup
Diffstat (limited to 'pywal')
| -rw-r--r-- | pywal/colors.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/pywal/colors.py b/pywal/colors.py index 394d9ee..b4ce44f 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -22,19 +22,23 @@ def imagemagick(color_count, img, magick_command): return colors.stdout.splitlines() -def gen_colors(img, color_count): - """Format the output from imagemagick into a list - of hex colors.""" +def has_im(): + """Check to see if the user has im installed.""" if shutil.which("magick"): - magick_command = ["magick", "convert"] + return ["magick", "convert"] elif shutil.which("convert"): - magick_command = ["convert"] + return ["convert"] + + print("error: imagemagick not found, exiting...\n" + "error: wal requires imagemagick to function.") + sys.exit(1) - else: - print("error: imagemagick not found, exiting...\n" - "error: wal requires imagemagick to function.") - sys.exit(1) + +def gen_colors(img, color_count): + """Format the output from imagemagick into a list + of hex colors.""" + magick_command = has_im() for index in range(0, 20, 1): raw_colors = imagemagick(color_count + index, img, magick_command) @@ -52,10 +56,7 @@ def gen_colors(img, color_count): "trying a larger palette size %s." % (color_count, color_count + index)) - # Remove the first element because it isn't a color code. - del raw_colors[0] - - return [re.search("#.{6}", str(col)).group(0) for col in raw_colors] + return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]] def sort_colors(img, colors): |
