Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: moban
organisation: moremoban
releases:
- changes:
- action: Updated
details:
- "`#390`: single render action will print to stdout by defafult"
date: 06.08.2020
version: 0.7.9
- changes:
- action: Added
details:
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.8
current_version: 0.7.8
release: 0.7.8
version: 0.7.9
current_version: 0.7.9
release: 0.7.9
branch: master
master: index
command_line_interface: "moban"
Expand Down
19 changes: 8 additions & 11 deletions .moban.d/moban_readme.jj2
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,11 @@ versions lower than 0.7.0 if you are still using python 2.
Quick start
================================================================================

.. image:: https://github.com/moremoban/moban/raw/dev/docs/images/moban-in-intro.gif

{% raw %}
.. code-block:: bash

$ export HELLO="world"
$ moban "{{HELLO}}"
Templating {{HELLO}}... to moban.output
Templated 1 file.
$ cat moban.output
world

Or
Expand All @@ -76,7 +71,7 @@ A bit formal example:
.. code-block:: bash

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

Given data.yml as:

Expand All @@ -94,11 +89,6 @@ and my.template as:

{% endraw %}

moban.output will contain:

.. code-block:: bash

world

Please note that data.yml will take precedence over environment variables.

Expand Down Expand Up @@ -182,6 +172,13 @@ Assume that the custom example was saved in `custom-jj2-plugin`

Moban will then load your custom jinja2 functions

Slim template syntax for jinja2
---------------------------------

with `moban-slim <https://github.com/moremoban/moban-slim>`_ installed,

{% include "slim_example.rst.jj2" %}

Handlebars.js template
----------------------------

Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Change log
================================================================================

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

**Updated**

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

0.7.8 - 09.06.2020
--------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lint:
yamllint -d "{extends: default, ignore: .moban.cd/changelog.yml}" .

format:
isort -y $(find moban -name "*.py"|xargs echo) $(find tests -name "*.py"|xargs echo)
isort $(find moban -name "*.py"|xargs echo) $(find tests -name "*.py"|xargs echo)
git diff
black -l 79 moban
git diff
Expand Down
37 changes: 26 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,11 @@ versions lower than 0.7.0 if you are still using python 2.
Quick start
================================================================================

.. image:: https://github.com/moremoban/moban/raw/dev/docs/images/moban-in-intro.gif


.. code-block:: bash

$ export HELLO="world"
$ moban "{{HELLO}}"
Templating {{HELLO}}... to moban.output
Templated 1 file.
$ cat moban.output
world

Or
Expand All @@ -75,7 +70,7 @@ A bit formal example:
.. code-block:: bash

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

Given data.yml as:

Expand All @@ -92,11 +87,6 @@ and my.template as:
{{hello}}


moban.output will contain:

.. code-block:: bash

world

Please note that data.yml will take precedence over environment variables.

Expand Down Expand Up @@ -179,6 +169,31 @@ Assume that the custom example was saved in `custom-jj2-plugin`

Moban will then load your custom jinja2 functions

Slim template syntax for jinja2
---------------------------------

with `moban-slim <https://github.com/moremoban/moban-slim>`_ installed,

Given a data.json file with the following content

.. code-block::

{
"person": {
"firstname": "Smith",
"lastname": "Jones",
},
}

.. code-block:: bash


$ moban --template-type slim -c data.json "{{person.firstname}} {{person.lastname}}"
Slimming <p>{{first... to moban.output
Slimmed 1 file.
$ cat moban.output
Smith Jones

Handlebars.js template
----------------------------

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.8'
version = '0.7.9'
# The full version, including alpha/beta/rc tags
release = '0.7.8'
release = '0.7.9'

# -- 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.8"
__version__ = "0.7.9"
__author__ = "C. W."
2 changes: 1 addition & 1 deletion moban/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
file_system.path_join(".", DEFAULT_TEMPLATE_DIRNAME),
],
# moban.output, default output file name
LABEL_OUTPUT: "%s.output" % PROGRAM_NAME,
LABEL_OUTPUT: "-",
# data.yml, default data input file
LABEL_CONFIG: "data%s" % DEFAULT_YAML_SUFFIX,
LABEL_TEMPLATE_TYPE: DEFAULT_TEMPLATE_TYPE,
Expand Down
4 changes: 3 additions & 1 deletion moban/externals/buffered_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ def __init__(self):
self.fs_list = {}

def write_file_out(self, filename, content):
if file_system.is_zip_alike_url(filename):
if filename == "-":
print(content.decode())
elif file_system.is_zip_alike_url(filename):
self.write_file_out_to_zip(filename, content)
else:
write_file_out(filename, content)
Expand Down
17 changes: 14 additions & 3 deletions moban/externals/reporter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

import crayons

import moban.constants as constants
Expand All @@ -13,6 +15,8 @@
MESSAGE_FILE_EXTENSION_NOT_NEEDED = "File extension is not required for ad-hoc\
type"

GLOBAL = {"PRINT": True}


def report_templating(
action_in_present_continuous_tense, source_file, destination_file
Expand Down Expand Up @@ -49,11 +53,13 @@ def report_partial_run(action_in_past_tense, file_count, total):


def report_error_message(message):
do_print(crayons.white("Error: ", bold=True) + crayons.red(message))
error_print(crayons.white("Error: ", bold=True) + crayons.red(message))


def report_warning_message(message):
do_print(crayons.white("Warning: ", bold=True) + crayons.yellow(message))
error_print(
crayons.white("Warning: ", bold=True) + crayons.yellow(message)
)


def report_info_message(message):
Expand Down Expand Up @@ -98,4 +104,9 @@ def report_file_extension_not_needed():


def do_print(message):
print(message)
if GLOBAL["PRINT"]:
print(message)


def error_print(message):
sys.stderr.write(message + "\n")
1 change: 1 addition & 0 deletions moban/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def handle_command_line(options):
"""
act upon command options
"""
reporter.GLOBAL["PRINT"] = False
options = data_loader.merge(options, constants.DEFAULT_OPTIONS)
engine = ENGINES.get_engine(
options[constants.LABEL_TEMPLATE_TYPE],
Expand Down
1 change: 1 addition & 0 deletions mobanfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ configuration:
- "git://github.com/moremoban/moban-anyconfig.git?branch=master!/.moban.d/"
- "git://github.com/moremoban/moban-handlebars.git?branch=dev!/.moban.d/"
- "git://github.com/moremoban/moban-velocity.git?branch=dev!/.moban.d/"
- "git://github.com/moremoban/moban-slim.git?branch=dev!/.moban.d/"
- "git://github.com/moremoban/httpfs.git?branch=master!/.moban.d/"
- "git://github.com/moremoban/gitfs2.git?branch=dev!/.moban.d/"
- "git://github.com/moremoban/pypifs.git?branch=master!/.moban.d/"
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.8"
VERSION = "0.7.9"
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.8.tar.gz" % URL
DOWNLOAD_URL = "%s/archive/0.7.9.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.8 " +
"Find 0.7.8 in changelog for more details")
GS_COMMAND = ("gs moban v0.7.9 " +
"Find 0.7.9 in changelog for more details")
NO_GS_MESSAGE = ("Automatic github release is disabled. " +
"Please install gease to enable it.")
UPLOAD_FAILED_MSG = (
Expand Down
Loading