makejinja 2.3.3__tar.gz → 2.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {makejinja-2.3.3 → makejinja-2.3.4}/PKG-INFO +1 -1
- {makejinja-2.3.3 → makejinja-2.3.4}/makejinja/app.py +25 -9
- {makejinja-2.3.3 → makejinja-2.3.4}/makejinja/cli.py +1 -0
- {makejinja-2.3.3 → makejinja-2.3.4}/pyproject.toml +1 -1
- {makejinja-2.3.3 → makejinja-2.3.4}/LICENSE +0 -0
- {makejinja-2.3.3 → makejinja-2.3.4}/README.md +0 -0
- {makejinja-2.3.3 → makejinja-2.3.4}/makejinja/__init__.py +0 -0
- {makejinja-2.3.3 → makejinja-2.3.4}/makejinja/__main__.py +0 -0
- {makejinja-2.3.3 → makejinja-2.3.4}/makejinja/config.py +0 -0
- {makejinja-2.3.3 → makejinja-2.3.4}/makejinja/loader.py +0 -0
- {makejinja-2.3.3 → makejinja-2.3.4}/makejinja/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: makejinja
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.4
|
|
4
4
|
Summary: makejinja is a CLI tool and Python library to automatically generate files from Jinja2 templates. Use it to easily generate complex Home Assistant dashboards!
|
|
5
5
|
Home-page: https://mirkolenz.github.io/makejinja/
|
|
6
6
|
License: MIT
|
|
@@ -45,9 +45,11 @@ def makejinja(config: Config):
|
|
|
45
45
|
# Save rendered files to avoid duplicate work
|
|
46
46
|
# Even if two files are in two separate folders, they will have the same template name (i.e., relative path)
|
|
47
47
|
# and thus only the first one will be rendered every time
|
|
48
|
-
|
|
48
|
+
# Key: output_path, Value: input_path
|
|
49
|
+
rendered_files: dict[Path, Path] = {}
|
|
49
50
|
|
|
50
51
|
# Save rendered folders to later copy metadata
|
|
52
|
+
# Key: output_path, Value: input_path
|
|
51
53
|
rendered_folders: dict[Path, Path] = {}
|
|
52
54
|
|
|
53
55
|
for user_input_path in config.inputs:
|
|
@@ -58,10 +60,24 @@ def makejinja(config: Config):
|
|
|
58
60
|
user_input_path, config, env, rendered_files, rendered_folders
|
|
59
61
|
)
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
postprocess_rendered_folders(config, rendered_folders)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def postprocess_rendered_folders(
|
|
67
|
+
config: Config,
|
|
68
|
+
rendered_folders: abc.Mapping[Path, Path],
|
|
69
|
+
) -> None:
|
|
70
|
+
# Start with the deepest folder and work our way up, otherwise the statistics could be modified after copying
|
|
71
|
+
for output_path, input_path in sorted(
|
|
72
|
+
rendered_folders.items(), key=lambda x: x[0], reverse=True
|
|
73
|
+
):
|
|
74
|
+
if not config.keep_empty and not any(output_path.iterdir()):
|
|
75
|
+
if not config.quiet:
|
|
76
|
+
print(f"Remove empty '{output_path}'")
|
|
77
|
+
|
|
78
|
+
shutil.rmtree(output_path)
|
|
79
|
+
|
|
80
|
+
elif config.copy_metadata:
|
|
65
81
|
if not config.quiet:
|
|
66
82
|
print(f"Copy metadata '{input_path}' -> '{output_path}'")
|
|
67
83
|
|
|
@@ -82,7 +98,7 @@ def handle_input_file(
|
|
|
82
98
|
input_path: Path,
|
|
83
99
|
config: Config,
|
|
84
100
|
env: Environment,
|
|
85
|
-
rendered_files: abc.
|
|
101
|
+
rendered_files: abc.MutableMapping[Path, Path],
|
|
86
102
|
) -> None:
|
|
87
103
|
relative_path = Path(input_path.name)
|
|
88
104
|
output_path = generate_output_path(config, relative_path)
|
|
@@ -97,14 +113,14 @@ def handle_input_file(
|
|
|
97
113
|
enforce_jinja_suffix=False,
|
|
98
114
|
)
|
|
99
115
|
|
|
100
|
-
rendered_files
|
|
116
|
+
rendered_files[output_path] = input_path
|
|
101
117
|
|
|
102
118
|
|
|
103
119
|
def handle_input_folder(
|
|
104
120
|
user_input_path: Path,
|
|
105
121
|
config: Config,
|
|
106
122
|
env: Environment,
|
|
107
|
-
rendered_files: abc.
|
|
123
|
+
rendered_files: abc.MutableMapping[Path, Path],
|
|
108
124
|
rendered_folders: abc.MutableMapping[Path, Path],
|
|
109
125
|
) -> None:
|
|
110
126
|
input_paths = (
|
|
@@ -130,7 +146,7 @@ def handle_input_folder(
|
|
|
130
146
|
env,
|
|
131
147
|
enforce_jinja_suffix=True,
|
|
132
148
|
)
|
|
133
|
-
rendered_files
|
|
149
|
+
rendered_files[output_path] = input_path
|
|
134
150
|
|
|
135
151
|
elif input_path.is_dir() and output_path not in rendered_folders:
|
|
136
152
|
if not config.quiet:
|
|
@@ -31,6 +31,7 @@ def makejinja_cli(config: Config):
|
|
|
31
31
|
**Note**: In this file, options may be named differently.
|
|
32
32
|
Please refer to the file [`makejinja/config.py`](https://github.com/mirkolenz/makejinja/blob/main/makejinja/config.py) to see their actual names.
|
|
33
33
|
You will also find an example here: [`makejinja/tests/data/makejinja.toml`](https://github.com/mirkolenz/makejinja/blob/main/tests/data/makejinja.toml).
|
|
34
|
+
To override its location, you can set the environment variable `MAKEJINJA_SETTINGS` to the path of your config file.
|
|
34
35
|
"""
|
|
35
36
|
|
|
36
37
|
makejinja(config)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "makejinja"
|
|
3
|
-
version = "2.3.
|
|
3
|
+
version = "2.3.4"
|
|
4
4
|
description = "makejinja is a CLI tool and Python library to automatically generate files from Jinja2 templates. Use it to easily generate complex Home Assistant dashboards!"
|
|
5
5
|
authors = ["Mirko Lenz <mirko@mirkolenz.com>"]
|
|
6
6
|
license = "MIT"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|