diff options
| author | Dylan Araps <dylanaraps@users.noreply.github.com> | 2017-08-12 18:42:27 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-12 18:42:27 +1000 |
| commit | 8be48c07fff889ed085744cc0cf585b6d0b71a89 (patch) | |
| tree | 839edfa96574721cc6fc82ef18059d75ebef792e /pywal/colors.py | |
| parent | f14aaf5a4fd1847a5316f9c41965daebc23db818 (diff) | |
| parent | c743cab4f0b74e928496c2a5052906da52acc8f7 (diff) | |
Merge pull request #79 from dylanaraps/35
general: Add support for Python 3.5
Diffstat (limited to 'pywal/colors.py')
| -rw-r--r-- | pywal/colors.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/pywal/colors.py b/pywal/colors.py index 2483acd..fd233c5 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -1,6 +1,7 @@ """ Generate a colorscheme using imagemagick. """ +import os import re import shutil import subprocess @@ -64,19 +65,17 @@ def sort_colors(img, colors): # Create a comment color from the background. raw_colors[8] = util.lighten_color(raw_colors[0], 0.40) - colors = {"wallpaper": img} - colors_special = {} - colors_hex = {} + colors = {} + colors["wallpaper"] = img + colors["special"] = {} + colors["colors"] = {} - colors_special.update({"background": raw_colors[0]}) - colors_special.update({"foreground": raw_colors[15]}) - colors_special.update({"cursor": raw_colors[15]}) + colors["special"]["background"] = raw_colors[0] + colors["special"]["foreground"] = raw_colors[15] + colors["special"]["cursor"] = raw_colors[15] for index, color in enumerate(raw_colors): - colors_hex.update({f"color{index}": color}) - - colors["special"] = colors_special - colors["colors"] = colors_hex + colors["colors"]["color%s" % index] = color return colors @@ -85,11 +84,10 @@ def get(img, cache_dir=CACHE_DIR, color_count=COLOR_COUNT, notify=False): """Get the colorscheme.""" # _home_dylan_img_jpg.json - cache_file = cache_dir / "schemes" / \ - img.replace("/", "_").replace(".", "_") - cache_file = cache_file.with_suffix(".json") + cache_file = img.replace("/", "_").replace(".", "_") + cache_file = os.path.join(cache_dir, "schemes", cache_file + ".json") - if cache_file.is_file(): + if os.path.isfile(cache_file): colors = util.read_file_json(cache_file) print("colors: Found cached colorscheme.") |
