From c8dd8f4d03fc79b5594e8d873e0aba77e360796a Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 22 Jul 2017 10:01:14 +1000 Subject: general: Fixes. --- pywal/export.py | 31 ------------------------------- pywal/template.py | 31 +++++++++++++++++++++++++++++++ pywal/wal.py | 4 ++-- 3 files changed, 33 insertions(+), 33 deletions(-) delete mode 100644 pywal/export.py create mode 100644 pywal/template.py (limited to 'pywal') diff --git a/pywal/export.py b/pywal/export.py deleted file mode 100644 index 1dc72bf..0000000 --- a/pywal/export.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -Export colors in various formats. -""" -import os - -from pywal import util - - -def template(colors, input_file, output_dir): - """Read template file, substitute markers and - save the file elsewhere.""" - template_data = util.read_file_raw(input_file) - template_data = "".join(template_data).format(**colors) - template_name = os.path.basename(input_file) - util.save_file(template_data, output_dir / template_name) - print(f"export: Exported {template_name}.") - - -def export_all_templates(colors, output_dir, template_dir=None): - """Export all template files.""" - template_dir = template_dir or \ - os.path.join(os.path.dirname(__file__), "templates") - - all_colors = {"wallpaper": colors["wallpaper"], - **colors["special"], - **colors["colors"]} - all_colors = {k: util.Color(v) for k, v in all_colors.items()} - - # pylint: disable=W0106 - [template(all_colors, file.path, output_dir) - for file in os.scandir(template_dir)] diff --git a/pywal/template.py b/pywal/template.py new file mode 100644 index 0000000..1dc72bf --- /dev/null +++ b/pywal/template.py @@ -0,0 +1,31 @@ +""" +Export colors in various formats. +""" +import os + +from pywal import util + + +def template(colors, input_file, output_dir): + """Read template file, substitute markers and + save the file elsewhere.""" + template_data = util.read_file_raw(input_file) + template_data = "".join(template_data).format(**colors) + template_name = os.path.basename(input_file) + util.save_file(template_data, output_dir / template_name) + print(f"export: Exported {template_name}.") + + +def export_all_templates(colors, output_dir, template_dir=None): + """Export all template files.""" + template_dir = template_dir or \ + os.path.join(os.path.dirname(__file__), "templates") + + all_colors = {"wallpaper": colors["wallpaper"], + **colors["special"], + **colors["colors"]} + all_colors = {k: util.Color(v) for k, v in all_colors.items()} + + # pylint: disable=W0106 + [template(all_colors, file.path, output_dir) + for file in os.scandir(template_dir)] diff --git a/pywal/wal.py b/pywal/wal.py index 6d10278..fa0eb3e 100644 --- a/pywal/wal.py +++ b/pywal/wal.py @@ -4,11 +4,11 @@ Created by Dylan Araps. """ import pathlib -from pywal import export from pywal import image from pywal import magic from pywal import reload from pywal import sequences +from pywal import template from pywal import wallpaper @@ -42,7 +42,7 @@ def reload_env(cache_dir=CACHE_DIR): def export_all_templates(colors, output_dir=CACHE_DIR, template_dir=None): """Export all templates.""" - export.export_all_templates(colors, output_dir, template_dir) + template.export_all_templates(colors, output_dir, template_dir) def set_wallpaper(img): -- cgit v1.2.3