From 27e36bda32ff65baa5b3228630975c667ebe908c Mon Sep 17 00:00:00 2001 From: chfw Date: Fri, 11 Oct 2019 20:26:54 +0100 Subject: [PATCH 01/14] :sparkles: prototype to support intermediate targets. step 1 for #335 --- moban/core/mobanfile/__init__.py | 4 +++- moban/core/mobanfile/store.py | 11 +++++++++++ moban/core/mobanfile/targets.py | 9 +++++---- 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 moban/core/mobanfile/store.py diff --git a/moban/core/mobanfile/__init__.py b/moban/core/mobanfile/__init__.py index ffb2e641..34d3f921 100644 --- a/moban/core/mobanfile/__init__.py +++ b/moban/core/mobanfile/__init__.py @@ -17,6 +17,7 @@ extract_target, extract_group_targets, ) +from .store import STORE LOG = logging.getLogger(__name__) @@ -89,7 +90,8 @@ def handle_moban_file_v1(moban_file_configurations, command_line_options): def handle_targets(merged_options, targets): LOG.info("handling targets") - list_of_templating_parameters = parse_targets(merged_options, targets) + parse_targets(merged_options, targets) + list_of_templating_parameters = STORE.targets jobs_for_each_engine = OrderedDict() for target in list_of_templating_parameters: diff --git a/moban/core/mobanfile/store.py b/moban/core/mobanfile/store.py new file mode 100644 index 00000000..0e880788 --- /dev/null +++ b/moban/core/mobanfile/store.py @@ -0,0 +1,11 @@ +class Store: + def __init__(self): + self.targets = [] + self.look_up_by_output = {} + + def add(self, target): + self.targets.append(target) + self.look_up_by_output[target.output] = target + + +STORE = Store() diff --git a/moban/core/mobanfile/targets.py b/moban/core/mobanfile/targets.py index 492399fa..f4c7ca29 100644 --- a/moban/core/mobanfile/targets.py +++ b/moban/core/mobanfile/targets.py @@ -4,7 +4,8 @@ from moban import core, constants, exceptions from moban.externals import reporter from moban.core.definitions import TemplateTarget -from moban.core.mobanfile.templates import handle_template +from .store import STORE +from .templates import handle_template LOG = logging.getLogger(__name__) @@ -50,7 +51,7 @@ def parse_targets(options, targets): for target in targets: if constants.LABEL_OUTPUT in target: for template_target in _handle_explicit_target(options, target): - yield template_target + STORE.add(template_target) else: for output, template_file in target.items(): if isinstance(template_file, str) is False: @@ -60,12 +61,12 @@ def parse_targets(options, targets): for template_target in _handle_group_target( options, a_list_short_hand_targets, group_template_type ): - yield template_target + STORE.add(template_target) else: for template_target in _handle_implicit_target( options, template_file, output ): - yield template_target + STORE.add(template_target) def _handle_explicit_target(options, target): From ee1f1e84fff193f8459a59c6a51a7e69ee040ce5 Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 09:10:14 +0100 Subject: [PATCH 02/14] :sparkles: synchronize with pypi-mobans --- CHANGELOG.rst | 171 +++++++++++++++++--------------------------------- docs/conf.py | 5 +- setup.py | 2 +- 3 files changed, 60 insertions(+), 118 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 972070f8..2850c583 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,8 +4,7 @@ Change log 0.6.4 - 4.10.2019 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. Command options have been grouped. --template_type became --template-type #. Increment gitfs2 to version 0.0.2. `gitfs#4 @@ -14,8 +13,7 @@ Updated 0.6.3 - 25.09.2019 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#260 `_: jinja-cli parity: support command line pipe stream. @@ -23,8 +21,7 @@ Added 0.6.2 - 15.09.2019 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#322 `_: Implicit targets with template extensions default to copy @@ -36,8 +33,7 @@ Added 0.6.1 - 10.09.2019 -------------------------------------------------------------------------------- -Fixed -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Fixed** #. `#328 `_: update backward compatibility @@ -45,8 +41,7 @@ Fixed 0.6.0 - 10.09.2019 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#205 `_: support `pyFilesystem2 `_ @@ -58,8 +53,7 @@ Added #. `#256 `_: jinja2-cli parity: '-d hello=world' to define custom variable on cli -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#275 `_: fix moban 0.4.5 test failures on openSUSE Tumbleweed @@ -67,8 +61,7 @@ Updated 0.5.0 - 14.07.2019 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#277 `_: Restored dependency git-url-parse, replacing incompatible giturlparse which was used during moban @@ -94,8 +87,7 @@ Updated 0.4.5 - 07.07.2019 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#271 `_: support git branch change in later run. @@ -103,8 +95,7 @@ Updated 0.4.4 - 26.05.2019 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#265 `_: Use simple `read binary` to read instead of encoding @@ -112,20 +103,17 @@ Updated 0.4.3 - 16.03.2019 -------------------------------------------------------------------------------- -Removed -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Removed** #. `#253 `_: symbolic link in regression pack causes python setup.py to do recursive include -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#209 `_: Alert moban user when `git` is not available and is used. -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#261 `_: since moban group template files per template type, this fill use first come first register to @@ -134,16 +122,14 @@ Updated 0.4.2 - 08.03.2019 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#234 `_: Define template parameters on the fly inside `targets` section #. `#62 `_: select a group target to run -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#180 `_: No longer two statistics will be shown in v0.4.x. legacy copy targets are injected into a @@ -158,8 +144,7 @@ Updated 0.4.1 - 28.02.2019 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#235 `_: user defined template types so that custom file extensions, template configurations can be @@ -171,13 +156,11 @@ Added 0.4.0 - 20.02.2019 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#165 `_: Copy as plugins -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#219 `_: git clone depth set to 2 @@ -187,8 +170,7 @@ Updated 0.3.10 - 03.02.2019 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#174 `_: Store git cache in XDG_CACHE_DIR @@ -197,8 +179,7 @@ Added #. `#164 `_: support additional data formats -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#178 `_: UnboundLocalError: local variable 'target' referenced before assignment @@ -208,8 +189,7 @@ Updated 0.3.9 - 18-1-2019 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#90 `_: allow adding extra jinja2 extensions. `jinja2.ext.do`, `jinja2.ext.loopcontrols` are included by @@ -221,8 +201,7 @@ Updated 0.3.8 - 12-1-2019 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#141 `_: disable file permissions copy feature and not to check file permission changes on windows. @@ -235,8 +214,7 @@ Updated 0.3.7 - 6-1-2019 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#146 `_: added a low-setup usage mode via environment variables to moban @@ -247,8 +225,7 @@ Updated 0.3.6 - 30-12-2018 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#143 `_: moban shall report permission error and continue the rest of the copying task. @@ -259,8 +236,7 @@ Updated 0.3.5 - 10-12-2018 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#37 `_: moban will report line number where the value is empty and the name of mobanfile. Switch from pyyaml @@ -269,8 +245,7 @@ Updated 0.3.4.1 - 28-11-2018 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#137 `_: missing contributors.rst file @@ -278,23 +253,20 @@ Updated 0.3.4 - 18-11-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. global variables to store the target and template file names in the jinja2 engine #. moban-handlebars is tested to work well with this version and above -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. Template engine interface has been clarified and documented 0.3.3 - 05-11-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. alternative and expanded syntax for requires, so as to accomendate github submodule recursive @@ -302,8 +274,7 @@ Added 0.3.2 - 04-11-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. configuration dirs may be located by `requires`, i.e. configuration files may be in a python package or git repository. @@ -311,8 +282,7 @@ Added 0.3.1 - 02-11-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#97 `_: requires will clone a repo if given. Note: only github, gitlab, bitbucket for now @@ -320,21 +290,18 @@ Added 0.3.0 - 27-18-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#89 `_: Install pypi-hosted mobans through requires syntax -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#96 `_: Fix for FileNotFoundError for plugins #. various documentation updates -Removed -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Removed** #. `#88 `_: removed python 2.6 support @@ -343,8 +310,7 @@ Removed 0.2.4 - 14-07-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#32 `_: option 1 copy a directory without its subdirectories. @@ -354,8 +320,7 @@ Added 0.2.3 - 10-07-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#76 `_: running moban as a module from python command @@ -367,14 +332,12 @@ Added 0.2.2 - 16-06-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#31 `_: create directory if missing during copying -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#28 `_: if a template has been copied once before, it is skipped in the next moban call @@ -382,8 +345,7 @@ Updated 0.2.1 - 13-06-2018 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. templates using the same template engine will be templated as a group #. update lml dependency to 0.0.3 @@ -391,8 +353,7 @@ Updated 0.2.0 - 11-06-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#18 `_: file exists test #. `#23 `_: custom jinja plugins @@ -402,8 +363,7 @@ Added #. `#58 `_: allow template type per template -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#34 `_: fix plural message if single file is processed @@ -411,8 +371,7 @@ Updated 0.1.4 - 29-May-2018 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#21 `_: targets become optional @@ -424,16 +383,14 @@ Updated 0.1.3 - 12-Mar-2018 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. handle unicode on python 2 0.1.2 - 10-Jan-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#13 `_: strip off new lines in the templated file @@ -441,8 +398,7 @@ Added 0.1.1 - 08-Jan-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. the ability to present a long text as multi-line paragraph with a custom upper limit @@ -453,8 +409,7 @@ Added 0.1.0 - 19-Dec-2017 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#14 `_, provide shell exit code @@ -462,8 +417,7 @@ Added 0.0.9 - 24-Nov-2017 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#11 `_, recognize .moban.yaml as well as .moban.yml. @@ -472,8 +426,7 @@ Added #. `-m` option is added to allow you to specify a custom moban file. kinda related to issue 11. -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. use explicit version name: `moban_file_spec_version` so that `version` can be used by users. `#10 `_ Please @@ -485,23 +438,20 @@ Updated 0.0.8 - 18-Nov-2017 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#8 `_, verify the existence of custom template and configuration directories. default .moban.td, .moban.cd are ignored if they do not exist. -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. Colorize error messages and processing messages. crayons become a dependency. 0.0.7 - 19-Jul-2017 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. Bring the visibility of environment variable into jinja2 templating process: `#7 `_ @@ -509,13 +459,11 @@ Added 0.0.6 - 16-Jun-2017 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. added '-f' flag to force moban to template all files despite of .moban.hashes -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. moban will not template target file in the situation where the changes occured in target file than in the source: the template file + the data @@ -525,8 +473,7 @@ Updated 0.0.5 - 17-Mar-2017 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. Create a default hash store when processing a moban file. It will save unnecessary file write to the disc if the rendered content is not changed. @@ -535,8 +482,7 @@ Added 0.0.4 - 11-May-2016 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. Bug fix `#5 `_, should detect duplicated targets in `.moban.yml` file. @@ -544,8 +490,7 @@ Updated 0.0.3 - 09-May-2016 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. Bug fix `#4 `_, keep trailing new lines @@ -553,8 +498,7 @@ Updated 0.0.2 - 27-Apr-2016 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. Bug fix `#1 `_, failed to save utf-8 characters @@ -562,7 +506,6 @@ Updated 0.0.1 - 23-Mar-2016 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. Initial release diff --git a/docs/conf.py b/docs/conf.py index 8468720d..7c7630d0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -7,7 +7,7 @@ # # This file only contains a selection of the most common options. For a full # list see the documentation: -# http://www.sphinx-doc.org/en/master/config +# https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- @@ -68,8 +68,7 @@ # -- Options for intersphinx extension --------------------------------------- # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/': None} - +intersphinx_mapping = {'https://docs.python.org/3/': None} # TODO: html_theme not configurable upstream html_theme = 'default' diff --git a/setup.py b/setup.py index 95ba5d2d..f2d2c60f 100644 --- a/setup.py +++ b/setup.py @@ -140,7 +140,7 @@ def run(self): self.status(NO_GS_MESSAGE) if run_status: if os.system(PUBLISH_COMMAND) != 0: - self.status(UPLOAD_FAILED_MSG % PUBLISH_COMMAND) + self.status(UPLOAD_FAILED_MSG) sys.exit() From 201da77b1ce40dd9512d2da08404273306efc42c Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 09:31:39 +0100 Subject: [PATCH 03/14] :microscope: :books: test and document intermediate targets] --- .../level-22-intermediate-targets/.moban.yaml | 4 ++ docs/level-22-intermediate-targets/REAME.rst | 19 +++++++++ docs/level-22-intermediate-targets/data.yml | 1 + .../original.jj2 | 1 + moban/core/mobanfile/templates.py | 41 +++++++++++-------- tests/test_docs.py | 8 ++++ 6 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 docs/level-22-intermediate-targets/.moban.yaml create mode 100644 docs/level-22-intermediate-targets/REAME.rst create mode 100644 docs/level-22-intermediate-targets/data.yml create mode 100644 docs/level-22-intermediate-targets/original.jj2 diff --git a/docs/level-22-intermediate-targets/.moban.yaml b/docs/level-22-intermediate-targets/.moban.yaml new file mode 100644 index 00000000..a2000cad --- /dev/null +++ b/docs/level-22-intermediate-targets/.moban.yaml @@ -0,0 +1,4 @@ +targets: + - intermediate.jj2: original.jj2 + - final: intermediate.jj2 + diff --git a/docs/level-22-intermediate-targets/REAME.rst b/docs/level-22-intermediate-targets/REAME.rst new file mode 100644 index 00000000..e281c7d8 --- /dev/null +++ b/docs/level-22-intermediate-targets/REAME.rst @@ -0,0 +1,19 @@ +Level 22: intermediate targets +================================================================================ + +It is natural to allow intermediate target to be source so that different +moban plugins can interact with each other. The good news is since moban verion +0.6.5, it is support. + + +The bad news is, folder as imtermediate target is not supported yet and will be +considered in next incremental build. For now, the date cannot be confirmed. + +Here the syntax:: + + targets: + - intermediate.jj2: original.jj2 + - final: intermediate.jj2 + +With moban 0.6.4-, above syntax cannot result in `final` file to be generated +because `intermediate.jj2` does not exist until moban is run. diff --git a/docs/level-22-intermediate-targets/data.yml b/docs/level-22-intermediate-targets/data.yml new file mode 100644 index 00000000..bb56b055 --- /dev/null +++ b/docs/level-22-intermediate-targets/data.yml @@ -0,0 +1 @@ +hello: world diff --git a/docs/level-22-intermediate-targets/original.jj2 b/docs/level-22-intermediate-targets/original.jj2 new file mode 100644 index 00000000..8b08a03e --- /dev/null +++ b/docs/level-22-intermediate-targets/original.jj2 @@ -0,0 +1 @@ +a {{hello}} diff --git a/moban/core/mobanfile/templates.py b/moban/core/mobanfile/templates.py index b344ec79..5de94640 100644 --- a/moban/core/mobanfile/templates.py +++ b/moban/core/mobanfile/templates.py @@ -2,6 +2,7 @@ from moban import constants from moban.externals import reporter, file_system +from .store import STORE LOG = logging.getLogger(__name__) @@ -20,29 +21,24 @@ def handle_template(template_file, output, template_dirs): ): yield a_triple else: - reporter.report_error_message( - "{0} cannot be found".format(template_file) - ) + if STORE.look_up_by_output.get(template_file) is None: + reporter.report_error_message( + "{0} cannot be found".format(template_file) + ) else: _, fs = multi_fs.which(template_file) if fs is None: - reporter.report_error_message( - "{0} cannot be found".format(template_file) - ) + if STORE.look_up_by_output.get(template_file) is None: + reporter.report_error_message( + "{0} cannot be found".format(template_file) + ) + else: + yield _create_a_single_target(template_file, output) elif fs.isdir(template_file): for a_triple in _list_dir_files(fs, template_file, output): yield a_triple else: - template_type = _get_template_type(template_file) - # output.jj2: source.jj2 means 'copy' - if template_type and output.endswith("." + template_type): - LOG.info( - "template type switched to from {0} to {1}".format( - template_type, constants.TEMPLATE_COPY - ) - ) - template_type = constants.TEMPLATE_COPY - yield (template_file, output, template_type) + yield _create_a_single_target(template_file, output) def _list_dir_files(fs, source, dest): @@ -72,6 +68,19 @@ def _listing_directory_files_recusively(fs, source, dest): yield a_triple +def _create_a_single_target(template_file, output): + template_type = _get_template_type(template_file) + # output.jj2: source.jj2 means 'copy' + if template_type and output.endswith("." + template_type): + LOG.info( + "template type switched to from {0} to {1}".format( + template_type, constants.TEMPLATE_COPY + ) + ) + template_type = constants.TEMPLATE_COPY + return (template_file, output, template_type) + + def _get_template_type(template_file): _, extension = file_system.path_splitext(template_file) if extension: diff --git a/tests/test_docs.py b/tests/test_docs.py index e3cc36e9..38cd1e95 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -311,6 +311,14 @@ def test_level_19_with_group_target(self): # make sure only copy target is executed eq_(False, os.path.exists("a.output")) + def test_level_22_intermediate_targets(self): + expected = "a world\n" + + folder = "level-22-intermediate-targets" + self.run_moban( + ["moban"], folder, [("final", expected)] + ) + def test_misc_1(self): expected = "test file\n" From 33d8405a861e41ed241bc6a36e6ce03af637eceb Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 09:57:37 +0100 Subject: [PATCH 04/14] :shirt: coding style fix --- tests/test_docs.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_docs.py b/tests/test_docs.py index 38cd1e95..eae9e2cd 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -315,9 +315,7 @@ def test_level_22_intermediate_targets(self): expected = "a world\n" folder = "level-22-intermediate-targets" - self.run_moban( - ["moban"], folder, [("final", expected)] - ) + self.run_moban(["moban"], folder, [("final", expected)]) def test_misc_1(self): expected = "test file\n" From 4d6c0bc197bc67ef5e247d9eda63a3d87897b227 Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 10:00:37 +0100 Subject: [PATCH 05/14] :shirt: fix yaml lint warning --- docs/level-22-intermediate-targets/.moban.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/level-22-intermediate-targets/.moban.yaml b/docs/level-22-intermediate-targets/.moban.yaml index a2000cad..8493915e 100644 --- a/docs/level-22-intermediate-targets/.moban.yaml +++ b/docs/level-22-intermediate-targets/.moban.yaml @@ -1,4 +1,3 @@ targets: - intermediate.jj2: original.jj2 - final: intermediate.jj2 - From a731b5de06f4340c6955efe1df9f1c6798dfed75 Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 14:52:24 +0100 Subject: [PATCH 06/14] :green_heart: fix broken tests --- moban/core/mobanfile/store.py | 7 +++++-- moban/main.py | 1 + tests/mobanfile/test_mobanfile.py | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/moban/core/mobanfile/store.py b/moban/core/mobanfile/store.py index 0e880788..c2d21168 100644 --- a/moban/core/mobanfile/store.py +++ b/moban/core/mobanfile/store.py @@ -1,11 +1,14 @@ class Store: def __init__(self): - self.targets = [] - self.look_up_by_output = {} + self.init() def add(self, target): self.targets.append(target) self.look_up_by_output[target.output] = target + def init(self): + self.targets = [] + self.look_up_by_output = {} + STORE = Store() diff --git a/moban/main.py b/moban/main.py index de2b742c..131975ad 100644 --- a/moban/main.py +++ b/moban/main.py @@ -33,6 +33,7 @@ def main(): handle_verbose(options[constants.LABEL_VERBOSE]) load_engine_factory_and_engines() # Error: jinja2 if removed hashstore.HASH_STORE.IGNORE_CACHE_FILE = options[constants.LABEL_FORCE] + mobanfile.store.STORE.init() options[constants.CLI_DICT] = handle_custom_variables( options.pop(constants.LABEL_DEFINE) ) diff --git a/tests/mobanfile/test_mobanfile.py b/tests/mobanfile/test_mobanfile.py index 5375ad39..905a72df 100644 --- a/tests/mobanfile/test_mobanfile.py +++ b/tests/mobanfile/test_mobanfile.py @@ -41,6 +41,9 @@ def test_handle_targets(fake_renderer): @patch("moban.core.moban_factory.MobanEngine.render_to_files") def test_handle_targets_sequence(fake_renderer): from moban.core.mobanfile import handle_targets + from moban.core.mobanfile.store import STORE + + STORE.init() # required to reset the store TEMPLATE1 = "a.template.jj2" OUTPUT1 = "filterme.handlebars" # in the future, this could dynamic output From d2f18efe1aa9e19998e77dfa48821075ebcab17a Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 16:03:46 +0100 Subject: [PATCH 07/14] :green_heart: make sure store is empty before next parsing session --- moban/core/mobanfile/targets.py | 1 + moban/main.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/moban/core/mobanfile/targets.py b/moban/core/mobanfile/targets.py index f4c7ca29..f0a6a2d8 100644 --- a/moban/core/mobanfile/targets.py +++ b/moban/core/mobanfile/targets.py @@ -48,6 +48,7 @@ def extract_group_targets(group, targets): def parse_targets(options, targets): LOG.info("paring targets..") + STORE.init() for target in targets: if constants.LABEL_OUTPUT in target: for template_target in _handle_explicit_target(options, target): diff --git a/moban/main.py b/moban/main.py index 131975ad..de2b742c 100644 --- a/moban/main.py +++ b/moban/main.py @@ -33,7 +33,6 @@ def main(): handle_verbose(options[constants.LABEL_VERBOSE]) load_engine_factory_and_engines() # Error: jinja2 if removed hashstore.HASH_STORE.IGNORE_CACHE_FILE = options[constants.LABEL_FORCE] - mobanfile.store.STORE.init() options[constants.CLI_DICT] = handle_custom_variables( options.pop(constants.LABEL_DEFINE) ) From e04f1aaf807a3318f45ff3698f067973261e2e94 Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 16:08:09 +0100 Subject: [PATCH 08/14] :hammer: code refactoring --- moban/core/definitions.py | 13 +++++++++++++ moban/core/mobanfile/store.py | 13 +------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/moban/core/definitions.py b/moban/core/definitions.py index e72f3d88..d81fd2e0 100644 --- a/moban/core/definitions.py +++ b/moban/core/definitions.py @@ -46,3 +46,16 @@ def __repr__(self): self.output, self.template_type, ) + + +class Store: + def __init__(self): + self.init() + + def add(self, target): + self.targets.append(target) + self.look_up_by_output[target.output] = target + + def init(self): + self.targets = [] + self.look_up_by_output = {} diff --git a/moban/core/mobanfile/store.py b/moban/core/mobanfile/store.py index c2d21168..eda34174 100644 --- a/moban/core/mobanfile/store.py +++ b/moban/core/mobanfile/store.py @@ -1,14 +1,3 @@ -class Store: - def __init__(self): - self.init() - - def add(self, target): - self.targets.append(target) - self.look_up_by_output[target.output] = target - - def init(self): - self.targets = [] - self.look_up_by_output = {} - +from moban.core.definitions import Store STORE = Store() From 9e69b82e30b61e576b66fabcc1ba8f8f8682cda2 Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 16:10:19 +0100 Subject: [PATCH 09/14] :books: update change log --- .moban.cd/changelog.yml | 6 ++++++ CHANGELOG.rst | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index a0dd2995..02ad0541 100644 --- a/.moban.cd/changelog.yml +++ b/.moban.cd/changelog.yml @@ -1,6 +1,12 @@ name: moban organisation: moremoban releases: + - changes: + - action: Updated + details: + - "`#335`: support intermediate targets in moban file" + date: tbd + version: 0.6.5 - changes: - action: Updated details: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2850c583..75433bda 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,14 @@ Change log ================================================================================ +0.6.5 - tbd +-------------------------------------------------------------------------------- + +**Updated** + +#. `#335 `_: support intermediate + targets in moban file + 0.6.4 - 4.10.2019 -------------------------------------------------------------------------------- From 242ebf68cebbc6ee1f476356c474ded75bf2b804 Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 16:20:05 +0100 Subject: [PATCH 10/14] :microscope: more tests --- .gitignore | 1 + .moban.d/moban_gitignore.jj2 | 1 + tests/test_definitions.py | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 95e2ceaf..ff3b5057 100644 --- a/.gitignore +++ b/.gitignore @@ -532,3 +532,4 @@ docs/level-19-moban-a-sub-group-in-targets/test-dir/ docs/level-19-moban-a-sub-group-in-targets/test-recursive-dir/ docs/level-6-complex-configuration/a.output docs/level-7-use-custom-jinja2-filter-test-n-global/filter.output +docs/level-8-pass-a-folder-full-of-templates/templated-folder diff --git a/.moban.d/moban_gitignore.jj2 b/.moban.d/moban_gitignore.jj2 index 7f19ac2f..b7ab25e9 100644 --- a/.moban.d/moban_gitignore.jj2 +++ b/.moban.d/moban_gitignore.jj2 @@ -27,4 +27,5 @@ docs/level-19-moban-a-sub-group-in-targets/test-dir/ docs/level-19-moban-a-sub-group-in-targets/test-recursive-dir/ docs/level-6-complex-configuration/a.output docs/level-7-use-custom-jinja2-filter-test-n-global/filter.output +docs/level-8-pass-a-folder-full-of-templates/templated-folder {% endblock %} \ No newline at end of file diff --git a/tests/test_definitions.py b/tests/test_definitions.py index a9a6a9d5..16bbdd17 100644 --- a/tests/test_definitions.py +++ b/tests/test_definitions.py @@ -1,7 +1,7 @@ from nose.tools import eq_ from moban.deprecated import GitRequire -from moban.core.definitions import TemplateTarget +from moban.core.definitions import Store, TemplateTarget def test_git_require_repr(): @@ -43,3 +43,10 @@ def test_branch_params(): actual = require.clone_params() expected = {"single_branch": True, "branch": "ghpages", "depth": 2} eq_(expected, actual) + + +def test_store(): + store = Store() + target = TemplateTarget("template_file", "data_file", "output") + store.add(target) + eq_(target, store.look_up_by_output.get("template_file")) From 1f71ccc0ba3d982285eccc948fbde3fbb5e4b68b Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 16:25:54 +0100 Subject: [PATCH 11/14] :green_heart: update unit test --- tests/test_definitions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_definitions.py b/tests/test_definitions.py index 16bbdd17..8992ca38 100644 --- a/tests/test_definitions.py +++ b/tests/test_definitions.py @@ -47,6 +47,7 @@ def test_branch_params(): def test_store(): store = Store() - target = TemplateTarget("template_file", "data_file", "output") + output = "output" + target = TemplateTarget("template_file", "data_file", output) store.add(target) - eq_(target, store.look_up_by_output.get("template_file")) + eq_(target, store.look_up_by_output.get(output)) From de9589a29b95dd9d214f6f793f4f4c0cbb723d1c Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 16:28:00 +0100 Subject: [PATCH 12/14] :books: update doc --- docs/level-22-intermediate-targets/REAME.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/level-22-intermediate-targets/REAME.rst b/docs/level-22-intermediate-targets/REAME.rst index e281c7d8..5a667e99 100644 --- a/docs/level-22-intermediate-targets/REAME.rst +++ b/docs/level-22-intermediate-targets/REAME.rst @@ -5,11 +5,11 @@ It is natural to allow intermediate target to be source so that different moban plugins can interact with each other. The good news is since moban verion 0.6.5, it is support. +.. note:: + The bad news is, folder as imtermediate target is not supported yet and will be + considered in next incremental build. For now, the date cannot be confirmed. -The bad news is, folder as imtermediate target is not supported yet and will be -considered in next incremental build. For now, the date cannot be confirmed. - -Here the syntax:: +Here are the syntax:: targets: - intermediate.jj2: original.jj2 From e70d48bb752e45bbf6f94507149f279b0d7595a5 Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 19:10:27 +0100 Subject: [PATCH 13/14] :books: update documentation links --- docs/README.rst | 2 ++ docs/index.rst | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/README.rst b/docs/README.rst index cfbe4a9f..74debb58 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -24,6 +24,7 @@ This section covers the use cases for moban. Please check them out individually. #. `Select a group target to run`_ #. `Template files in a zip or tar`_ #. `Template copying from a zip to a zip`_ +#. `Intermeidate targets`_ .. _Jinja2 command line: level-1-jinja2-cli .. _Template inheritance: level-2-template-inheritance @@ -46,3 +47,4 @@ This section covers the use cases for moban. Please check them out individually. .. _Select a group target to run: level-19-moban-a-sub-group-in-targets .. _Template files in a zip or tar: level-20-templates-configs-in-zip-or-tar .. _Template copying from a zip to a zip: level-21-copy-templates-into-an-alien-file-system +.. _Intermeidate targets: level-22-intermediate-targets diff --git a/docs/index.rst b/docs/index.rst index e5deaaf5..b6c3946d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -36,6 +36,7 @@ examples folder. level-19-moban-a-sub-group-in-targets/README.rst level-20-templates-configs-in-zip-or-tar/README.rst level-21-copy-templates-into-an-alien-file-system/README.rst + level-22-intermediate-targets/README.rst For more complex use case, please look at `its usage in pyexcel project `_ From 060c8204cc4056ee329a63609731e6253cc720ec Mon Sep 17 00:00:00 2001 From: chfw Date: Sat, 12 Oct 2019 19:14:47 +0100 Subject: [PATCH 14/14] :books: update release date --- .moban.cd/changelog.yml | 2 +- CHANGELOG.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index 02ad0541..31fef9d2 100644 --- a/.moban.cd/changelog.yml +++ b/.moban.cd/changelog.yml @@ -5,7 +5,7 @@ releases: - action: Updated details: - "`#335`: support intermediate targets in moban file" - date: tbd + date: 13.10.2019 version: 0.6.5 - changes: - action: Updated diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 75433bda..131748f8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ Change log ================================================================================ -0.6.5 - tbd +0.6.5 - 13.10.2019 -------------------------------------------------------------------------------- **Updated**