diff options
Diffstat (limited to 'dots_manager/template.py')
-rw-r--r-- | dots_manager/template.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/dots_manager/template.py b/dots_manager/template.py index 4c62500..13aecf7 100644 --- a/dots_manager/template.py +++ b/dots_manager/template.py @@ -2,20 +2,18 @@ from pathlib import Path from typing import Optional import shutil import jinja2 -from dots_manager.config import Config -from dots_manager.parallel import parallelize -from dots_manager.utils import is_some -from dots_manager.env import Environment +from dots_manager.config import Constants, Environment +from dots_manager.utils import is_some, parallelize def is_template(path: Path) -> bool: - return path.suffix == Config.template_extension + return path.suffix == Constants.template_extension def find_templates_under(destination: Path) -> list[Path]: return [ t - for t in destination.glob("**/*" + Config.template_extension) + for t in destination.glob("**/*" + Constants.template_extension) if t.is_file() and is_template(t) ] @@ -47,15 +45,15 @@ def render( source: Path, jinja_env: jinja2.Environment, env: Environment ) -> Optional[str]: try: - env.logger.debug(f"rendering template {source} ✿.。.:・") + env.logger.debug(f"rendering template {source} <_mood.happy>") return jinja_env.from_string(source.read_text()).render(**env.context) except Exception as e: - env.logger.error(f"couldn’t render {source}: {e}") + env.logger.error(f"couldn’t render {source}: {e} <_mood.sad>") return None def compile_dotfiles(source: Path, output: Path, env: Environment) -> bool: - env.logger.info(f"compiling {source} to {output}") + env.logger.info(f"compiling {source} to {output} <_mood.anxious>") output.mkdir(exist_ok=True, parents=True) shutil.copytree(source, output, dirs_exist_ok=True) @@ -68,6 +66,6 @@ def compile_dotfiles(source: Path, output: Path, env: Environment) -> bool: )[0] and (template.unlink() is None), find_templates_under(output), - env, + env.logger, ) return all(tasks) |