Skip to content

Commit 897cce9

Browse files
authored
Merge pull request #395 from moremoban/dev
release 0.7.10
2 parents 141d3be + 36ee1af commit 897cce9

File tree

11 files changed

+67
-30
lines changed

11 files changed

+67
-30
lines changed

.moban.cd/changelog.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ releases:
44
- changes:
55
- action: Updated
66
details:
7-
- "`#390`: single render action will print to stdout by defafult"
7+
- "`#393`: Rendered content output to stdout once"
8+
date: 16.08.2020
9+
version: 0.7.10
10+
- changes:
11+
- action: Updated
12+
details:
13+
- "`#390`: single render action will print to stdout by default"
814
date: 06.08.2020
915
version: 0.7.9
1016
- changes:

.moban.cd/moban.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ organisation: moremoban
44
author: C. W.
55
66
license: MIT
7-
version: 0.7.9
8-
current_version: 0.7.9
9-
release: 0.7.9
7+
version: 0.7.10
8+
current_version: 0.7.10
9+
release: 0.7.10
1010
branch: master
1111
master: index
1212
command_line_interface: "moban"

.moban.d/moban_readme.jj2

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ A bit formal example:
7070

7171
.. code-block:: bash
7272

73-
$ moban -c data.yml -t my.template
73+
$ moban -c data.yml -t my.template
7474
world
7575

7676
Given data.yml as:
@@ -222,9 +222,6 @@ You can start using it like this:
222222
.. code-block:: bash
223223

224224
$ moban --template-type de-duplicate -pd custom-plugin -t duplicated_content.txt
225-
De-duplicating duplicated_content.txt to moban.output
226-
De-duplicating 1 file.
227-
Everything is up to date!
228225

229226

230227
TOML data format

CHANGELOG.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
Change log
22
================================================================================
33

4+
0.7.10 - 16.08.2020
5+
--------------------------------------------------------------------------------
6+
7+
**Updated**
8+
9+
#. `#393 <https://github.com/moremoban/moban/issues/393>`_: Rendered content
10+
output to stdout once
11+
412
0.7.9 - 06.08.2020
513
--------------------------------------------------------------------------------
614

715
**Updated**
816

917
#. `#390 <https://github.com/moremoban/moban/issues/390>`_: single render action
10-
will print to stdout by defafult
18+
will print to stdout by default
1119

1220
0.7.8 - 09.06.2020
1321
--------------------------------------------------------------------------------

CONTRIBUTORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ In alphabetical order:
88
* `John Vandenberg <https://github.com/jayvdb>`_
99
* `Joshua Chung <https://github.com/seeeturtle>`_
1010
* `PRAJWAL M <https://github.com/PrajwalM2212>`_
11+
* `salotz <https://github.com/salotz>`_
1112
* `SerekKiri <https://github.com/SerekKiri>`_

README.rst

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ A bit formal example:
6969

7070
.. code-block:: bash
7171
72-
$ moban -c data.yml -t my.template
72+
$ moban -c data.yml -t my.template
7373
world
7474
7575
Given data.yml as:
@@ -216,9 +216,6 @@ Given a data.json file with the following content
216216
217217
218218
$ moban --template-type handlebars -c data.json "{{person.firstname}} {{person.lastname}}"
219-
Handlebars-ing <p>{{first... to moban.output
220-
Handlebarsed 1 file.
221-
$ cat moban.output
222219
Yehuda Katz
223220
224221
For `handlebars.js` users, yes, the example was copied from handlebarjs.com. The
@@ -314,9 +311,6 @@ And given the following velocity.template:
314311
.. code-block:: bash
315312
316313
$ moban --template-type velocity -c data.json -t velocity.template
317-
Velocity-templating vo.t to moban.output
318-
Velocity-templated 1 file.
319-
$ cat moban.output
320314
Old people:
321315
322316
Bill
@@ -355,9 +349,6 @@ You can start using it like this:
355349
.. code-block:: bash
356350
357351
$ moban --template-type de-duplicate -pd custom-plugin -t duplicated_content.txt
358-
De-duplicating duplicated_content.txt to moban.output
359-
De-duplicating 1 file.
360-
Everything is up to date!
361352
362353
363354
TOML data format
@@ -380,9 +371,6 @@ You can do:
380371
.. code-block:: bash
381372
382373
$ moban -c sample.toml "{{owner.name}} made {{title}}"
383-
Templating {{owner.na... to moban.output
384-
Templated 1 file.
385-
$ cat moban.output
386374
Tom Preston-Werner made TOML Example
387375
388376
Not limited to toml, you can supply moban with the following data formats:

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
copyright = '2017-2020 Onni Software Ltd.'
2626
author = 'C. W.'
2727
# The short X.Y version
28-
version = '0.7.9'
28+
version = '0.7.10'
2929
# The full version, including alpha/beta/rc tags
30-
release = '0.7.9'
30+
release = '0.7.10'
3131

3232
# -- General configuration ---------------------------------------------------
3333

moban/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.7.9"
1+
__version__ = "0.7.10"
22
__author__ = "C. W."

moban/core/moban_factory.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,42 @@ def render_string_to_file(
156156
self.buffered_writer.close()
157157

158158
def apply_template(self, template_abs_path, template, data, output_file):
159+
160+
# render the content
159161
rendered_content = self.engine.apply_template(
160162
template, data, output_file
161163
)
164+
165+
# convert to utf8 if not already
162166
if not isinstance(rendered_content, bytes):
163167
rendered_content = rendered_content.encode("utf-8")
164168

169+
# attempt to output to the file and printing to stdout instead
170+
# if not found
165171
try:
172+
173+
# check if any of the files have changed
166174
flag = HASH_STORE.is_file_changed(
167175
output_file, rendered_content, template_abs_path
168176
)
177+
178+
# if they have re-render things
169179
if flag:
180+
181+
# write the content to the output file
170182
self.buffered_writer.write_file_out(
171183
output_file, rendered_content
172184
)
173-
if not file_system.is_zip_alike_url(output_file):
185+
186+
# attempt to copy the file permissions of the template
187+
# file to the output file
188+
189+
# if it isn't an archive proceed or stdout
190+
if (
191+
not file_system.is_zip_alike_url(output_file)
192+
and output_file != "-"
193+
):
194+
174195
try:
175196
file_system.file_permissions_copy(
176197
template_abs_path, output_file

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
NAME = "moban"
4343
AUTHOR = "C. W."
44-
VERSION = "0.7.9"
44+
VERSION = "0.7.10"
4545
4646
LICENSE = "MIT"
4747
ENTRY_POINTS = {
@@ -53,7 +53,7 @@
5353
"General purpose static text generator"
5454
)
5555
URL = "https://github.com/moremoban/moban"
56-
DOWNLOAD_URL = "%s/archive/0.7.9.tar.gz" % URL
56+
DOWNLOAD_URL = "%s/archive/0.7.10.tar.gz" % URL
5757
FILES = ["README.rst", "CONTRIBUTORS.rst", "CHANGELOG.rst"]
5858
KEYWORDS = [
5959
"python",
@@ -96,8 +96,8 @@
9696
}
9797
# You do not need to read beyond this line
9898
PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable)
99-
GS_COMMAND = ("gs moban v0.7.9 " +
100-
"Find 0.7.9 in changelog for more details")
99+
GS_COMMAND = ("gs moban v0.7.10 " +
100+
"Find 0.7.10 in changelog for more details")
101101
NO_GS_MESSAGE = ("Automatic github release is disabled. " +
102102
"Please install gease to enable it.")
103103
UPLOAD_FAILED_MSG = (

tests/integration_tests/test_command_line_options.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,3 +572,19 @@ def test_stdout():
572572

573573
main()
574574
eq_(fake_stdout.getvalue(), "world\n")
575+
576+
577+
def test_render_file_stdout():
578+
config_file = "config.yaml"
579+
with open(config_file, "w") as f:
580+
f.write("hello: world")
581+
template_file = "t.jj2"
582+
with open(template_file, "w") as f:
583+
f.write("{{hello}}")
584+
test_args = ["moban", "-t", "t.jj2", "-c", "config.yaml"]
585+
with patch.object(sys, "argv", test_args):
586+
with patch("sys.stdout", new_callable=StringIO) as fake_stdout:
587+
from moban.main import main
588+
589+
main()
590+
eq_(fake_stdout.getvalue(), "world\n")

0 commit comments

Comments
 (0)