diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-07-23 10:57:33 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-07-23 10:57:33 +1000 |
| commit | 377cc7e68ce2576ad928fdd6efb40cabdf0f19dc (patch) | |
| tree | 43fa2d6c67fab5d46b3fb8e170ba0aa36913054d /pywal/template.py | |
| parent | bd5611e35cba2cfa0a57f3f854ed157638da3c95 (diff) | |
api: Changed export arguments.
Diffstat (limited to 'pywal/template.py')
| -rw-r--r-- | pywal/template.py | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/pywal/template.py b/pywal/template.py deleted file mode 100644 index a7961e3..0000000 --- a/pywal/template.py +++ /dev/null @@ -1,49 +0,0 @@ -""" -Export colors in various formats. -""" -import os -import pathlib - -from .settings import __cache_dir__ -from . import util - - -TEMPLATE_DIR = pathlib.Path(__file__).parent / "templates" - - -def template(colors, input_file, cache_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, cache_dir / template_name) - print(f"export: Exported {template_name}.") - - -def flatten_colors(colors): - """Prepare colors to be exported. (Flatten dicts)""" - all_colors = {"wallpaper": colors["wallpaper"], - **colors["special"], - **colors["colors"]} - return {k: util.Color(v) for k, v in all_colors.items()} - - -def export_all(colors, cache_dir=__cache_dir__): - """Export all template files.""" - all_colors = flatten_colors(colors) - - for file in os.scandir(TEMPLATE_DIR): - template(all_colors, file.path, cache_dir) - - -def export(colors, file, cache_dir=__cache_dir__): - """Export a single template file.""" - all_colors = flatten_colors(colors) - template_file = TEMPLATE_DIR / file - - if template_file.is_file(): - template(all_colors, template_file, cache_dir) - else: - print(f"[!] warning: template '{template_file}' doesn't exist.") |
