From 02acd28f0641667ff658a4e5a19061ef8657e697 Mon Sep 17 00:00:00 2001 From: Amit Prasad <17amitprasad@gmail.com> Date: Tue, 17 Dec 2019 20:29:04 -0500 Subject: Added ability to modify colors using methods ( .lighten(%), .darken(%), .saturate(%) for now) --- pywal/export.py | 59 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 27 deletions(-) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index b175c11..ae619cd 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -13,38 +13,43 @@ def template(colors, input_file, output_file=None): """Read template file, substitute markers and save the file elsewhere.""" template_data = util.read_file_raw(input_file) - matches = re.finditer(r"(?<=(? 1: + args = func_split[1].split(",") + else: + args = [] + name = func_split[0] + if name[0] == '.': + name = name[1:] + x = getattr(colors[color], name) + if callable(x): + new_color = x(*args) + if func[0] != '.': + to_replace += "." + to_replace += func + ")" + else: + pass + if not new_color is None: + cname = "color" + new_color.strip + template_data[i] = line.replace(to_replace, cname) + colors[cname] = new_color try: template_data = "".join(template_data).format(**colors) except ValueError: logging.error("Syntax error in template file '%s'.", input_file) return - util.save_file(template_data, output_file) -- cgit v1.2.3