hokora 0.dev0__tar.gz → 0.1.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.
- hokora-0.1.0/PKG-INFO +190 -0
- hokora-0.1.0/README.md +167 -0
- hokora-0.1.0/hokora.egg-info/PKG-INFO +190 -0
- {hokora-0.dev0 → hokora-0.1.0}/hokora.egg-info/SOURCES.txt +1 -0
- {hokora-0.dev0 → hokora-0.1.0}/pyproject.toml +3 -1
- {hokora-0.dev0 → hokora-0.1.0}/src/__init__.py +11 -3
- hokora-0.dev0/PKG-INFO +0 -20
- hokora-0.dev0/hokora.egg-info/PKG-INFO +0 -20
- {hokora-0.dev0 → hokora-0.1.0}/COPYING +0 -0
- {hokora-0.dev0 → hokora-0.1.0}/hokora.egg-info/dependency_links.txt +0 -0
- {hokora-0.dev0 → hokora-0.1.0}/hokora.egg-info/entry_points.txt +0 -0
- {hokora-0.dev0 → hokora-0.1.0}/hokora.egg-info/requires.txt +0 -0
- {hokora-0.dev0 → hokora-0.1.0}/hokora.egg-info/top_level.txt +0 -0
- {hokora-0.dev0 → hokora-0.1.0}/setup.cfg +0 -0
hokora-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hokora
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A stand-alone renderer for Jinja2 templates
|
|
5
|
+
License-Expression: BSD-3-Clause
|
|
6
|
+
Project-URL: Homepage, https://gitlab.com/drmoose/hokora
|
|
7
|
+
Project-URL: Issues, https://gitlab.com/drmoose/hokora/-/issues
|
|
8
|
+
Project-URL: Repository, https://gitlab.com/drmoose/hokora.git
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: COPYING
|
|
12
|
+
Requires-Dist: jinja2
|
|
13
|
+
Provides-Extra: check
|
|
14
|
+
Requires-Dist: ruff; extra == "check"
|
|
15
|
+
Requires-Dist: mypy; extra == "check"
|
|
16
|
+
Provides-Extra: toml
|
|
17
|
+
Requires-Dist: toml; extra == "toml"
|
|
18
|
+
Provides-Extra: yaml
|
|
19
|
+
Requires-Dist: PyYAML; extra == "yaml"
|
|
20
|
+
Provides-Extra: all
|
|
21
|
+
Requires-Dist: hokora[toml,yaml]; extra == "all"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
<!-- vim: set ft=mdjinja et tw=80 cc : -->
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# `hokora` is a [Jinja2][jinja-main] standalone template parser
|
|
28
|
+
|
|
29
|
+
You might be familiar with [Jinja2 templates][jinja-wikipedia] if you've worked
|
|
30
|
+
with [Flask][flask], [Ansible][ansible], [Salt][salt] or [dbt][dbt]. `hokora`
|
|
31
|
+
is a tool for rendering Jinja templates on the command line, or as part of a
|
|
32
|
+
bash pipeline.
|
|
33
|
+
|
|
34
|
+
`README.md` in this repository is itself generated by hokora, from the
|
|
35
|
+
README.md.in.
|
|
36
|
+
|
|
37
|
+
# Usage
|
|
38
|
+
```
|
|
39
|
+
usage: hokora [-h] [--context CONTEXT] [--environ] [-C C] [--no-include-env]
|
|
40
|
+
[--no-include-cwd] [--no-include-template-dir]
|
|
41
|
+
[--include INCLUDE] [--autoescape | --no-autoescape]
|
|
42
|
+
[--strip-shebang | --no-strip-shebang]
|
|
43
|
+
[template]
|
|
44
|
+
|
|
45
|
+
Hokora: Standalone Jinja2 template renderer
|
|
46
|
+
|
|
47
|
+
positional arguments:
|
|
48
|
+
template path to template to render
|
|
49
|
+
|
|
50
|
+
options:
|
|
51
|
+
-h, --help show this help message and exit
|
|
52
|
+
--autoescape, --no-autoescape
|
|
53
|
+
whether to escape HTML entities in jinja expressions
|
|
54
|
+
--strip-shebang, --no-strip-shebang
|
|
55
|
+
remove the first line of the output if it is a bash
|
|
56
|
+
shebang
|
|
57
|
+
|
|
58
|
+
Jinja Context Variables:
|
|
59
|
+
--context, -c CONTEXT
|
|
60
|
+
Read the given file for context values to supply as
|
|
61
|
+
jinja variables. Use key=filename if you want to
|
|
62
|
+
namespace the data, like {{key.somevar}}. See
|
|
63
|
+
AVAILABLE CONTEXT FORMATS below for supported file
|
|
64
|
+
extensions.
|
|
65
|
+
--environ, -e Make environment variables available as jinja
|
|
66
|
+
variables
|
|
67
|
+
|
|
68
|
+
Template search paths:
|
|
69
|
+
-C C Change directories to this folder and interpret all
|
|
70
|
+
paths as relative to it.
|
|
71
|
+
--no-include-env Don't parse $JINJA_TEMPLATE_DIRS for include folders
|
|
72
|
+
--no-include-cwd Don't include the current working directory in the
|
|
73
|
+
search path
|
|
74
|
+
--no-include-template-dir
|
|
75
|
+
Don't include the template's folder in the search
|
|
76
|
+
path.
|
|
77
|
+
--include, -I INCLUDE
|
|
78
|
+
Add this folder to the template include path
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
ENVIRONMENT VARIABLES
|
|
82
|
+
|
|
83
|
+
$JINJA_TEMPLATE_DIRS
|
|
84
|
+
A :-separated list of additional template include paths, which
|
|
85
|
+
will be searched to handle {%extends %}, {%include %} and {%import %}
|
|
86
|
+
tags unless --no-include-env is passed at the command line.
|
|
87
|
+
|
|
88
|
+
$HOKORA_MODULES
|
|
89
|
+
Additional python modules (honoring $PYTHONPATH) to import at load time.
|
|
90
|
+
These can be used to extend the functionality of hokora if they contain
|
|
91
|
+
subclasses of DataFormat or HokoraFeature.
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
AVAILABLE CONTEXT FORMATS
|
|
95
|
+
|
|
96
|
+
json {{ ... | json }} *.json
|
|
97
|
+
python {{ ... | python }} *.py, *.pyc, *.pyd, *.so
|
|
98
|
+
pickle {{ ... | pickle }} *.pkl, *.pickle
|
|
99
|
+
toml {{ ... | toml }} *.toml
|
|
100
|
+
yaml {{ ... | yaml }} *.yaml, *.yml
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
# Installation
|
|
105
|
+
|
|
106
|
+
`hokora` requires Python 3.10 or better.
|
|
107
|
+
|
|
108
|
+
## Standalone script via [`uv`][uv]
|
|
109
|
+
|
|
110
|
+
If you're on a Unix-like operating system, the [`./hokora`](./hokora) script
|
|
111
|
+
in the root of this repo can just be copied into `~/.local/bin` or some
|
|
112
|
+
appropriate place on your `$PATH`. `uv` will reach out to gitlab and grab the
|
|
113
|
+
latest version the first time you run it.
|
|
114
|
+
|
|
115
|
+
## Local install via [`pipx`][pipx]
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pipx install git+https://gitlab.com/drmoose/hokora
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Local install via [`pip`][pip]
|
|
122
|
+
|
|
123
|
+
`pip` versions below 24.0.0, which, sadly, includes [the one on ubuntu
|
|
124
|
+
22.04 Jammy][jammy-pip] (although this is fixed on 24.04 Noble and beyond),
|
|
125
|
+
cannot install a `pyproject.toml`-based project correctly from gitlab. It'll
|
|
126
|
+
get installed [under the name UNKNOWN instead][old-pip-unknown]. To work
|
|
127
|
+
around this, upgrade pip before attempting to install.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
python3 -m pip install --upgrade pip
|
|
131
|
+
python3 -m pip install git+https://gitlab.com/drmoose/hokora
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
# Metadata
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
hokora is licensed under a [BSD 3-Clause License](./COPYING), like Jinja itself.
|
|
140
|
+
|
|
141
|
+
hokora's icon is licensed under [creative commons attribution share-alike 4.0
|
|
142
|
+
international][ccbysa4] with a hat tip to wikimedia user Immanuelle who made
|
|
143
|
+
the [original][icon-upstream].
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
## Name
|
|
147
|
+
|
|
148
|
+
Jinja itself [says][jinja-faq-name] it's named for a [Shinto
|
|
149
|
+
shrine][shrine-wikipedia] because the word "template" sounds vaguely like the
|
|
150
|
+
word "temple." Well, two can play the Wikipedia game. A
|
|
151
|
+
[_Hokora_][hokora-wikipedia] is a miniature Shinto shrine, and `hokora` is a
|
|
152
|
+
miniature wrapper around Jinja.
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
## Contributing
|
|
156
|
+
|
|
157
|
+
Issues and MRs are welcome.
|
|
158
|
+
|
|
159
|
+
- The `main` branch is kept stable. Tinker in topic branches.
|
|
160
|
+
- Don't edit `README.md` directly; edit `README.md.in`.
|
|
161
|
+
- Update version numbers as necessary. Follow [semver][semver]
|
|
162
|
+
- Make sure your code is sane:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
ruff format
|
|
166
|
+
ruff check
|
|
167
|
+
mypy --check-untyped-defs .
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
<!-- `links -->
|
|
172
|
+
|
|
173
|
+
[jinja-main]: https://jinja.palletsprojects.com
|
|
174
|
+
[jinja-example]: https://jinja.palletsprojects.com/en/stable/templates/#synopsis
|
|
175
|
+
[jinja-wikipedia]: https://en.wikipedia.org/wiki/Jinja_(template_engine)
|
|
176
|
+
[jinja-faq-name]: https://jinja.palletsprojects.com/en/stable/faq/#why-is-it-called-jinja
|
|
177
|
+
[flask]: https://flask.palletsprojects.com/en/stable/tutorial/templates/
|
|
178
|
+
[ansible]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_templating.html
|
|
179
|
+
[salt]: https://docs.saltproject.io/en/latest/topics/jinja/index.html
|
|
180
|
+
[dbt]: https://docs.getdbt.com/docs/build/jinja-macros
|
|
181
|
+
[ccbysa4]: https://creativecommons.org/licenses/by-sa/4.0/deed.en
|
|
182
|
+
[icon-upstream]: https://commons.wikimedia.org/wiki/File:%E7%A5%A0svg.svg
|
|
183
|
+
[shrine-wikipedia]: https://en.wikipedia.org/wiki/Shinto_shrine
|
|
184
|
+
[hokora-wikipedia]: https://en.wikipedia.org/wiki/Hokora
|
|
185
|
+
[jammy-pip]: https://packages.ubuntu.com/jammy/python3-pip
|
|
186
|
+
[uv]: https://docs.astral.sh/uv/getting-started/installation/
|
|
187
|
+
[pipx]: https://pipx.pypa.io/latest/installation/
|
|
188
|
+
[pip]: https://pypi.org/project/pip/
|
|
189
|
+
[old-pip-unknown]: https://stackoverflow.com/q/78034052
|
|
190
|
+
[semver]: https://semver.org/
|
hokora-0.1.0/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<!-- vim: set ft=mdjinja et tw=80 cc : -->
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# `hokora` is a [Jinja2][jinja-main] standalone template parser
|
|
5
|
+
|
|
6
|
+
You might be familiar with [Jinja2 templates][jinja-wikipedia] if you've worked
|
|
7
|
+
with [Flask][flask], [Ansible][ansible], [Salt][salt] or [dbt][dbt]. `hokora`
|
|
8
|
+
is a tool for rendering Jinja templates on the command line, or as part of a
|
|
9
|
+
bash pipeline.
|
|
10
|
+
|
|
11
|
+
`README.md` in this repository is itself generated by hokora, from the
|
|
12
|
+
README.md.in.
|
|
13
|
+
|
|
14
|
+
# Usage
|
|
15
|
+
```
|
|
16
|
+
usage: hokora [-h] [--context CONTEXT] [--environ] [-C C] [--no-include-env]
|
|
17
|
+
[--no-include-cwd] [--no-include-template-dir]
|
|
18
|
+
[--include INCLUDE] [--autoescape | --no-autoescape]
|
|
19
|
+
[--strip-shebang | --no-strip-shebang]
|
|
20
|
+
[template]
|
|
21
|
+
|
|
22
|
+
Hokora: Standalone Jinja2 template renderer
|
|
23
|
+
|
|
24
|
+
positional arguments:
|
|
25
|
+
template path to template to render
|
|
26
|
+
|
|
27
|
+
options:
|
|
28
|
+
-h, --help show this help message and exit
|
|
29
|
+
--autoescape, --no-autoescape
|
|
30
|
+
whether to escape HTML entities in jinja expressions
|
|
31
|
+
--strip-shebang, --no-strip-shebang
|
|
32
|
+
remove the first line of the output if it is a bash
|
|
33
|
+
shebang
|
|
34
|
+
|
|
35
|
+
Jinja Context Variables:
|
|
36
|
+
--context, -c CONTEXT
|
|
37
|
+
Read the given file for context values to supply as
|
|
38
|
+
jinja variables. Use key=filename if you want to
|
|
39
|
+
namespace the data, like {{key.somevar}}. See
|
|
40
|
+
AVAILABLE CONTEXT FORMATS below for supported file
|
|
41
|
+
extensions.
|
|
42
|
+
--environ, -e Make environment variables available as jinja
|
|
43
|
+
variables
|
|
44
|
+
|
|
45
|
+
Template search paths:
|
|
46
|
+
-C C Change directories to this folder and interpret all
|
|
47
|
+
paths as relative to it.
|
|
48
|
+
--no-include-env Don't parse $JINJA_TEMPLATE_DIRS for include folders
|
|
49
|
+
--no-include-cwd Don't include the current working directory in the
|
|
50
|
+
search path
|
|
51
|
+
--no-include-template-dir
|
|
52
|
+
Don't include the template's folder in the search
|
|
53
|
+
path.
|
|
54
|
+
--include, -I INCLUDE
|
|
55
|
+
Add this folder to the template include path
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
ENVIRONMENT VARIABLES
|
|
59
|
+
|
|
60
|
+
$JINJA_TEMPLATE_DIRS
|
|
61
|
+
A :-separated list of additional template include paths, which
|
|
62
|
+
will be searched to handle {%extends %}, {%include %} and {%import %}
|
|
63
|
+
tags unless --no-include-env is passed at the command line.
|
|
64
|
+
|
|
65
|
+
$HOKORA_MODULES
|
|
66
|
+
Additional python modules (honoring $PYTHONPATH) to import at load time.
|
|
67
|
+
These can be used to extend the functionality of hokora if they contain
|
|
68
|
+
subclasses of DataFormat or HokoraFeature.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
AVAILABLE CONTEXT FORMATS
|
|
72
|
+
|
|
73
|
+
json {{ ... | json }} *.json
|
|
74
|
+
python {{ ... | python }} *.py, *.pyc, *.pyd, *.so
|
|
75
|
+
pickle {{ ... | pickle }} *.pkl, *.pickle
|
|
76
|
+
toml {{ ... | toml }} *.toml
|
|
77
|
+
yaml {{ ... | yaml }} *.yaml, *.yml
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
# Installation
|
|
82
|
+
|
|
83
|
+
`hokora` requires Python 3.10 or better.
|
|
84
|
+
|
|
85
|
+
## Standalone script via [`uv`][uv]
|
|
86
|
+
|
|
87
|
+
If you're on a Unix-like operating system, the [`./hokora`](./hokora) script
|
|
88
|
+
in the root of this repo can just be copied into `~/.local/bin` or some
|
|
89
|
+
appropriate place on your `$PATH`. `uv` will reach out to gitlab and grab the
|
|
90
|
+
latest version the first time you run it.
|
|
91
|
+
|
|
92
|
+
## Local install via [`pipx`][pipx]
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pipx install git+https://gitlab.com/drmoose/hokora
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Local install via [`pip`][pip]
|
|
99
|
+
|
|
100
|
+
`pip` versions below 24.0.0, which, sadly, includes [the one on ubuntu
|
|
101
|
+
22.04 Jammy][jammy-pip] (although this is fixed on 24.04 Noble and beyond),
|
|
102
|
+
cannot install a `pyproject.toml`-based project correctly from gitlab. It'll
|
|
103
|
+
get installed [under the name UNKNOWN instead][old-pip-unknown]. To work
|
|
104
|
+
around this, upgrade pip before attempting to install.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
python3 -m pip install --upgrade pip
|
|
108
|
+
python3 -m pip install git+https://gitlab.com/drmoose/hokora
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
# Metadata
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
hokora is licensed under a [BSD 3-Clause License](./COPYING), like Jinja itself.
|
|
117
|
+
|
|
118
|
+
hokora's icon is licensed under [creative commons attribution share-alike 4.0
|
|
119
|
+
international][ccbysa4] with a hat tip to wikimedia user Immanuelle who made
|
|
120
|
+
the [original][icon-upstream].
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
## Name
|
|
124
|
+
|
|
125
|
+
Jinja itself [says][jinja-faq-name] it's named for a [Shinto
|
|
126
|
+
shrine][shrine-wikipedia] because the word "template" sounds vaguely like the
|
|
127
|
+
word "temple." Well, two can play the Wikipedia game. A
|
|
128
|
+
[_Hokora_][hokora-wikipedia] is a miniature Shinto shrine, and `hokora` is a
|
|
129
|
+
miniature wrapper around Jinja.
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
## Contributing
|
|
133
|
+
|
|
134
|
+
Issues and MRs are welcome.
|
|
135
|
+
|
|
136
|
+
- The `main` branch is kept stable. Tinker in topic branches.
|
|
137
|
+
- Don't edit `README.md` directly; edit `README.md.in`.
|
|
138
|
+
- Update version numbers as necessary. Follow [semver][semver]
|
|
139
|
+
- Make sure your code is sane:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
ruff format
|
|
143
|
+
ruff check
|
|
144
|
+
mypy --check-untyped-defs .
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
<!-- `links -->
|
|
149
|
+
|
|
150
|
+
[jinja-main]: https://jinja.palletsprojects.com
|
|
151
|
+
[jinja-example]: https://jinja.palletsprojects.com/en/stable/templates/#synopsis
|
|
152
|
+
[jinja-wikipedia]: https://en.wikipedia.org/wiki/Jinja_(template_engine)
|
|
153
|
+
[jinja-faq-name]: https://jinja.palletsprojects.com/en/stable/faq/#why-is-it-called-jinja
|
|
154
|
+
[flask]: https://flask.palletsprojects.com/en/stable/tutorial/templates/
|
|
155
|
+
[ansible]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_templating.html
|
|
156
|
+
[salt]: https://docs.saltproject.io/en/latest/topics/jinja/index.html
|
|
157
|
+
[dbt]: https://docs.getdbt.com/docs/build/jinja-macros
|
|
158
|
+
[ccbysa4]: https://creativecommons.org/licenses/by-sa/4.0/deed.en
|
|
159
|
+
[icon-upstream]: https://commons.wikimedia.org/wiki/File:%E7%A5%A0svg.svg
|
|
160
|
+
[shrine-wikipedia]: https://en.wikipedia.org/wiki/Shinto_shrine
|
|
161
|
+
[hokora-wikipedia]: https://en.wikipedia.org/wiki/Hokora
|
|
162
|
+
[jammy-pip]: https://packages.ubuntu.com/jammy/python3-pip
|
|
163
|
+
[uv]: https://docs.astral.sh/uv/getting-started/installation/
|
|
164
|
+
[pipx]: https://pipx.pypa.io/latest/installation/
|
|
165
|
+
[pip]: https://pypi.org/project/pip/
|
|
166
|
+
[old-pip-unknown]: https://stackoverflow.com/q/78034052
|
|
167
|
+
[semver]: https://semver.org/
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hokora
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A stand-alone renderer for Jinja2 templates
|
|
5
|
+
License-Expression: BSD-3-Clause
|
|
6
|
+
Project-URL: Homepage, https://gitlab.com/drmoose/hokora
|
|
7
|
+
Project-URL: Issues, https://gitlab.com/drmoose/hokora/-/issues
|
|
8
|
+
Project-URL: Repository, https://gitlab.com/drmoose/hokora.git
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: COPYING
|
|
12
|
+
Requires-Dist: jinja2
|
|
13
|
+
Provides-Extra: check
|
|
14
|
+
Requires-Dist: ruff; extra == "check"
|
|
15
|
+
Requires-Dist: mypy; extra == "check"
|
|
16
|
+
Provides-Extra: toml
|
|
17
|
+
Requires-Dist: toml; extra == "toml"
|
|
18
|
+
Provides-Extra: yaml
|
|
19
|
+
Requires-Dist: PyYAML; extra == "yaml"
|
|
20
|
+
Provides-Extra: all
|
|
21
|
+
Requires-Dist: hokora[toml,yaml]; extra == "all"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
<!-- vim: set ft=mdjinja et tw=80 cc : -->
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# `hokora` is a [Jinja2][jinja-main] standalone template parser
|
|
28
|
+
|
|
29
|
+
You might be familiar with [Jinja2 templates][jinja-wikipedia] if you've worked
|
|
30
|
+
with [Flask][flask], [Ansible][ansible], [Salt][salt] or [dbt][dbt]. `hokora`
|
|
31
|
+
is a tool for rendering Jinja templates on the command line, or as part of a
|
|
32
|
+
bash pipeline.
|
|
33
|
+
|
|
34
|
+
`README.md` in this repository is itself generated by hokora, from the
|
|
35
|
+
README.md.in.
|
|
36
|
+
|
|
37
|
+
# Usage
|
|
38
|
+
```
|
|
39
|
+
usage: hokora [-h] [--context CONTEXT] [--environ] [-C C] [--no-include-env]
|
|
40
|
+
[--no-include-cwd] [--no-include-template-dir]
|
|
41
|
+
[--include INCLUDE] [--autoescape | --no-autoescape]
|
|
42
|
+
[--strip-shebang | --no-strip-shebang]
|
|
43
|
+
[template]
|
|
44
|
+
|
|
45
|
+
Hokora: Standalone Jinja2 template renderer
|
|
46
|
+
|
|
47
|
+
positional arguments:
|
|
48
|
+
template path to template to render
|
|
49
|
+
|
|
50
|
+
options:
|
|
51
|
+
-h, --help show this help message and exit
|
|
52
|
+
--autoescape, --no-autoescape
|
|
53
|
+
whether to escape HTML entities in jinja expressions
|
|
54
|
+
--strip-shebang, --no-strip-shebang
|
|
55
|
+
remove the first line of the output if it is a bash
|
|
56
|
+
shebang
|
|
57
|
+
|
|
58
|
+
Jinja Context Variables:
|
|
59
|
+
--context, -c CONTEXT
|
|
60
|
+
Read the given file for context values to supply as
|
|
61
|
+
jinja variables. Use key=filename if you want to
|
|
62
|
+
namespace the data, like {{key.somevar}}. See
|
|
63
|
+
AVAILABLE CONTEXT FORMATS below for supported file
|
|
64
|
+
extensions.
|
|
65
|
+
--environ, -e Make environment variables available as jinja
|
|
66
|
+
variables
|
|
67
|
+
|
|
68
|
+
Template search paths:
|
|
69
|
+
-C C Change directories to this folder and interpret all
|
|
70
|
+
paths as relative to it.
|
|
71
|
+
--no-include-env Don't parse $JINJA_TEMPLATE_DIRS for include folders
|
|
72
|
+
--no-include-cwd Don't include the current working directory in the
|
|
73
|
+
search path
|
|
74
|
+
--no-include-template-dir
|
|
75
|
+
Don't include the template's folder in the search
|
|
76
|
+
path.
|
|
77
|
+
--include, -I INCLUDE
|
|
78
|
+
Add this folder to the template include path
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
ENVIRONMENT VARIABLES
|
|
82
|
+
|
|
83
|
+
$JINJA_TEMPLATE_DIRS
|
|
84
|
+
A :-separated list of additional template include paths, which
|
|
85
|
+
will be searched to handle {%extends %}, {%include %} and {%import %}
|
|
86
|
+
tags unless --no-include-env is passed at the command line.
|
|
87
|
+
|
|
88
|
+
$HOKORA_MODULES
|
|
89
|
+
Additional python modules (honoring $PYTHONPATH) to import at load time.
|
|
90
|
+
These can be used to extend the functionality of hokora if they contain
|
|
91
|
+
subclasses of DataFormat or HokoraFeature.
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
AVAILABLE CONTEXT FORMATS
|
|
95
|
+
|
|
96
|
+
json {{ ... | json }} *.json
|
|
97
|
+
python {{ ... | python }} *.py, *.pyc, *.pyd, *.so
|
|
98
|
+
pickle {{ ... | pickle }} *.pkl, *.pickle
|
|
99
|
+
toml {{ ... | toml }} *.toml
|
|
100
|
+
yaml {{ ... | yaml }} *.yaml, *.yml
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
# Installation
|
|
105
|
+
|
|
106
|
+
`hokora` requires Python 3.10 or better.
|
|
107
|
+
|
|
108
|
+
## Standalone script via [`uv`][uv]
|
|
109
|
+
|
|
110
|
+
If you're on a Unix-like operating system, the [`./hokora`](./hokora) script
|
|
111
|
+
in the root of this repo can just be copied into `~/.local/bin` or some
|
|
112
|
+
appropriate place on your `$PATH`. `uv` will reach out to gitlab and grab the
|
|
113
|
+
latest version the first time you run it.
|
|
114
|
+
|
|
115
|
+
## Local install via [`pipx`][pipx]
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pipx install git+https://gitlab.com/drmoose/hokora
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Local install via [`pip`][pip]
|
|
122
|
+
|
|
123
|
+
`pip` versions below 24.0.0, which, sadly, includes [the one on ubuntu
|
|
124
|
+
22.04 Jammy][jammy-pip] (although this is fixed on 24.04 Noble and beyond),
|
|
125
|
+
cannot install a `pyproject.toml`-based project correctly from gitlab. It'll
|
|
126
|
+
get installed [under the name UNKNOWN instead][old-pip-unknown]. To work
|
|
127
|
+
around this, upgrade pip before attempting to install.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
python3 -m pip install --upgrade pip
|
|
131
|
+
python3 -m pip install git+https://gitlab.com/drmoose/hokora
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
# Metadata
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
hokora is licensed under a [BSD 3-Clause License](./COPYING), like Jinja itself.
|
|
140
|
+
|
|
141
|
+
hokora's icon is licensed under [creative commons attribution share-alike 4.0
|
|
142
|
+
international][ccbysa4] with a hat tip to wikimedia user Immanuelle who made
|
|
143
|
+
the [original][icon-upstream].
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
## Name
|
|
147
|
+
|
|
148
|
+
Jinja itself [says][jinja-faq-name] it's named for a [Shinto
|
|
149
|
+
shrine][shrine-wikipedia] because the word "template" sounds vaguely like the
|
|
150
|
+
word "temple." Well, two can play the Wikipedia game. A
|
|
151
|
+
[_Hokora_][hokora-wikipedia] is a miniature Shinto shrine, and `hokora` is a
|
|
152
|
+
miniature wrapper around Jinja.
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
## Contributing
|
|
156
|
+
|
|
157
|
+
Issues and MRs are welcome.
|
|
158
|
+
|
|
159
|
+
- The `main` branch is kept stable. Tinker in topic branches.
|
|
160
|
+
- Don't edit `README.md` directly; edit `README.md.in`.
|
|
161
|
+
- Update version numbers as necessary. Follow [semver][semver]
|
|
162
|
+
- Make sure your code is sane:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
ruff format
|
|
166
|
+
ruff check
|
|
167
|
+
mypy --check-untyped-defs .
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
<!-- `links -->
|
|
172
|
+
|
|
173
|
+
[jinja-main]: https://jinja.palletsprojects.com
|
|
174
|
+
[jinja-example]: https://jinja.palletsprojects.com/en/stable/templates/#synopsis
|
|
175
|
+
[jinja-wikipedia]: https://en.wikipedia.org/wiki/Jinja_(template_engine)
|
|
176
|
+
[jinja-faq-name]: https://jinja.palletsprojects.com/en/stable/faq/#why-is-it-called-jinja
|
|
177
|
+
[flask]: https://flask.palletsprojects.com/en/stable/tutorial/templates/
|
|
178
|
+
[ansible]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_templating.html
|
|
179
|
+
[salt]: https://docs.saltproject.io/en/latest/topics/jinja/index.html
|
|
180
|
+
[dbt]: https://docs.getdbt.com/docs/build/jinja-macros
|
|
181
|
+
[ccbysa4]: https://creativecommons.org/licenses/by-sa/4.0/deed.en
|
|
182
|
+
[icon-upstream]: https://commons.wikimedia.org/wiki/File:%E7%A5%A0svg.svg
|
|
183
|
+
[shrine-wikipedia]: https://en.wikipedia.org/wiki/Shinto_shrine
|
|
184
|
+
[hokora-wikipedia]: https://en.wikipedia.org/wiki/Hokora
|
|
185
|
+
[jammy-pip]: https://packages.ubuntu.com/jammy/python3-pip
|
|
186
|
+
[uv]: https://docs.astral.sh/uv/getting-started/installation/
|
|
187
|
+
[pipx]: https://pipx.pypa.io/latest/installation/
|
|
188
|
+
[pip]: https://pypi.org/project/pip/
|
|
189
|
+
[old-pip-unknown]: https://stackoverflow.com/q/78034052
|
|
190
|
+
[semver]: https://semver.org/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "hokora"
|
|
3
|
-
|
|
3
|
+
description = "A stand-alone renderer for Jinja2 templates"
|
|
4
|
+
version = "0.1.0"
|
|
4
5
|
requires-python = ">=3.10"
|
|
5
6
|
readme = "README.md"
|
|
6
7
|
dependencies = ["jinja2"]
|
|
@@ -16,6 +17,7 @@ all = ["hokora[toml,yaml]"]
|
|
|
16
17
|
[project.urls]
|
|
17
18
|
Homepage = "https://gitlab.com/drmoose/hokora"
|
|
18
19
|
Issues = "https://gitlab.com/drmoose/hokora/-/issues"
|
|
20
|
+
Repository = "https://gitlab.com/drmoose/hokora.git"
|
|
19
21
|
|
|
20
22
|
[project.scripts]
|
|
21
23
|
hokora = "hokora:main"
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# /// script
|
|
2
|
+
# dependencies = [
|
|
3
|
+
# "jinja2",
|
|
4
|
+
# "toml",
|
|
5
|
+
# "PyYAML",
|
|
6
|
+
# ]
|
|
7
|
+
# ///
|
|
8
|
+
|
|
1
9
|
import argparse
|
|
2
10
|
import importlib.machinery
|
|
3
11
|
import importlib.util
|
|
@@ -334,8 +342,7 @@ class TemplateSearchPaths(HokoraFeature):
|
|
|
334
342
|
group.add_argument(
|
|
335
343
|
'--no-include-cwd',
|
|
336
344
|
help=(
|
|
337
|
-
"Don't include the current working directory in the search "
|
|
338
|
-
'path'
|
|
345
|
+
"Don't include the current working directory in the search path"
|
|
339
346
|
),
|
|
340
347
|
action='store_true',
|
|
341
348
|
)
|
|
@@ -442,6 +449,7 @@ def make_argument_parser():
|
|
|
442
449
|
name = name_builder.getvalue()
|
|
443
450
|
sio.write(f' {name}{getattr(f, "__doc__", "") or ""}\n')
|
|
444
451
|
main = argparse.ArgumentParser(
|
|
452
|
+
prog='hokora',
|
|
445
453
|
description='Hokora: Standalone Jinja2 template renderer',
|
|
446
454
|
epilog=sio.getvalue(),
|
|
447
455
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
@@ -609,7 +617,7 @@ def main():
|
|
|
609
617
|
for feat in features:
|
|
610
618
|
rendered = feat.postprocess_output(rendered)
|
|
611
619
|
|
|
612
|
-
print(rendered
|
|
620
|
+
print(rendered)
|
|
613
621
|
|
|
614
622
|
|
|
615
623
|
if __name__ == '__main__':
|
hokora-0.dev0/PKG-INFO
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: hokora
|
|
3
|
-
Version: 0.dev0
|
|
4
|
-
License-Expression: BSD-3-Clause
|
|
5
|
-
Project-URL: Homepage, https://gitlab.com/drmoose/hokora
|
|
6
|
-
Project-URL: Issues, https://gitlab.com/drmoose/hokora/-/issues
|
|
7
|
-
Requires-Python: >=3.10
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
License-File: COPYING
|
|
10
|
-
Requires-Dist: jinja2
|
|
11
|
-
Provides-Extra: check
|
|
12
|
-
Requires-Dist: ruff; extra == "check"
|
|
13
|
-
Requires-Dist: mypy; extra == "check"
|
|
14
|
-
Provides-Extra: toml
|
|
15
|
-
Requires-Dist: toml; extra == "toml"
|
|
16
|
-
Provides-Extra: yaml
|
|
17
|
-
Requires-Dist: PyYAML; extra == "yaml"
|
|
18
|
-
Provides-Extra: all
|
|
19
|
-
Requires-Dist: hokora[toml,yaml]; extra == "all"
|
|
20
|
-
Dynamic: license-file
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: hokora
|
|
3
|
-
Version: 0.dev0
|
|
4
|
-
License-Expression: BSD-3-Clause
|
|
5
|
-
Project-URL: Homepage, https://gitlab.com/drmoose/hokora
|
|
6
|
-
Project-URL: Issues, https://gitlab.com/drmoose/hokora/-/issues
|
|
7
|
-
Requires-Python: >=3.10
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
License-File: COPYING
|
|
10
|
-
Requires-Dist: jinja2
|
|
11
|
-
Provides-Extra: check
|
|
12
|
-
Requires-Dist: ruff; extra == "check"
|
|
13
|
-
Requires-Dist: mypy; extra == "check"
|
|
14
|
-
Provides-Extra: toml
|
|
15
|
-
Requires-Dist: toml; extra == "toml"
|
|
16
|
-
Provides-Extra: yaml
|
|
17
|
-
Requires-Dist: PyYAML; extra == "yaml"
|
|
18
|
-
Provides-Extra: all
|
|
19
|
-
Requires-Dist: hokora[toml,yaml]; extra == "all"
|
|
20
|
-
Dynamic: license-file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|