Skip to content

Commit

Permalink
Merge pull request #395 from moremoban/dev
Browse files Browse the repository at this point in the history
release 0.7.10
  • Loading branch information
chfw authored Aug 15, 2020
2 parents 141d3be + 36ee1af commit 897cce9
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 30 deletions.
8 changes: 7 additions & 1 deletion .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ releases:
- changes:
- action: Updated
details:
- "`#390`: single render action will print to stdout by defafult"
- "`#393`: Rendered content output to stdout once"
date: 16.08.2020
version: 0.7.10
- changes:
- action: Updated
details:
- "`#390`: single render action will print to stdout by default"
date: 06.08.2020
version: 0.7.9
- changes:
Expand Down
6 changes: 3 additions & 3 deletions .moban.cd/moban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ organisation: moremoban
author: C. W.
contact: wangc_2011@hotmail.com
license: MIT
version: 0.7.9
current_version: 0.7.9
release: 0.7.9
version: 0.7.10
current_version: 0.7.10
release: 0.7.10
branch: master
master: index
command_line_interface: "moban"
Expand Down
5 changes: 1 addition & 4 deletions .moban.d/moban_readme.jj2
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ A bit formal example:

.. code-block:: bash

$ moban -c data.yml -t my.template
$ moban -c data.yml -t my.template
world

Given data.yml as:
Expand Down Expand Up @@ -222,9 +222,6 @@ You can start using it like this:
.. code-block:: bash

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


TOML data format
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
Change log
================================================================================

0.7.10 - 16.08.2020
--------------------------------------------------------------------------------

**Updated**

#. `#393 <https://github.com/moremoban/moban/issues/393>`_: Rendered content
output to stdout once

0.7.9 - 06.08.2020
--------------------------------------------------------------------------------

**Updated**

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

0.7.8 - 09.06.2020
--------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ In alphabetical order:
* `John Vandenberg <https://github.com/jayvdb>`_
* `Joshua Chung <https://github.com/seeeturtle>`_
* `PRAJWAL M <https://github.com/PrajwalM2212>`_
* `salotz <https://github.com/salotz>`_
* `SerekKiri <https://github.com/SerekKiri>`_
14 changes: 1 addition & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ A bit formal example:

.. code-block:: bash
$ moban -c data.yml -t my.template
$ moban -c data.yml -t my.template
world
Given data.yml as:
Expand Down Expand Up @@ -216,9 +216,6 @@ Given a data.json file with the following content
$ moban --template-type handlebars -c data.json "{{person.firstname}} {{person.lastname}}"
Handlebars-ing <p>{{first... to moban.output
Handlebarsed 1 file.
$ cat moban.output
Yehuda Katz
For `handlebars.js` users, yes, the example was copied from handlebarjs.com. The
Expand Down Expand Up @@ -314,9 +311,6 @@ And given the following velocity.template:
.. code-block:: bash
$ moban --template-type velocity -c data.json -t velocity.template
Velocity-templating vo.t to moban.output
Velocity-templated 1 file.
$ cat moban.output
Old people:
Bill
Expand Down Expand Up @@ -355,9 +349,6 @@ You can start using it like this:
.. code-block:: bash
$ moban --template-type de-duplicate -pd custom-plugin -t duplicated_content.txt
De-duplicating duplicated_content.txt to moban.output
De-duplicating 1 file.
Everything is up to date!
TOML data format
Expand All @@ -380,9 +371,6 @@ You can do:
.. code-block:: bash
$ moban -c sample.toml "{{owner.name}} made {{title}}"
Templating {{owner.na... to moban.output
Templated 1 file.
$ cat moban.output
Tom Preston-Werner made TOML Example
Not limited to toml, you can supply moban with the following data formats:
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
copyright = '2017-2020 Onni Software Ltd.'
author = 'C. W.'
# The short X.Y version
version = '0.7.9'
version = '0.7.10'
# The full version, including alpha/beta/rc tags
release = '0.7.9'
release = '0.7.10'

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion moban/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.7.9"
__version__ = "0.7.10"
__author__ = "C. W."
23 changes: 22 additions & 1 deletion moban/core/moban_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,42 @@ def render_string_to_file(
self.buffered_writer.close()

def apply_template(self, template_abs_path, template, data, output_file):

# render the content
rendered_content = self.engine.apply_template(
template, data, output_file
)

# convert to utf8 if not already
if not isinstance(rendered_content, bytes):
rendered_content = rendered_content.encode("utf-8")

# attempt to output to the file and printing to stdout instead
# if not found
try:

# check if any of the files have changed
flag = HASH_STORE.is_file_changed(
output_file, rendered_content, template_abs_path
)

# if they have re-render things
if flag:

# write the content to the output file
self.buffered_writer.write_file_out(
output_file, rendered_content
)
if not file_system.is_zip_alike_url(output_file):

# attempt to copy the file permissions of the template
# file to the output file

# if it isn't an archive proceed or stdout
if (
not file_system.is_zip_alike_url(output_file)
and output_file != "-"
):

try:
file_system.file_permissions_copy(
template_abs_path, output_file
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

NAME = "moban"
AUTHOR = "C. W."
VERSION = "0.7.9"
VERSION = "0.7.10"
EMAIL = "wangc_2011@hotmail.com"
LICENSE = "MIT"
ENTRY_POINTS = {
Expand All @@ -53,7 +53,7 @@
"General purpose static text generator"
)
URL = "https://github.com/moremoban/moban"
DOWNLOAD_URL = "%s/archive/0.7.9.tar.gz" % URL
DOWNLOAD_URL = "%s/archive/0.7.10.tar.gz" % URL
FILES = ["README.rst", "CONTRIBUTORS.rst", "CHANGELOG.rst"]
KEYWORDS = [
"python",
Expand Down Expand Up @@ -96,8 +96,8 @@
}
# You do not need to read beyond this line
PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable)
GS_COMMAND = ("gs moban v0.7.9 " +
"Find 0.7.9 in changelog for more details")
GS_COMMAND = ("gs moban v0.7.10 " +
"Find 0.7.10 in changelog for more details")
NO_GS_MESSAGE = ("Automatic github release is disabled. " +
"Please install gease to enable it.")
UPLOAD_FAILED_MSG = (
Expand Down
16 changes: 16 additions & 0 deletions tests/integration_tests/test_command_line_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,3 +572,19 @@ def test_stdout():

main()
eq_(fake_stdout.getvalue(), "world\n")


def test_render_file_stdout():
config_file = "config.yaml"
with open(config_file, "w") as f:
f.write("hello: world")
template_file = "t.jj2"
with open(template_file, "w") as f:
f.write("{{hello}}")
test_args = ["moban", "-t", "t.jj2", "-c", "config.yaml"]
with patch.object(sys, "argv", test_args):
with patch("sys.stdout", new_callable=StringIO) as fake_stdout:
from moban.main import main

main()
eq_(fake_stdout.getvalue(), "world\n")

0 comments on commit 897cce9

Please sign in to comment.