From 713f3d751a210c91ad1d88f7a11dcde12eb266a3 Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 9 Mar 2019 18:41:31 +0000 Subject: [PATCH 1/4] :sparkles: respect appearance sequence --- moban/mobanfile/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/moban/mobanfile/__init__.py b/moban/mobanfile/__init__.py index e788eaf9..dd3a33a7 100644 --- a/moban/mobanfile/__init__.py +++ b/moban/mobanfile/__init__.py @@ -1,7 +1,7 @@ import os import re import sys -from collections import defaultdict +from collections import OrderedDict from lml.utils import do_import @@ -112,7 +112,7 @@ def _iterate_list_of_dicts(list_of_dict): def handle_targets(merged_options, targets): list_of_templating_parameters = parse_targets(merged_options, targets) - jobs_for_each_engine = defaultdict(list) + jobs_for_each_engine = OrderedDict() for target in list_of_templating_parameters: forced_template_type = merged_options.get( @@ -129,6 +129,9 @@ def handle_targets(merged_options, targets): ] target.set_template_type(primary_template_type) + if primary_template_type not in jobs_for_each_engine: + jobs_for_each_engine[primary_template_type] = [] + jobs_for_each_engine[primary_template_type].append(target) count = 0 From 4e1c8ba49a86e39f01597452d625c265ed34a4d1 Mon Sep 17 00:00:00 2001 From: chfw Date: Mon, 11 Mar 2019 07:53:13 +0000 Subject: [PATCH 2/4] :microscope: test the sequence --- tests/mobanfile/test_mobanfile.py | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/mobanfile/test_mobanfile.py b/tests/mobanfile/test_mobanfile.py index 0786108d..d30f79d1 100644 --- a/tests/mobanfile/test_mobanfile.py +++ b/tests/mobanfile/test_mobanfile.py @@ -143,3 +143,45 @@ def test_handle_targets(fake_renderer): ) ], ) + + +@patch("moban.plugins.template.MobanEngine.render_to_files") +def test_handle_targets_sequence(fake_renderer): + from moban.mobanfile import handle_targets + + TEMPLATE1 = "a.template.jj2" + OUTPUT1 = "filterme.handlebars" # in the future, this could dynamic output + OUTPUT2 = "filtered_output.txt" + CONFIGURATION = "child.yaml" + TEMPLATE_DIRS = [os.path.join("tests", "fixtures", "mobanfile")] + DEFAULT_TEMPLATE_TYPE = "jinja2" + + options = dict( + configuration=CONFIGURATION, + template_type=DEFAULT_TEMPLATE_TYPE, + template_dir=TEMPLATE_DIRS, + configuration_dir=os.path.join("tests", "fixtures"), + ) + short_hand_targets = [{OUTPUT1: TEMPLATE1}, {OUTPUT2: OUTPUT1}] + handle_targets(options, short_hand_targets) + + call_args = list(fake_renderer.call_args_list) + + eq_( + call_args[0][0][0][0], + TemplateTarget( + "a.template.jj2", + "child.yaml", + "filterme.handlebars", + template_type="jj2", + ), + ) + eq_( + call_args[1][0][0][0], + TemplateTarget( + "filterme.handlebars", + "child.yaml", + "filtered_output.txt", + template_type="handlebars", + ), + ) From 55947c71437df8120a7832057e6324621924a385 Mon Sep 17 00:00:00 2001 From: chfw Date: Mon, 11 Mar 2019 08:31:17 +0000 Subject: [PATCH 3/4] :newspaper: add missing file --- tests/fixtures/mobanfile/a.template.jj2 | 0 tests/fixtures/mobanfile/filterme.handlebars | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/fixtures/mobanfile/a.template.jj2 create mode 100644 tests/fixtures/mobanfile/filterme.handlebars diff --git a/tests/fixtures/mobanfile/a.template.jj2 b/tests/fixtures/mobanfile/a.template.jj2 new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/mobanfile/filterme.handlebars b/tests/fixtures/mobanfile/filterme.handlebars new file mode 100644 index 00000000..e69de29b From f9c09fb4526a7d4e5854e41306c33c406afa23dc Mon Sep 17 00:00:00 2001 From: chfw Date: Mon, 11 Mar 2019 08:33:45 +0000 Subject: [PATCH 4/4] :books: update change log. #261 --- .moban.cd/changelog.yml | 1 + CHANGELOG.rst | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index 9c726859..b05c6e39 100644 --- a/.moban.cd/changelog.yml +++ b/.moban.cd/changelog.yml @@ -6,6 +6,7 @@ releases: details: - "`#253`: symbolic link in regression pack causes python setup.py to do recursive include" - "`#209`: Alert moban user when `git` is not available and is used." + - "`#261`: since moban group template files per template type, this fill use first come first register to order moban group" date: unreleased version: 0.4.3 - changes: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 58502302..ead5bd11 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,6 +11,9 @@ Removed regression pack causes python setup.py to do recursive include #. `#209 `_: Alert moban user when `git` is not available and is used. +#. `#261 `_: since moban group + template files per template type, this fill use first come first register to + order moban group 0.4.2 - 08.03.2019 --------------------------------------------------------------------------------