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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ cscope.in.out
cscope.po.out


docs/level-1-jinja2-cli/testout
docs/level-10-moban-dependency-as-git-repo/mytravis.yml
docs/level-18-user-defined-template-types/b.output
docs/level-9-moban-dependency-as-pypi-package/mytravis.yml
docs/misc-1-copying-templates/misc-1-copying/
docs/misc-1-copying-templates/test-dir/
Expand Down
3 changes: 2 additions & 1 deletion .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ releases:
- action: Added
details:
- "`#234`: Define template parameters on the fly inside `targets` section"
date: 01.03.2019
- "`#180`: No longer two statistics will be shown in v0.4.x. legacy copy targets are injected into a normal targets. cli target is made a clear priority."
date: unreleased
version: 0.4.2
- changes:
- action: Added
Expand Down
3 changes: 3 additions & 0 deletions .moban.d/moban_gitignore.jj2
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{% extends "gitignore.jj2" %}

{% block extra %}
docs/level-1-jinja2-cli/testout
docs/level-10-moban-dependency-as-git-repo/mytravis.yml
docs/level-18-user-defined-template-types/b.output
docs/level-9-moban-dependency-as-pypi-package/mytravis.yml
docs/misc-1-copying-templates/misc-1-copying/
docs/misc-1-copying-templates/test-dir/
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
Change log
================================================================================

0.4.2 - 01.03.2019
0.4.2 - unreleased
--------------------------------------------------------------------------------

Added
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `#234 <https://github.com/moremoban/moban/issues/234>`_: Define template
parameters on the fly inside `targets` section
#. `#180 <https://github.com/moremoban/moban/issues/180>`_: No longer two
statistics will be shown in v0.4.x. legacy copy targets are injected into a
normal targets. cli target is made a clear priority.

0.4.1 - 28.02.2019
--------------------------------------------------------------------------------
Expand Down
46 changes: 20 additions & 26 deletions moban/mobanfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ def find_default_moban_file():
def handle_moban_file_v1(moban_file_configurations, command_line_options):
merged_options = None

targets = moban_file_configurations.get(constants.LABEL_TARGETS)
target = extract_target(command_line_options)
targets = moban_file_configurations.get(constants.LABEL_TARGETS, [])
if constants.LABEL_COPY in moban_file_configurations:
legacy_copy_targets = handle_copy(
merged_options, moban_file_configurations[constants.LABEL_COPY]
)
targets += legacy_copy_targets

cli_target = extract_target(command_line_options)

if constants.LABEL_CONFIG in moban_file_configurations:
merged_options = merge(
Expand Down Expand Up @@ -68,27 +74,16 @@ def handle_moban_file_v1(moban_file_configurations, command_line_options):
if template_types:
plugins.ENGINES.register_options(template_types)

if targets:
if target:
targets = target
# If template specified via CLI flag `-t:
# 1. Only update the specified template
# 2. Do not copy
if constants.LABEL_COPY in moban_file_configurations:
del moban_file_configurations[constants.LABEL_COPY]
number_of_templated_files = handle_targets(merged_options, targets)
if cli_target:
number_of_templated_files = handle_targets(
merged_options, [cli_target])
elif targets:
number_of_templated_files = handle_targets(
merged_options, targets)
else:
number_of_templated_files = 0

if constants.LABEL_COPY in moban_file_configurations:
number_of_copied_files = handle_copy(
merged_options, moban_file_configurations[constants.LABEL_COPY]
)
else:
number_of_copied_files = 0
exit_code = reporter.convert_to_shell_exit_code(
number_of_templated_files + number_of_copied_files
)
exit_code = reporter.convert_to_shell_exit_code(number_of_templated_files)
reporter.report_up_to_date()
return exit_code

Expand All @@ -100,12 +95,11 @@ def handle_copy(merged_options, copy_config):
copy_targets.append(
{
constants.LABEL_TEMPLATE: src,
constants.LABEL_CONFIG: None,
constants.LABEL_OUTPUT: dest,
constants.LABEL_TEMPLATE_TYPE: constants.TEMPLATE_COPY,
}
)
return handle_targets(merged_options, copy_targets)
return copy_targets


def _iterate_list_of_dicts(list_of_dict):
Expand Down Expand Up @@ -134,6 +128,7 @@ def handle_targets(merged_options, targets):
target.set_template_type(primary_template_type)

jobs_for_each_engine[primary_template_type].append(target)
print(target)

count = 0
for template_type in jobs_for_each_engine.keys():
Expand Down Expand Up @@ -172,15 +167,14 @@ def extract_target(options):
"Please specify a output file name for %s." % template
)
if config:
result = [
{
result = {
constants.LABEL_TEMPLATE: template,
constants.LABEL_CONFIG: config,
constants.LABEL_OUTPUT: output,
}
]

else:
result = [{output: template}]
result = {output: template}
return result


Expand Down