summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Coyle <loic.coyle@hotmail.fr>2020-02-09 21:33:51 +0100
committerLoic Coyle <loic.coyle@hotmail.fr>2020-02-09 21:33:51 +0100
commit27dff31cbd11f5cb397887f74152452e182333eb (patch)
tree33badb4ac0fd1a235cc978430b121b2b3aac6fd4
parent1bc5c0e63ad9ac0aac08cc4ff80c3d3fe1266ef6 (diff)
fix template issue
-rw-r--r--pywal/export.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/pywal/export.py b/pywal/export.py
index 0c71a76..b9a95e8 100644
--- a/pywal/export.py
+++ b/pywal/export.py
@@ -25,7 +25,7 @@ def template(colors, input_file, output_file=None):
# Color to be modified copied into new one
new_color = util.Color(colors[cname].hex_color)
# Execute each function to be done
- for func in filter(None, funcs.split(")")):
+ for func in filter(None, re.split("\)|\.", funcs)):
# Get function name and arguments
func = func.split("(")
fname = func[0]
@@ -47,11 +47,18 @@ def template(colors, input_file, output_file=None):
if func[0] != '.':
replace_str += "."
replace_str += "(".join(func) + ")"
+ else:
+ # if it is an attribute i.e. rgb
+ replace_str += '.' + fname
+ new_color = function
+
+ if not isinstance(new_color, str):
+ new_color = new_color.strip
# If the color was changed, replace with a unique identifier.
if new_color is not colors[cname]:
- template_data[i] = l.replace(
- replace_str, "color" + new_color.strip)
- colors["color" + new_color.strip] = new_color
+ new_color_clean = new_color.replace('[', '_').replace(']', '_')
+ template_data[i] = l.replace(replace_str, "color" + new_color_clean)
+ colors["color" + new_color_clean] = new_color
try:
template_data = "".join(template_data).format(**colors)
except ValueError: