makejinja 2.6.2__tar.gz → 2.7.0__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.
@@ -1,13 +1,36 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: makejinja
3
- Version: 2.6.2
3
+ Version: 2.7.0
4
4
  Summary: Generate entire directory structures using Jinja templates with support for external data and custom plugins.
5
- Home-page: https://mirkolenz.github.io/makejinja/
6
- License: MIT
5
+ Author-email: Mirko Lenz <mirko@mirkolenz.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2022 Mirko Lenz
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Repository, https://github.com/mirkolenz/makejinja
29
+ Project-URL: Homepage, https://mirkolenz.github.io/makejinja/
30
+ Project-URL: Documentation, https://mirkolenz.github.io/makejinja/makejinja/cli.html
31
+ Project-URL: Issues, https://github.com/mirkolenz/makejinja/issues
32
+ Project-URL: Changelog, https://github.com/mirkolenz/makejinja/releases
7
33
  Keywords: jinja2,home-assistant,hassio,dashboard,lovelace,template,generator,cli,tool,library
8
- Author: Mirko Lenz
9
- Author-email: mirko@mirkolenz.com
10
- Requires-Python: >=3.11,<4.0
11
34
  Classifier: Development Status :: 5 - Production/Stable
12
35
  Classifier: Environment :: Console
13
36
  Classifier: Framework :: Pytest
@@ -17,9 +40,6 @@ Classifier: Intended Audience :: System Administrators
17
40
  Classifier: License :: OSI Approved :: MIT License
18
41
  Classifier: Natural Language :: English
19
42
  Classifier: Operating System :: OS Independent
20
- Classifier: Programming Language :: Python :: 3
21
- Classifier: Programming Language :: Python :: 3.11
22
- Classifier: Programming Language :: Python :: 3.12
23
43
  Classifier: Topic :: File Formats
24
44
  Classifier: Topic :: Home Automation
25
45
  Classifier: Topic :: Software Development :: Code Generators
@@ -29,14 +49,18 @@ Classifier: Topic :: System :: Systems Administration
29
49
  Classifier: Topic :: Text Processing :: Markup
30
50
  Classifier: Topic :: Utilities
31
51
  Classifier: Typing :: Typed
32
- Requires-Dist: immutables (>=0.20,<0.21)
33
- Requires-Dist: jinja2 (>=3.1,<4.0)
34
- Requires-Dist: pyyaml (>=6.0,<7.0)
35
- Requires-Dist: rich-click (>=1.7,<2.0)
36
- Requires-Dist: typed-settings[attrs,cattrs,click] (>=23.1,<25)
37
- Project-URL: Documentation, https://mirkolenz.github.io/makejinja/makejinja/cli.html
38
- Project-URL: Repository, https://github.com/mirkolenz/makejinja
52
+ Classifier: Programming Language :: Python :: 3
53
+ Classifier: Programming Language :: Python :: 3.11
54
+ Classifier: Programming Language :: Python :: 3.12
55
+ Classifier: Programming Language :: Python :: 3.13
56
+ Requires-Python: >=3.11
39
57
  Description-Content-Type: text/markdown
58
+ License-File: LICENSE
59
+ Requires-Dist: jinja2<4,>=3
60
+ Requires-Dist: pyyaml<7,>=6
61
+ Requires-Dist: rich-click<2,>=1
62
+ Requires-Dist: typed-settings[attrs,cattrs,click]<25,>=23
63
+ Requires-Dist: immutables<1,>=0.20
40
64
 
41
65
  <!-- markdownlint-disable MD033 MD041 -->
42
66
  <h2><p align="center">makejinja</p></h2>
@@ -109,4 +133,3 @@ docker run --rm -v $(pwd)/data:/data ghcr.io/mirkolenz/makejinja:latest -i /data
109
133
  In its default configuration, makejinja searches the input directory recursively for files ending in `.jinja`.
110
134
  It then renders these files and writes them to the output directory, preserving the directory structure.
111
135
  Our [documentation](https://mirkolenz.github.io/makejinja/makejinja/cli.html) contains a detailed description of all options and can also be accessed via `makejinja --help`.
112
-
@@ -0,0 +1,135 @@
1
+ Metadata-Version: 2.1
2
+ Name: makejinja
3
+ Version: 2.7.0
4
+ Summary: Generate entire directory structures using Jinja templates with support for external data and custom plugins.
5
+ Author-email: Mirko Lenz <mirko@mirkolenz.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2022 Mirko Lenz
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Repository, https://github.com/mirkolenz/makejinja
29
+ Project-URL: Homepage, https://mirkolenz.github.io/makejinja/
30
+ Project-URL: Documentation, https://mirkolenz.github.io/makejinja/makejinja/cli.html
31
+ Project-URL: Issues, https://github.com/mirkolenz/makejinja/issues
32
+ Project-URL: Changelog, https://github.com/mirkolenz/makejinja/releases
33
+ Keywords: jinja2,home-assistant,hassio,dashboard,lovelace,template,generator,cli,tool,library
34
+ Classifier: Development Status :: 5 - Production/Stable
35
+ Classifier: Environment :: Console
36
+ Classifier: Framework :: Pytest
37
+ Classifier: Intended Audience :: Developers
38
+ Classifier: Intended Audience :: End Users/Desktop
39
+ Classifier: Intended Audience :: System Administrators
40
+ Classifier: License :: OSI Approved :: MIT License
41
+ Classifier: Natural Language :: English
42
+ Classifier: Operating System :: OS Independent
43
+ Classifier: Topic :: File Formats
44
+ Classifier: Topic :: Home Automation
45
+ Classifier: Topic :: Software Development :: Code Generators
46
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
47
+ Classifier: Topic :: System :: Software Distribution
48
+ Classifier: Topic :: System :: Systems Administration
49
+ Classifier: Topic :: Text Processing :: Markup
50
+ Classifier: Topic :: Utilities
51
+ Classifier: Typing :: Typed
52
+ Classifier: Programming Language :: Python :: 3
53
+ Classifier: Programming Language :: Python :: 3.11
54
+ Classifier: Programming Language :: Python :: 3.12
55
+ Classifier: Programming Language :: Python :: 3.13
56
+ Requires-Python: >=3.11
57
+ Description-Content-Type: text/markdown
58
+ License-File: LICENSE
59
+ Requires-Dist: jinja2<4,>=3
60
+ Requires-Dist: pyyaml<7,>=6
61
+ Requires-Dist: rich-click<2,>=1
62
+ Requires-Dist: typed-settings[attrs,cattrs,click]<25,>=23
63
+ Requires-Dist: immutables<1,>=0.20
64
+
65
+ <!-- markdownlint-disable MD033 MD041 -->
66
+ <h2><p align="center">makejinja</p></h2>
67
+ <p align="center">
68
+ <img width="256px" alt="makejinja logo" src="https://raw.githubusercontent.com/mirkolenz/makejinja/main/assets/logo.png" />
69
+ </p>
70
+ <p align="center">
71
+ <a href="https://pypi.org/project/makejinja/">PyPI</a> |
72
+ <a href="https://github.com/users/mirkolenz/packages/container/package/makejinja">Docker</a> |
73
+ <a href="https://mirkolenz.github.io/makejinja">Docs</a> |
74
+ <a href="https://github.com/mirkolenz/makejinja/tree/main/tests/data">Example</a> |
75
+ <a href="https://jinja.palletsprojects.com/en/3.1.x/templates">Jinja reference</a>
76
+ </p>
77
+ <p align="center">
78
+ Generate entire directory structures using Jinja templates with support for external data and custom plugins.
79
+ </p>
80
+
81
+ ---
82
+
83
+ # makejinja
84
+
85
+ makejinja can be used to automatically generate files from [Jinja templates](https://jinja.palletsprojects.com/en/3.1.x/templates).
86
+ It is conceptually similar to [Ansible templates](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html) since both are built on top of Jinja.
87
+ However, makejinja is a standalone tool that can be used without Ansible and offers some advanced features like custom plugins.
88
+ A use case for this tool is generating config files for [Home Assistant](https://www.home-assistant.io/):
89
+ Using the same language that the built-in templates use, you can greatly simplify your configuration.
90
+ An [example for Home Assistant](https://github.com/mirkolenz/makejinja/tree/main/tests/data) can be found in the tests directory.
91
+
92
+ ## Highlights
93
+
94
+ - Recursively render nested directories containing template files to a common output directory.
95
+ - Load data files containing variables to use in your Jinja templates from YAML, TOML, and Python files.
96
+ - Write custom [plugins](https://mirkolenz.github.io/makejinja/makejinja/plugin.html#Plugin) to extend the functionality of makejinja.
97
+ - Adjust all Jinja options (e.g., whitespace behavior and delimiters) to your needs via CLI flags or a config file.
98
+
99
+ ## Installation
100
+
101
+ The tool is written in Python and can be installed via pip, nix, and docker.
102
+ It can be used as a CLI tool or as a Python library.
103
+
104
+ ### PIP
105
+
106
+ makejinja is available on [PyPI](https://pypi.org/project/makejinja/) and can be installed via `pip`:
107
+
108
+ ```shell
109
+ pip install makejinja
110
+ makejinja -i ./input -o ./output
111
+ ```
112
+
113
+ ### Nix
114
+
115
+ If you use the `nix` package manager, you can add this repository as an input to your flake and use `makejinja.packages.${system}.default` or apply the overlay `makejinja.overlays.default`.
116
+ You can also run it directly as follows:
117
+
118
+ ```shell
119
+ nix run github:mirkolenz/makejinja -- -i ./input -o ./output
120
+ ```
121
+
122
+ ### Docker
123
+
124
+ We automatically publish an image to the [GitHub Container Registry](https://ghcr.io/mirkolenz/makejinja).
125
+ To use it, mount a directory to the container and pass the options as the command:
126
+
127
+ ```shell
128
+ docker run --rm -v $(pwd)/data:/data ghcr.io/mirkolenz/makejinja:latest -i /data/input -o /data/output
129
+ ```
130
+
131
+ ## Usage in Terminal / Command Line
132
+
133
+ In its default configuration, makejinja searches the input directory recursively for files ending in `.jinja`.
134
+ It then renders these files and writes them to the output directory, preserving the directory structure.
135
+ Our [documentation](https://mirkolenz.github.io/makejinja/makejinja/cli.html) contains a detailed description of all options and can also be accessed via `makejinja --help`.
@@ -0,0 +1,17 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ makejinja/__init__.py
5
+ makejinja/__main__.py
6
+ makejinja/app.py
7
+ makejinja/cli.py
8
+ makejinja/config.py
9
+ makejinja/plugin.py
10
+ makejinja/py.typed
11
+ makejinja.egg-info/PKG-INFO
12
+ makejinja.egg-info/SOURCES.txt
13
+ makejinja.egg-info/dependency_links.txt
14
+ makejinja.egg-info/entry_points.txt
15
+ makejinja.egg-info/requires.txt
16
+ makejinja.egg-info/top_level.txt
17
+ tests/test_makejinja.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ makejinja = makejinja.cli:makejinja_cli
@@ -0,0 +1,5 @@
1
+ jinja2<4,>=3
2
+ pyyaml<7,>=6
3
+ rich-click<2,>=1
4
+ typed-settings[attrs,cattrs,click]<25,>=23
5
+ immutables<1,>=0.20
@@ -0,0 +1 @@
1
+ makejinja
@@ -1,13 +1,11 @@
1
- [tool.poetry]
1
+ [project]
2
2
  name = "makejinja"
3
- version = "2.6.2"
3
+ version = "2.7.0"
4
4
  description = "Generate entire directory structures using Jinja templates with support for external data and custom plugins."
5
- authors = ["Mirko Lenz <mirko@mirkolenz.com>"]
6
- license = "MIT"
5
+ requires-python = ">=3.11"
6
+ authors = [{ name = "Mirko Lenz", email = "mirko@mirkolenz.com" }]
7
+ license = { file = "LICENSE" }
7
8
  readme = "README.md"
8
- repository = "https://github.com/mirkolenz/makejinja"
9
- homepage = "https://mirkolenz.github.io/makejinja/"
10
- documentation = "https://mirkolenz.github.io/makejinja/makejinja/cli.html"
11
9
  keywords = [
12
10
  "jinja2",
13
11
  "home-assistant",
@@ -39,29 +37,36 @@ classifiers = [
39
37
  "Topic :: Text Processing :: Markup",
40
38
  "Topic :: Utilities",
41
39
  "Typing :: Typed",
40
+ "Programming Language :: Python :: 3",
41
+ "Programming Language :: Python :: 3.11",
42
+ "Programming Language :: Python :: 3.12",
43
+ "Programming Language :: Python :: 3.13",
44
+ ]
45
+ dependencies = [
46
+ "jinja2>=3,<4",
47
+ "pyyaml>=6,<7",
48
+ "rich-click>=1,<2",
49
+ "typed-settings[attrs,cattrs,click]>=23,<25",
50
+ "immutables>=0.20,<1",
42
51
  ]
43
52
 
44
- [tool.poetry.scripts]
45
- makejinja = "makejinja.cli:makejinja_cli"
53
+ [project.urls]
54
+ Repository = "https://github.com/mirkolenz/makejinja"
55
+ Homepage = "https://mirkolenz.github.io/makejinja/"
56
+ Documentation = "https://mirkolenz.github.io/makejinja/makejinja/cli.html"
57
+ Issues = "https://github.com/mirkolenz/makejinja/issues"
58
+ Changelog = "https://github.com/mirkolenz/makejinja/releases"
46
59
 
47
- [tool.poetry.dependencies]
48
- python = "^3.11"
49
- jinja2 = "^3.1"
50
- pyyaml = "^6.0"
51
- rich-click = "^1.7"
52
- typed-settings = { version = ">=23.1, <25", extras = [
53
- "attrs",
54
- "cattrs",
55
- "click",
56
- ] }
57
- immutables = "^0.20"
60
+ [project.scripts]
61
+ makejinja = "makejinja.cli:makejinja_cli"
58
62
 
59
- [tool.poetry.group.dev.dependencies]
60
- pytest = "^8.0.0"
61
- pytest-cov = "^5.0.0"
63
+ [dependency-groups]
64
+ test = ["pytest>=8,<9", "pytest-cov>=6,<7"]
65
+ docs = ["pdoc>=15,<16"]
62
66
 
63
- [tool.poetry.group.docs.dependencies]
64
- pdoc = "^14.1"
67
+ [tool.uv]
68
+ default-groups = ["test", "docs"]
69
+ package = true
65
70
 
66
71
  [tool.pytest.ini_options]
67
72
  addopts = "--cov makejinja --cov-report term-missing"
@@ -74,6 +79,5 @@ ignore = ["E501"]
74
79
  [tool.ruff.pydocstyle]
75
80
  convention = "google"
76
81
 
77
- [build-system]
78
- requires = ["poetry-core"]
79
- build-backend = "poetry.core.masonry.api"
82
+ [tool.setuptools]
83
+ packages = ["makejinja"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,66 @@
1
+ from dataclasses import dataclass
2
+ from pathlib import Path
3
+
4
+ import pytest
5
+ from click.testing import CliRunner
6
+
7
+
8
+ @dataclass
9
+ class Paths:
10
+ input: Path
11
+ baseline: Path
12
+ output: Path
13
+
14
+ def __repr__(self) -> str:
15
+ return "makejinja"
16
+
17
+
18
+ @pytest.fixture(scope="session")
19
+ def exec(tmp_path_factory: pytest.TempPathFactory) -> Paths:
20
+ assert __package__ is not None
21
+ data_path = Path(__package__, "data")
22
+ input_path = data_path / "input"
23
+ baseline_path = data_path / "output"
24
+ output_path = tmp_path_factory.mktemp("data")
25
+
26
+ with pytest.MonkeyPatch.context() as m:
27
+ m.chdir(data_path)
28
+ runner = CliRunner()
29
+
30
+ # Need to import it AFTER chdir
31
+ from makejinja.cli import makejinja_cli
32
+
33
+ runner.invoke(
34
+ makejinja_cli,
35
+ [
36
+ # Override it here to use our tmp_path
37
+ "--output",
38
+ str(output_path),
39
+ ],
40
+ catch_exceptions=False,
41
+ color=True,
42
+ )
43
+
44
+ return Paths(input_path, baseline_path, output_path)
45
+
46
+
47
+ def _dir_content(path: Path) -> set[Path]:
48
+ return {item.relative_to(path) for item in path.rglob("*")}
49
+
50
+
51
+ def test_dir_content(exec: Paths):
52
+ assert _dir_content(exec.baseline) == _dir_content(exec.output)
53
+
54
+
55
+ def test_file_content(exec: Paths):
56
+ paths = _dir_content(exec.baseline)
57
+
58
+ for item in paths:
59
+ baseline_path = exec.baseline / item
60
+ output_path = exec.output / item
61
+
62
+ if baseline_path.is_file() and output_path.is_file():
63
+ baseline = baseline_path.read_text()
64
+ output = output_path.read_text()
65
+
66
+ assert baseline.strip() == output.strip(), str(item)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes