mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-02-03 12:00:21 +01:00
backend: cleanup
This commit is contained in:
parent
1411ef02f3
commit
5a680b8af6
@ -17,19 +17,35 @@ def list_backends():
|
|||||||
|
|
||||||
def colors_to_dict(colors, img):
|
def colors_to_dict(colors, img):
|
||||||
"""Convert list of colors to pywal format."""
|
"""Convert list of colors to pywal format."""
|
||||||
scheme = {"wallpaper": img,
|
return {
|
||||||
|
"wallpaper": img,
|
||||||
"alpha": util.Color.alpha_num,
|
"alpha": util.Color.alpha_num,
|
||||||
"special": {},
|
|
||||||
"colors": {}}
|
|
||||||
|
|
||||||
for i, color in enumerate(colors):
|
"special": {
|
||||||
scheme["colors"]["color%s" % i] = color
|
"background": colors[0],
|
||||||
|
"foreground": colors[15],
|
||||||
|
"cursor": colors[1]
|
||||||
|
},
|
||||||
|
|
||||||
scheme["special"]["background"] = colors[0]
|
"colors": {
|
||||||
scheme["special"]["foreground"] = colors[15]
|
"color0": colors[0],
|
||||||
scheme["special"]["cursor"] = colors[1]
|
"color1": colors[1],
|
||||||
|
"color2": colors[2],
|
||||||
return scheme
|
"color3": colors[3],
|
||||||
|
"color4": colors[4],
|
||||||
|
"color5": colors[5],
|
||||||
|
"color6": colors[6],
|
||||||
|
"color7": colors[7],
|
||||||
|
"color8": colors[8],
|
||||||
|
"color9": colors[9],
|
||||||
|
"color10": colors[10],
|
||||||
|
"color11": colors[11],
|
||||||
|
"color12": colors[12],
|
||||||
|
"color13": colors[13],
|
||||||
|
"color14": colors[14],
|
||||||
|
"color15": colors[15]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def generic_adjust(colors, light):
|
def generic_adjust(colors, light):
|
||||||
@ -53,14 +69,20 @@ def generic_adjust(colors, light):
|
|||||||
return colors
|
return colors
|
||||||
|
|
||||||
|
|
||||||
|
def cache_fname(img, backend, light, cache_dir):
|
||||||
|
"""Create the cache file name."""
|
||||||
|
color_type = "light" if light else "dark"
|
||||||
|
file_name = re.sub("[/|\\|.]", "_", img)
|
||||||
|
|
||||||
|
file_parts = [file_name, color_type, backend, __cache_version__]
|
||||||
|
return [cache_dir, "schemes", "%s_%s_%s_%s.json" % (*file_parts,)]
|
||||||
|
|
||||||
|
|
||||||
def get(img, light=False, backend="wal", cache_dir=CACHE_DIR):
|
def get(img, light=False, backend="wal", cache_dir=CACHE_DIR):
|
||||||
"""Generate a palette."""
|
"""Generate a palette."""
|
||||||
# home_dylan_img_jpg_backend_1.2.2.json
|
# home_dylan_img_jpg_backend_1.2.2.json
|
||||||
color_type = "light" if light else "dark"
|
cache_name = cache_fname(img, backend, light, cache_dir)
|
||||||
cache_file = re.sub("[/|\\|.]", "_", img)
|
cache_file = os.path.join(*cache_name)
|
||||||
cache_file = os.path.join(cache_dir, "schemes", "%s_%s_%s_%s.json"
|
|
||||||
% (cache_file, color_type,
|
|
||||||
backend, __cache_version__))
|
|
||||||
|
|
||||||
if os.path.isfile(cache_file):
|
if os.path.isfile(cache_file):
|
||||||
colors = file(cache_file)
|
colors = file(cache_file)
|
||||||
|
Loading…
Reference in New Issue
Block a user