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/.isort.cfg b/.isort.cfg index 25965d9b..33965f07 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -2,11 +2,11 @@ line_length=79 # Ignore generated files skip=setup.py, moban/__init__.py -known_first_party=fs, lml, crayons, jinja2, ruamel.yaml, mock, nose +known_third_party=fs, lml, crayons, jinja2, ruamel.yaml, mock, nose indent=' ' multi_line_output=3 length_sort=1 include_trailing_comma=true default_section=FIRSTPARTY no_lines_before=LOCALFOLDER -sections=FUTURE,STDLIB,FIRSTPARTY,THIRDPARTY,LOCALFOLDER +sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index a0dd2995..31fef9d2 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: 13.10.2019 + version: 0.6.5 - changes: - action: Updated details: diff --git a/.moban.cd/moban.yml b/.moban.cd/moban.yml index 52dba2a1..4448cc2f 100644 --- a/.moban.cd/moban.yml +++ b/.moban.cd/moban.yml @@ -4,8 +4,8 @@ organisation: moremoban author: C. W. contact: wangc_2011@hotmail.com license: MIT -version: 0.6.4 -current_version: 0.6.4 +version: 0.6.5 +current_version: 0.6.5 release: 0.6.4 branch: master master: index 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/CHANGELOG.rst b/CHANGELOG.rst index 972070f8..131748f8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,11 +1,18 @@ Change log ================================================================================ +0.6.5 - 13.10.2019 +-------------------------------------------------------------------------------- + +**Updated** + +#. `#335 `_: support intermediate + targets in moban file + 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 +21,7 @@ Updated 0.6.3 - 25.09.2019 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#260 `_: jinja-cli parity: support command line pipe stream. @@ -23,8 +29,7 @@ Added 0.6.2 - 15.09.2019 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#322 `_: Implicit targets with template extensions default to copy @@ -36,8 +41,7 @@ Added 0.6.1 - 10.09.2019 -------------------------------------------------------------------------------- -Fixed -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Fixed** #. `#328 `_: update backward compatibility @@ -45,8 +49,7 @@ Fixed 0.6.0 - 10.09.2019 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#205 `_: support `pyFilesystem2 `_ @@ -58,8 +61,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 +69,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 +95,7 @@ Updated 0.4.5 - 07.07.2019 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#271 `_: support git branch change in later run. @@ -103,8 +103,7 @@ Updated 0.4.4 - 26.05.2019 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#265 `_: Use simple `read binary` to read instead of encoding @@ -112,20 +111,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 +130,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 +152,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 +164,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 +178,7 @@ Updated 0.3.10 - 03.02.2019 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#174 `_: Store git cache in XDG_CACHE_DIR @@ -197,8 +187,7 @@ Added #. `#164 `_: support additional data formats -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#178 `_: UnboundLocalError: local variable 'target' referenced before assignment @@ -208,8 +197,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 +209,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 +222,7 @@ Updated 0.3.7 - 6-1-2019 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#146 `_: added a low-setup usage mode via environment variables to moban @@ -247,8 +233,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 +244,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 +253,7 @@ Updated 0.3.4.1 - 28-11-2018 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#137 `_: missing contributors.rst file @@ -278,23 +261,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 +282,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 +290,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 +298,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 +318,7 @@ Removed 0.2.4 - 14-07-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#32 `_: option 1 copy a directory without its subdirectories. @@ -354,8 +328,7 @@ Added 0.2.3 - 10-07-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#76 `_: running moban as a module from python command @@ -367,14 +340,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 +353,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 +361,7 @@ Updated 0.2.0 - 11-06-2018 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#18 `_: file exists test #. `#23 `_: custom jinja plugins @@ -402,8 +371,7 @@ Added #. `#58 `_: allow template type per template -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#34 `_: fix plural message if single file is processed @@ -411,8 +379,7 @@ Updated 0.1.4 - 29-May-2018 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. `#21 `_: targets become optional @@ -424,16 +391,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 +406,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 +417,7 @@ Added 0.1.0 - 19-Dec-2017 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#14 `_, provide shell exit code @@ -462,8 +425,7 @@ Added 0.0.9 - 24-Nov-2017 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. `#11 `_, recognize .moban.yaml as well as .moban.yml. @@ -472,8 +434,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 +446,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 +467,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 +481,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 +490,7 @@ Added 0.0.4 - 11-May-2016 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. Bug fix `#5 `_, should detect duplicated targets in `.moban.yml` file. @@ -544,8 +498,7 @@ Updated 0.0.3 - 09-May-2016 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. Bug fix `#4 `_, keep trailing new lines @@ -553,8 +506,7 @@ Updated 0.0.2 - 27-Apr-2016 -------------------------------------------------------------------------------- -Updated -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Updated** #. Bug fix `#1 `_, failed to save utf-8 characters @@ -562,7 +514,6 @@ Updated 0.0.1 - 23-Mar-2016 -------------------------------------------------------------------------------- -Added -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**Added** #. Initial release 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/conf.py b/docs/conf.py index 7f2dd23d..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 -------------------------------------------------------------- @@ -25,7 +25,7 @@ copyright = '2017-2019 Onni Software Ltd.' author = 'C. W.' # The short X.Y version -version = '0.6.4' +version = '0.6.5' # The full version, including alpha/beta/rc tags release = '0.6.4' @@ -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/docs/index.rst b/docs/index.rst index d5a85674..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 `_ @@ -48,6 +49,14 @@ Developer Guide .. include:: ../CHANGELOG.rst +Migration Notes +================================================================================ + +.. toctree:: + + migration-note + + Indices and tables ================== diff --git a/docs/level-14-custom-data-loader/custom-data-loader/custom.py b/docs/level-14-custom-data-loader/custom-data-loader/custom.py index f7c32dad..61813cce 100644 --- a/docs/level-14-custom-data-loader/custom-data-loader/custom.py +++ b/docs/level-14-custom-data-loader/custom-data-loader/custom.py @@ -1,8 +1,9 @@ import csv -from moban import constants from lml.plugin import PluginInfo +from moban import constants + @PluginInfo(constants.DATA_LOADER_EXTENSION, tags=["custom"]) def open_custom(file_name): diff --git a/docs/level-22-intermediate-targets/.moban.yaml b/docs/level-22-intermediate-targets/.moban.yaml new file mode 100644 index 00000000..8493915e --- /dev/null +++ b/docs/level-22-intermediate-targets/.moban.yaml @@ -0,0 +1,3 @@ +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..5a667e99 --- /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. + +.. 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. + +Here are 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/docs/level-7-use-custom-jinja2-filter-test-n-global/custom-jj2-plugin/filter.py b/docs/level-7-use-custom-jinja2-filter-test-n-global/custom-jj2-plugin/filter.py index ac71c4c3..9661035b 100644 --- a/docs/level-7-use-custom-jinja2-filter-test-n-global/custom-jj2-plugin/filter.py +++ b/docs/level-7-use-custom-jinja2-filter-test-n-global/custom-jj2-plugin/filter.py @@ -1,7 +1,7 @@ import sys import base64 -from moban.jinja2.extensions import JinjaFilter +from moban.plugins.jinja2.extensions import JinjaFilter @JinjaFilter() diff --git a/docs/level-7-use-custom-jinja2-filter-test-n-global/custom-jj2-plugin/global.py b/docs/level-7-use-custom-jinja2-filter-test-n-global/custom-jj2-plugin/global.py index b4396280..cf11ce4b 100644 --- a/docs/level-7-use-custom-jinja2-filter-test-n-global/custom-jj2-plugin/global.py +++ b/docs/level-7-use-custom-jinja2-filter-test-n-global/custom-jj2-plugin/global.py @@ -1,3 +1,3 @@ -from moban.jinja2.extensions import jinja_global +from moban.plugins.jinja2.extensions import jinja_global jinja_global('global', dict(hello='world')) diff --git a/docs/level-7-use-custom-jinja2-filter-test-n-global/custom-jj2-plugin/test.py b/docs/level-7-use-custom-jinja2-filter-test-n-global/custom-jj2-plugin/test.py index 903b0b17..501d2485 100644 --- a/docs/level-7-use-custom-jinja2-filter-test-n-global/custom-jj2-plugin/test.py +++ b/docs/level-7-use-custom-jinja2-filter-test-n-global/custom-jj2-plugin/test.py @@ -1,4 +1,4 @@ -from moban.jinja2.extensions import JinjaTest +from moban.plugins.jinja2.extensions import JinjaTest @JinjaTest() diff --git a/docs/migration-notes.rst b/docs/migration-notes.rst new file mode 100644 index 00000000..306d675c --- /dev/null +++ b/docs/migration-notes.rst @@ -0,0 +1,10 @@ +Migrate to 0.6.x +================================================================================ + +It has been noticed that, this version will fail to template but do a copy, in +the following situation:: + + targets: + index.rst: index.rst + +Please note that 0.6.x changed its behavior to do a copy instead of templating. diff --git a/moban/_version.py b/moban/_version.py index a83896a5..06c83660 100644 --- a/moban/_version.py +++ b/moban/_version.py @@ -1,2 +1,2 @@ -__version__ = "0.6.4" +__version__ = "0.6.5" __author__ = "C. W." diff --git a/moban/constants.py b/moban/constants.py index 9b4277e5..2f8f3f4c 100644 --- a/moban/constants.py +++ b/moban/constants.py @@ -1,4 +1,4 @@ -from moban import file_system +from moban.externals import file_system # Template type TEMPLATE_JINJA2 = "jinja2" diff --git a/moban/core/context.py b/moban/core/context.py index 10ce96f0..50d0ec4c 100644 --- a/moban/core/context.py +++ b/moban/core/context.py @@ -1,9 +1,11 @@ import os import copy -from moban import utils, reporter, constants, exceptions +from moban import constants, exceptions +from moban.core import utils +from moban.externals import reporter from moban.program_options import OPTIONS -from moban.data_loaders.manager import merge, load_data +from moban.core.data_loader import merge, load_data class Context(object): diff --git a/moban/data_loaders/manager.py b/moban/core/data_loader.py similarity index 95% rename from moban/data_loaders/manager.py rename to moban/core/data_loader.py index 6c7a9097..f9ab2434 100644 --- a/moban/data_loaders/manager.py +++ b/moban/core/data_loader.py @@ -1,10 +1,10 @@ from collections import OrderedDict -import moban.data_loaders.yaml # noqa: F401 -import moban.data_loaders.json_loader # noqa: F401 -from moban import constants, file_system from lml.plugin import PluginManager +from moban import constants +from moban.externals import file_system + class AnyDataLoader(PluginManager): def __init__(self): diff --git a/moban/definitions.py b/moban/core/definitions.py similarity index 83% rename from moban/definitions.py rename to moban/core/definitions.py index e72f3d88..d81fd2e0 100644 --- a/moban/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/hashstore.py b/moban/core/hashstore.py similarity index 97% rename from moban/hashstore.py rename to moban/core/hashstore.py index 636e7165..3987ce65 100644 --- a/moban/hashstore.py +++ b/moban/core/hashstore.py @@ -2,7 +2,8 @@ import json import hashlib -from moban import constants, file_system +from moban import constants +from moban.externals import file_system PY2 = sys.version_info[0] == 2 diff --git a/moban/core/moban_factory.py b/moban/core/moban_factory.py index e430f097..101394ce 100644 --- a/moban/core/moban_factory.py +++ b/moban/core/moban_factory.py @@ -3,14 +3,17 @@ import logging from collections import defaultdict -from moban import utils, reporter, constants, exceptions, file_system from fs.errors import ResourceNotFound from lml.plugin import PluginManager -from moban.hashstore import HASH_STORE + +from moban import constants, exceptions +from moban.core import utils +from moban.externals import reporter, file_system from moban.deprecated import deprecated_moban_path_notation from moban.core.context import Context from moban.core.strategy import Strategy -from moban.buffered_writer import BufferedWriter +from moban.core.hashstore import HASH_STORE +from moban.externals.buffered_writer import BufferedWriter log = logging.getLogger(__name__) PY3_ABOVE = sys.version_info[0] > 2 diff --git a/moban/mobanfile/__init__.py b/moban/core/mobanfile/__init__.py similarity index 93% rename from moban/mobanfile/__init__.py rename to moban/core/mobanfile/__init__.py index f3ae753d..34d3f921 100644 --- a/moban/mobanfile/__init__.py +++ b/moban/core/mobanfile/__init__.py @@ -4,17 +4,20 @@ import logging from collections import OrderedDict -from moban import core, reporter, constants from lml.utils import do_import -from moban.utils import verify_the_existence_of_directories + +from moban import core, constants +from moban.externals import reporter +from moban.core.utils import verify_the_existence_of_directories from moban.deprecated import handle_copy, handle_requires -from moban.mobanfile.targets import ( +from moban.core.data_loader import merge +from moban.core.moban_factory import expand_template_directories +from moban.core.mobanfile.targets import ( parse_targets, extract_target, extract_group_targets, ) -from moban.core.moban_factory import expand_template_directories -from moban.data_loaders.manager import merge +from .store import STORE LOG = logging.getLogger(__name__) @@ -87,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..eda34174 --- /dev/null +++ b/moban/core/mobanfile/store.py @@ -0,0 +1,3 @@ +from moban.core.definitions import Store + +STORE = Store() diff --git a/moban/mobanfile/targets.py b/moban/core/mobanfile/targets.py similarity index 93% rename from moban/mobanfile/targets.py rename to moban/core/mobanfile/targets.py index 161de814..f0a6a2d8 100644 --- a/moban/mobanfile/targets.py +++ b/moban/core/mobanfile/targets.py @@ -1,9 +1,11 @@ import uuid import logging -from moban import core, reporter, constants, exceptions -from moban.definitions import TemplateTarget -from moban.mobanfile.templates import handle_template +from moban import core, constants, exceptions +from moban.externals import reporter +from moban.core.definitions import TemplateTarget +from .store import STORE +from .templates import handle_template LOG = logging.getLogger(__name__) @@ -46,10 +48,11 @@ 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): - yield template_target + STORE.add(template_target) else: for output, template_file in target.items(): if isinstance(template_file, str) is False: @@ -59,12 +62,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): diff --git a/moban/mobanfile/templates.py b/moban/core/mobanfile/templates.py similarity index 67% rename from moban/mobanfile/templates.py rename to moban/core/mobanfile/templates.py index 893ee09d..5de94640 100644 --- a/moban/mobanfile/templates.py +++ b/moban/core/mobanfile/templates.py @@ -1,6 +1,8 @@ import logging -from moban import reporter, constants, file_system +from moban import constants +from moban.externals import reporter, file_system +from .store import STORE LOG = logging.getLogger(__name__) @@ -19,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): @@ -71,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/moban/plugins.py b/moban/core/plugins.py similarity index 62% rename from moban/plugins.py rename to moban/core/plugins.py index 88ce7f65..486c64cc 100644 --- a/moban/plugins.py +++ b/moban/core/plugins.py @@ -1,11 +1,12 @@ -from moban import constants from lml.loader import scan_plugins_regex +from moban import constants + BUILTIN_EXENSIONS = [ - "moban.jinja2.engine", - "moban.data_loaders.yaml", - "moban.data_loaders.json_loader", - "moban.copy", + "moban.plugins.jinja2.engine", + "moban.plugins.yaml_loader", + "moban.plugins.json_loader", + "moban.plugins.copy", ] diff --git a/moban/utils.py b/moban/core/utils.py similarity index 72% rename from moban/utils.py rename to moban/core/utils.py index 98672fed..884e0e19 100644 --- a/moban/utils.py +++ b/moban/core/utils.py @@ -1,22 +1,11 @@ -import os -import errno import logging -from moban import constants, exceptions, file_system +from moban import constants, exceptions +from moban.externals import file_system LOG = logging.getLogger(__name__) -def mkdir_p(path): - try: - os.makedirs(path) - except OSError as exc: # Python >2.5 - if exc.errno == errno.EEXIST and os.path.isdir(path): - pass - else: - raise - - def verify_the_existence_of_directories(dirs): LOG.debug("Verifying the existence: %s", dirs) if not isinstance(dirs, list): diff --git a/moban/deprecated/__init__.py b/moban/deprecated/__init__.py index a2218fbb..2751b422 100644 --- a/moban/deprecated/__init__.py +++ b/moban/deprecated/__init__.py @@ -1,7 +1,9 @@ import sys from functools import wraps -from moban import plugins, reporter, constants, file_system +from moban import constants +from moban.core import plugins +from moban.externals import reporter, file_system from moban.deprecated import repo from moban.deprecated.repo import git_clone from moban.deprecated.library import LIBRARIES diff --git a/moban/deprecated/library.py b/moban/deprecated/library.py index 4c7405dc..ff9c782d 100644 --- a/moban/deprecated/library.py +++ b/moban/deprecated/library.py @@ -1,6 +1,7 @@ -from moban import constants from lml.plugin import PluginManager +from moban import constants + class LibraryManager(PluginManager): def __init__(self): diff --git a/moban/deprecated/repo.py b/moban/deprecated/repo.py index 47c40635..b4f2492e 100644 --- a/moban/deprecated/repo.py +++ b/moban/deprecated/repo.py @@ -1,8 +1,8 @@ import sys import subprocess -from moban import reporter, constants, exceptions, file_system -from moban.utils import mkdir_p +from moban import constants, exceptions +from moban.externals import reporter, file_system def git_clone(requires): @@ -15,7 +15,7 @@ def git_clone(requires): make_sure_git_is_available() moban_home = get_moban_home() - mkdir_p(moban_home) + file_system.mkdir_p(moban_home) for require in requires: repo_name = get_repo_name(require.git_url) diff --git a/moban/data_loaders/__init__.py b/moban/externals/__init__.py similarity index 100% rename from moban/data_loaders/__init__.py rename to moban/externals/__init__.py diff --git a/moban/buffered_writer.py b/moban/externals/buffered_writer.py similarity index 93% rename from moban/buffered_writer.py rename to moban/externals/buffered_writer.py index ff980895..dd8b5242 100644 --- a/moban/buffered_writer.py +++ b/moban/externals/buffered_writer.py @@ -3,7 +3,8 @@ import fs import fs.path -from moban import utils, file_system + +from moban.externals import file_system PY2 = sys.version_info[0] == 2 @@ -43,6 +44,6 @@ def write_file_out(filename, content): if not file_system.is_zip_alike_url(filename): dest_folder = os.path.dirname(filename) if dest_folder: - utils.mkdir_p(dest_folder) + file_system.mkdir_p(dest_folder) file_system.write_bytes(filename, content) diff --git a/moban/file_system.py b/moban/externals/file_system.py similarity index 96% rename from moban/file_system.py rename to moban/externals/file_system.py index f08554f4..3aaf4497 100644 --- a/moban/file_system.py +++ b/moban/externals/file_system.py @@ -1,14 +1,16 @@ import os import sys import stat +import errno import logging from contextlib import contextmanager import fs import fs.path -from moban import exceptions from fs.multifs import MultiFS +from moban import exceptions + try: from urllib.parse import urlparse except ImportError: @@ -260,3 +262,13 @@ def get_multi_fs(directories): for directory in directories: filesystem.add_fs(directory, fs.open_fs(directory)) return filesystem + + +def mkdir_p(path): + try: + os.makedirs(path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: + raise diff --git a/moban/reporter.py b/moban/externals/reporter.py similarity index 99% rename from moban/reporter.py rename to moban/externals/reporter.py index e79ad989..e7fb2eec 100644 --- a/moban/reporter.py +++ b/moban/externals/reporter.py @@ -1,4 +1,5 @@ import crayons + import moban.constants as constants MESSAGE_TEMPLATING = "Templating {0} to {1}" diff --git a/moban/main.py b/moban/main.py index e855d5a5..de2b742c 100644 --- a/moban/main.py +++ b/moban/main.py @@ -14,19 +14,11 @@ import logging.config from collections import defaultdict -from moban import ( - core, - plugins, - reporter, - constants, - mobanfile, - exceptions, - file_system, -) +from moban import constants, exceptions +from moban.core import ENGINES, plugins, hashstore, mobanfile, data_loader from moban._version import __version__ -from moban.hashstore import HASH_STORE +from moban.externals import reporter, file_system from moban.program_options import OPTIONS -from moban.data_loaders.manager import merge, load_data LOG = logging.getLogger() LOG_LEVEL = [logging.WARNING, logging.INFO, logging.DEBUG] @@ -40,7 +32,7 @@ def main(): options = vars(parser.parse_args()) handle_verbose(options[constants.LABEL_VERBOSE]) load_engine_factory_and_engines() # Error: jinja2 if removed - HASH_STORE.IGNORE_CACHE_FILE = options[constants.LABEL_FORCE] + hashstore.HASH_STORE.IGNORE_CACHE_FILE = options[constants.LABEL_FORCE] options[constants.CLI_DICT] = handle_custom_variables( options.pop(constants.LABEL_DEFINE) ) @@ -180,7 +172,7 @@ def handle_moban_file(moban_file, options): """ act upon default moban file """ - moban_file_configurations = load_data(None, moban_file) + moban_file_configurations = data_loader.load_data(None, moban_file) if moban_file_configurations is None: raise exceptions.MobanfileGrammarException( constants.ERROR_INVALID_MOBAN_FILE % moban_file @@ -202,7 +194,7 @@ def handle_moban_file(moban_file, options): raise exceptions.MobanfileGrammarException( constants.MESSAGE_FILE_VERSION_NOT_SUPPORTED % version ) - HASH_STORE.save_hashes() + hashstore.HASH_STORE.save_hashes() def check_none(data, moban_file): @@ -231,8 +223,8 @@ def handle_command_line(options): """ act upon command options """ - options = merge(options, constants.DEFAULT_OPTIONS) - engine = core.ENGINES.get_engine( + options = data_loader.merge(options, constants.DEFAULT_OPTIONS) + engine = ENGINES.get_engine( options[constants.LABEL_TEMPLATE_TYPE], options[constants.LABEL_TMPL_DIRS], options[constants.LABEL_CONFIG_DIR], @@ -257,7 +249,7 @@ def handle_command_line(options): options[constants.LABEL_OUTPUT], ) engine.report() - HASH_STORE.save_hashes() + hashstore.HASH_STORE.save_hashes() exit_code = reporter.convert_to_shell_exit_code( engine.number_of_templated_files() ) @@ -293,7 +285,7 @@ def handle_custom_extensions(list_of_definitions): for definition in list_of_definitions: key, value = definition.split("=") user_extensions[key].add(value) - core.ENGINES.register_extensions(user_extensions) + ENGINES.register_extensions(user_extensions) def handle_verbose(verbose_level): diff --git a/moban/jinja2/__init__.py b/moban/plugins/__init__.py similarity index 100% rename from moban/jinja2/__init__.py rename to moban/plugins/__init__.py diff --git a/moban/copy.py b/moban/plugins/copy.py similarity index 93% rename from moban/copy.py rename to moban/plugins/copy.py index e617366a..455c9227 100644 --- a/moban/copy.py +++ b/moban/plugins/copy.py @@ -1,6 +1,8 @@ -from moban import constants, file_system from lml.plugin import PluginInfo +from moban import constants +from moban.externals import file_system + @PluginInfo( constants.TEMPLATE_ENGINE_EXTENSION, tags=[constants.TEMPLATE_COPY] diff --git a/moban/jinja2/filters/__init__.py b/moban/plugins/jinja2/__init__.py similarity index 100% rename from moban/jinja2/filters/__init__.py rename to moban/plugins/jinja2/__init__.py diff --git a/moban/jinja2/engine.py b/moban/plugins/jinja2/engine.py similarity index 96% rename from moban/jinja2/engine.py rename to moban/plugins/jinja2/engine.py index 87aeb76d..88080157 100644 --- a/moban/jinja2/engine.py +++ b/moban/plugins/jinja2/engine.py @@ -3,20 +3,21 @@ from importlib import import_module import fs.errors -from moban import constants, file_system from jinja2 import Template, Environment from lml.loader import scan_plugins_regex from lml.plugin import PluginInfo, PluginManager +from jinja2_fsloader import FSLoader from jinja2.exceptions import TemplateNotFound -from jinja2_fsloader import FSLoader +from moban import constants +from moban.externals import file_system JINJA2_LIBRARIES = "^moban_jinja2_.+$" JINJA2_EXTENSIONS = [ - "moban.jinja2.filters.repr", - "moban.jinja2.filters.github", - "moban.jinja2.filters.text", - "moban.jinja2.tests.files", + "moban.plugins.jinja2.filters.repr", + "moban.plugins.jinja2.filters.github", + "moban.plugins.jinja2.filters.text", + "moban.plugins.jinja2.tests.files", ] JINJA2_THIRD_PARTY_EXTENSIONS = ["jinja2.ext.do", "jinja2.ext.loopcontrols"] LOG = logging.getLogger(__name__) diff --git a/moban/jinja2/extensions.py b/moban/plugins/jinja2/extensions.py similarity index 99% rename from moban/jinja2/extensions.py rename to moban/plugins/jinja2/extensions.py index a4817ca1..7b21dbfd 100644 --- a/moban/jinja2/extensions.py +++ b/moban/plugins/jinja2/extensions.py @@ -1,6 +1,7 @@ -from moban import constants from lml.plugin import PluginInfo +from moban import constants + class JinjaFilter(PluginInfo): def __init__(self): diff --git a/moban/jinja2/tests/__init__.py b/moban/plugins/jinja2/filters/__init__.py similarity index 100% rename from moban/jinja2/tests/__init__.py rename to moban/plugins/jinja2/filters/__init__.py diff --git a/moban/jinja2/filters/github.py b/moban/plugins/jinja2/filters/github.py similarity index 96% rename from moban/jinja2/filters/github.py rename to moban/plugins/jinja2/filters/github.py index 5a12972a..815627e6 100644 --- a/moban/jinja2/filters/github.py +++ b/moban/plugins/jinja2/filters/github.py @@ -1,6 +1,6 @@ import re -from moban.jinja2.extensions import JinjaFilter +from moban.plugins.jinja2.extensions import JinjaFilter GITHUB_REF_PATTERN = "`([^`]*?#[0-9]+)`" ISSUE = "^.*?" + GITHUB_REF_PATTERN + ".*?$" diff --git a/moban/jinja2/filters/repr.py b/moban/plugins/jinja2/filters/repr.py similarity index 77% rename from moban/jinja2/filters/repr.py rename to moban/plugins/jinja2/filters/repr.py index 3f278915..e0fd304e 100644 --- a/moban/jinja2/filters/repr.py +++ b/moban/plugins/jinja2/filters/repr.py @@ -1,4 +1,4 @@ -from moban.jinja2.extensions import JinjaFilter +from moban.plugins.jinja2.extensions import JinjaFilter @JinjaFilter() diff --git a/moban/jinja2/filters/text.py b/moban/plugins/jinja2/filters/text.py similarity index 94% rename from moban/jinja2/filters/text.py rename to moban/plugins/jinja2/filters/text.py index 19c529e1..801a607f 100644 --- a/moban/jinja2/filters/text.py +++ b/moban/plugins/jinja2/filters/text.py @@ -1,6 +1,6 @@ import re -from moban.jinja2.extensions import JinjaFilter +from moban.plugins.jinja2.extensions import JinjaFilter @JinjaFilter() diff --git a/moban/plugins/jinja2/tests/__init__.py b/moban/plugins/jinja2/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/moban/jinja2/tests/files.py b/moban/plugins/jinja2/tests/files.py similarity index 90% rename from moban/jinja2/tests/files.py rename to moban/plugins/jinja2/tests/files.py index f5977627..471a0b56 100644 --- a/moban/jinja2/tests/files.py +++ b/moban/plugins/jinja2/tests/files.py @@ -1,7 +1,7 @@ import sys from os.path import isabs, isdir, exists, isfile, islink, ismount, lexists -from moban.jinja2.extensions import jinja_tests +from moban.plugins.jinja2.extensions import jinja_tests if sys.platform == "win32": from moban.jinja2.tests.win32 import samefile diff --git a/moban/jinja2/tests/win32.py b/moban/plugins/jinja2/tests/win32.py similarity index 100% rename from moban/jinja2/tests/win32.py rename to moban/plugins/jinja2/tests/win32.py diff --git a/moban/data_loaders/json_loader.py b/moban/plugins/json_loader.py similarity index 86% rename from moban/data_loaders/json_loader.py rename to moban/plugins/json_loader.py index 6393af47..8e56a5bf 100644 --- a/moban/data_loaders/json_loader.py +++ b/moban/plugins/json_loader.py @@ -1,8 +1,9 @@ import json -from moban import constants from lml.plugin import PluginInfo -from moban.file_system import open_file + +from moban import constants +from moban.externals.file_system import open_file @PluginInfo(constants.DATA_LOADER_EXTENSION, tags=["json"]) diff --git a/moban/data_loaders/yaml.py b/moban/plugins/yaml_loader.py similarity index 86% rename from moban/data_loaders/yaml.py rename to moban/plugins/yaml_loader.py index f082730c..10780735 100644 --- a/moban/data_loaders/yaml.py +++ b/moban/plugins/yaml_loader.py @@ -1,7 +1,8 @@ -from moban import constants from lml.plugin import PluginInfo from ruamel.yaml import YAML -from moban.file_system import open_file + +from moban import constants +from moban.externals.file_system import open_file @PluginInfo(constants.DATA_LOADER_EXTENSION, tags=["yaml", "yml"]) diff --git a/rnd_requirements.txt b/rnd_requirements.txt index 9e76ec64..86b965ae 100644 --- a/rnd_requirements.txt +++ b/rnd_requirements.txt @@ -1,4 +1 @@ https://github.com/moremoban/moban-handlebars/archive/dev.zip - - - diff --git a/setup.py b/setup.py index 15917f45..f2d2c60f 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ NAME = "moban" AUTHOR = "C. W." -VERSION = "0.6.4" +VERSION = "0.6.5" EMAIL = "wangc_2011@hotmail.com" LICENSE = "MIT" ENTRY_POINTS = { @@ -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() diff --git a/tests/core/test_context.py b/tests/core/test_context.py index 846d2383..d9e39bc7 100644 --- a/tests/core/test_context.py +++ b/tests/core/test_context.py @@ -2,6 +2,7 @@ import fs.path from nose.tools import eq_ + from moban.core.context import Context diff --git a/tests/core/test_engine.py b/tests/core/test_engine.py index d1c6c790..b64a2f0a 100644 --- a/tests/core/test_engine.py +++ b/tests/core/test_engine.py @@ -2,8 +2,9 @@ import fs.path from mock import patch -from moban.core import ENGINES from nose.tools import eq_ + +from moban.core import ENGINES from moban.definitions import TemplateTarget from moban.jinja2.engine import Engine from moban.data_loaders.yaml import open_yaml diff --git a/tests/core/test_moban_factory.py b/tests/core/test_moban_factory.py index c5f4b179..536d4eea 100644 --- a/tests/core/test_moban_factory.py +++ b/tests/core/test_moban_factory.py @@ -2,11 +2,12 @@ import sys import fs.path -import moban.exceptions as exceptions from mock import patch from lml.plugin import PluginInfo -from moban.core import ENGINES from nose.tools import eq_, raises + +import moban.exceptions as exceptions +from moban.core import ENGINES from moban.core.context import Context from moban.jinja2.engine import ( Engine, diff --git a/tests/data_loaders/test_json_loader.py b/tests/data_loaders/test_json_loader.py index 44ed74fa..c575fcc7 100644 --- a/tests/data_loaders/test_json_loader.py +++ b/tests/data_loaders/test_json_loader.py @@ -1,5 +1,6 @@ import fs.path from nose.tools import eq_ + from moban.data_loaders.json_loader import open_json diff --git a/tests/data_loaders/test_overrides.py b/tests/data_loaders/test_overrides.py index d9b190d3..7bc29bef 100644 --- a/tests/data_loaders/test_overrides.py +++ b/tests/data_loaders/test_overrides.py @@ -1,6 +1,7 @@ import os from nose.tools import eq_ + from moban.data_loaders.manager import load_data diff --git a/tests/data_loaders/test_yaml_loader.py b/tests/data_loaders/test_yaml_loader.py index c8f2c8b1..034926f1 100644 --- a/tests/data_loaders/test_yaml_loader.py +++ b/tests/data_loaders/test_yaml_loader.py @@ -1,5 +1,6 @@ import fs.path from nose.tools import eq_, raises + from moban.data_loaders.yaml import open_yaml from moban.data_loaders.manager import load_data diff --git a/tests/deprecated/test_handle_requires.py b/tests/deprecated/test_handle_requires.py index fa427c8f..f2c66bd5 100644 --- a/tests/deprecated/test_handle_requires.py +++ b/tests/deprecated/test_handle_requires.py @@ -1,5 +1,6 @@ from mock import patch from nose.tools import eq_ + from moban.deprecated import GitRequire diff --git a/tests/deprecated/test_repo.py b/tests/deprecated/test_repo.py index 1cfc571b..eacafbed 100644 --- a/tests/deprecated/test_repo.py +++ b/tests/deprecated/test_repo.py @@ -1,6 +1,7 @@ import fs.path from mock import patch from nose.tools import eq_, raises + from moban.deprecated import GitRequire from moban.exceptions import NoGitCommand from moban.deprecated.repo import ( diff --git a/tests/integration_tests/test_command_line_options.py b/tests/integration_tests/test_command_line_options.py index 0a2bc8e7..7ba46eb6 100644 --- a/tests/integration_tests/test_command_line_options.py +++ b/tests/integration_tests/test_command_line_options.py @@ -5,7 +5,8 @@ from mock import MagicMock, patch from nose import SkipTest from nose.tools import eq_, raises, assert_raises -from moban.definitions import TemplateTarget + +from moban.core.definitions import TemplateTarget try: from StringIO import StringIO @@ -19,11 +20,11 @@ def setUp(self): with open(self.config_file, "w") as f: f.write("hello: world") self.patcher1 = patch( - "moban.utils.verify_the_existence_of_directories" + "moban.core.utils.verify_the_existence_of_directories" ) self.patcher1.start() - @patch("moban.file_system.abspath") + @patch("moban.externals.file_system.abspath") @patch("moban.core.moban_factory.MobanEngine.render_to_file") def test_custom_options(self, fake_template_doer, fake_abspath): test_args = [ @@ -77,7 +78,7 @@ def setUp(self): with open(self.config_file, "w") as f: f.write("hello: world") self.patcher1 = patch( - "moban.utils.verify_the_existence_of_directories" + "moban.core.utils.verify_the_existence_of_directories" ) self.patcher1.start() @@ -130,7 +131,7 @@ def setUp(self): with open(self.data_file, "w") as f: f.write("hello: world") self.patcher1 = patch( - "moban.utils.verify_the_existence_of_directories" + "moban.core.utils.verify_the_existence_of_directories" ) self.patcher1.start() @@ -221,7 +222,7 @@ def setUp(self): with open(self.data_file, "w") as f: f.write("hello: world") self.patcher1 = patch( - "moban.utils.verify_the_existence_of_directories" + "moban.core.utils.verify_the_existence_of_directories" ) self.patcher1.start() @@ -259,7 +260,7 @@ def setUp(self): with open(self.data_file, "w") as f: f.write("hello: world") self.patcher1 = patch( - "moban.utils.verify_the_existence_of_directories" + "moban.core.utils.verify_the_existence_of_directories" ) self.patcher1.start() @@ -294,7 +295,7 @@ def setUp(self): os.path.join("tests", "fixtures", ".moban.yml"), self.config_file ) self.patcher1 = patch( - "moban.utils.verify_the_existence_of_directories" + "moban.core.utils.verify_the_existence_of_directories" ) self.patcher1.start() @@ -325,7 +326,7 @@ def tearDown(self): os.unlink(self.config_file) -@patch("moban.utils.verify_the_existence_of_directories") +@patch("moban.core.utils.verify_the_existence_of_directories") def test_duplicated_targets_in_moban_file(fake_verify): config_file = "duplicated.moban.yml" copyfile(os.path.join("tests", "fixtures", config_file), ".moban.yml") @@ -388,7 +389,10 @@ def setUp(self): with open(self.data_file, "w") as f: f.write("hello: world") - @patch("moban.utils.verify_the_existence_of_directories", return_value=".") + @patch( + "moban.core.utils.verify_the_existence_of_directories", + return_value=".", + ) def test_single_command(self, _): test_args = ["moban"] with patch.object(sys, "argv", test_args): @@ -460,7 +464,7 @@ def test_debug_option(fake_config): ) -@patch("moban.utils.verify_the_existence_of_directories", return_value=[]) +@patch("moban.core.utils.verify_the_existence_of_directories", return_value=[]) def test_git_repo_example(_): test_args = [ "moban", @@ -481,7 +485,7 @@ def test_git_repo_example(_): os.unlink("test_git_repo_example.py") -@patch("moban.utils.verify_the_existence_of_directories", return_value=[]) +@patch("moban.core.utils.verify_the_existence_of_directories", return_value=[]) def test_pypi_pkg_example(_): test_args = [ "moban", diff --git a/tests/jinja2/test_engine.py b/tests/jinja2/test_engine.py index 5238621a..4ebb396f 100644 --- a/tests/jinja2/test_engine.py +++ b/tests/jinja2/test_engine.py @@ -1,7 +1,8 @@ import os -from moban import file_system from nose.tools import eq_ + +from moban import file_system from moban.jinja2.engine import Engine diff --git a/tests/jinja2/test_extensions.py b/tests/jinja2/test_extensions.py index 61ddbf1a..4d602fc9 100644 --- a/tests/jinja2/test_extensions.py +++ b/tests/jinja2/test_extensions.py @@ -1,7 +1,8 @@ import os -from moban import file_system from nose.tools import eq_ + +from moban import file_system from moban.jinja2.engine import Engine from moban.jinja2.extensions import jinja_global from moban.core.moban_factory import MobanEngine diff --git a/tests/jinja2/test_github.py b/tests/jinja2/test_github.py index 2bb043fd..25aa58d1 100644 --- a/tests/jinja2/test_github.py +++ b/tests/jinja2/test_github.py @@ -1,4 +1,5 @@ from nose.tools import eq_ + from moban.jinja2.filters.github import github_expand diff --git a/tests/jinja2/test_repr.py b/tests/jinja2/test_repr.py index c18d458b..01d388ea 100644 --- a/tests/jinja2/test_repr.py +++ b/tests/jinja2/test_repr.py @@ -1,4 +1,5 @@ from nose.tools import eq_ + from moban.jinja2.filters.repr import repr as repr_function diff --git a/tests/jinja2/test_text.py b/tests/jinja2/test_text.py index 177c0c5c..17f000df 100644 --- a/tests/jinja2/test_text.py +++ b/tests/jinja2/test_text.py @@ -1,4 +1,5 @@ from nose.tools import eq_ + from moban.jinja2.filters.text import split_length diff --git a/tests/mobanfile/test_mobanfile.py b/tests/mobanfile/test_mobanfile.py index db8c11b7..905a72df 100644 --- a/tests/mobanfile/test_mobanfile.py +++ b/tests/mobanfile/test_mobanfile.py @@ -1,12 +1,13 @@ import fs.path from mock import patch from nose.tools import eq_ -from moban.definitions import TemplateTarget + +from moban.core.definitions import TemplateTarget @patch("moban.core.moban_factory.MobanEngine.render_to_files") def test_handle_targets(fake_renderer): - from moban.mobanfile import handle_targets + from moban.core.mobanfile import handle_targets TEMPLATE = "copier-test01.csv" OUTPUT = "output.csv" @@ -39,7 +40,10 @@ def test_handle_targets(fake_renderer): @patch("moban.core.moban_factory.MobanEngine.render_to_files") def test_handle_targets_sequence(fake_renderer): - from moban.mobanfile import handle_targets + 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 diff --git a/tests/mobanfile/test_targets.py b/tests/mobanfile/test_targets.py index dff5c850..836b481b 100644 --- a/tests/mobanfile/test_targets.py +++ b/tests/mobanfile/test_targets.py @@ -2,9 +2,10 @@ import fs.path from nose.tools import eq_, raises -from moban.mobanfile import targets + from moban.exceptions import GroupTargetNotFound -from moban.definitions import TemplateTarget +from moban.core.mobanfile import targets +from moban.core.definitions import TemplateTarget TEMPLATE = "a.jj2" OUTPUT = "a.output" diff --git a/tests/mobanfile/test_templates.py b/tests/mobanfile/test_templates.py index bd07f6ff..c3b54613 100644 --- a/tests/mobanfile/test_templates.py +++ b/tests/mobanfile/test_templates.py @@ -1,7 +1,8 @@ import fs.path from mock import patch from nose.tools import eq_ -from moban.mobanfile.templates import handle_template + +from moban.core.mobanfile.templates import handle_template class TestHandleTemplateFunction: @@ -15,7 +16,7 @@ def test_copy_files(self): expected = [("copier-test01.csv", "/tmp/test", "csv")] eq_(expected, results) - @patch("moban.reporter.report_error_message") + @patch("moban.externals.reporter.report_error_message") def test_file_not_found(self, reporter): list( handle_template( @@ -64,7 +65,7 @@ def test_listing_dir_recusively(self): sorted(expected, key=lambda x: x[0]), ) - @patch("moban.reporter.report_error_message") + @patch("moban.externals.reporter.report_error_message") def test_listing_dir_recusively_with_error(self, reporter): test_dir = "/tmp/copy-a-directory" list( diff --git a/tests/test_buffered_writer.py b/tests/test_buffered_writer.py index e6684433..02e5caaa 100644 --- a/tests/test_buffered_writer.py +++ b/tests/test_buffered_writer.py @@ -1,9 +1,10 @@ import os import tempfile -from moban import file_system from nose.tools import eq_ -from moban.buffered_writer import BufferedWriter, write_file_out + +from moban.externals import file_system +from moban.externals.buffered_writer import BufferedWriter, write_file_out CONTENT = b""" helloworld diff --git a/tests/test_copy_engine.py b/tests/test_copy_engine.py index 65a25262..f590d21a 100644 --- a/tests/test_copy_engine.py +++ b/tests/test_copy_engine.py @@ -1,10 +1,11 @@ import os import fs.path -from moban import file_system -from moban.copy import ContentForwardEngine from nose.tools import eq_ +from moban.externals import file_system +from moban.plugins.copy import ContentForwardEngine + class TestContentForwardEngine: def setUp(self): diff --git a/tests/test_definitions.py b/tests/test_definitions.py index 98a78741..8992ca38 100644 --- a/tests/test_definitions.py +++ b/tests/test_definitions.py @@ -1,6 +1,7 @@ from nose.tools import eq_ + from moban.deprecated import GitRequire -from moban.definitions import TemplateTarget +from moban.core.definitions import Store, TemplateTarget def test_git_require_repr(): @@ -42,3 +43,11 @@ def test_branch_params(): actual = require.clone_params() expected = {"single_branch": True, "branch": "ghpages", "depth": 2} eq_(expected, actual) + + +def test_store(): + store = Store() + output = "output" + target = TemplateTarget("template_file", "data_file", output) + store.add(target) + eq_(target, store.look_up_by_output.get(output)) diff --git a/tests/test_docs.py b/tests/test_docs.py index e3cc36e9..eae9e2cd 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -311,6 +311,12 @@ 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" diff --git a/tests/test_file_system.py b/tests/test_file_system.py index 5b2eb26b..a9fbe33f 100644 --- a/tests/test_file_system.py +++ b/tests/test_file_system.py @@ -1,10 +1,13 @@ import os import sys import stat +from shutil import rmtree +from mock import patch from nose import SkipTest -from moban import file_system from nose.tools import eq_, raises + +from moban.externals import file_system from moban.exceptions import FileNotFound LOCAL_FOLDER = "tests/fixtures" @@ -243,3 +246,21 @@ def test_file_permission_copy_symlink(): os.unlink(test_source) os.unlink(test_dest) os.unlink(test_symlink) + + +def test_mkdir_p(): + test_path = "a/b/c/d" + file_system.mkdir_p(test_path) + assert os.path.exists(test_path) + rmtree(test_path) + + +@patch("subprocess.check_call") +def test_pip_install(fake_check_all): + import sys + from moban.deprecated import pip_install + + pip_install(["package1", "package2"]) + fake_check_all.assert_called_with( + [sys.executable, "-m", "pip", "install", "package1 package2"] + ) diff --git a/tests/test_hash_store.py b/tests/test_hash_store.py index 3a8d5ae9..3220fee5 100644 --- a/tests/test_hash_store.py +++ b/tests/test_hash_store.py @@ -2,8 +2,9 @@ import sys from nose import SkipTest -from moban import file_system -from moban.hashstore import HashStore + +from moban.externals import file_system +from moban.core.hashstore import HashStore class TestHashStore: diff --git a/tests/test_main.py b/tests/test_main.py index 0de35825..abf381bd 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -2,10 +2,11 @@ import sys from shutil import copyfile -import moban.exceptions as exceptions from mock import MagicMock, patch from nose.tools import eq_, raises, assert_raises +import moban.exceptions as exceptions + class TestException: def setUp(self): @@ -80,7 +81,7 @@ def test_version_1_is_recognized(self): @raises(SystemExit) @patch("os.path.exists") @patch("moban.main.handle_moban_file") - @patch("moban.reporter.report_error_message") + @patch("moban.externals.reporter.report_error_message") def test_directory_not_found( self, fake_reporter, fake_moban_file, fake_file ): @@ -96,7 +97,7 @@ def test_directory_not_found( @raises(SystemExit) @patch("os.path.exists") @patch("moban.main.handle_moban_file") - @patch("moban.reporter.report_error_message") + @patch("moban.externals.reporter.report_error_message") def test_no_third_party_engine( self, fake_reporter, fake_moban_file, fake_file ): @@ -112,7 +113,7 @@ def test_no_third_party_engine( @raises(SystemExit) @patch("os.path.exists") @patch("moban.main.handle_moban_file") - @patch("moban.reporter.report_error_message") + @patch("moban.externals.reporter.report_error_message") def test_double_underscore_main( self, fake_reporter, fake_moban_file, fake_file ): @@ -176,7 +177,7 @@ def test_handle_single_change(self, fake_find_file, fake_command_line): class TestFinder: def setUp(self): - self.patcher = patch("moban.file_system.exists") + self.patcher = patch("moban.externals.file_system.exists") self.fake_file_existence = self.patcher.start() self.fake_file_existence.__name__ = "fake" self.fake_file_existence.__module__ = "fake" diff --git a/tests/test_regression.py b/tests/test_regression.py index 85ab9a48..a91acabd 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -4,8 +4,8 @@ import fs.path from mock import patch -from moban.main import main +from moban.main import main from .utils import Docs diff --git a/tests/test_reporter.py b/tests/test_reporter.py index 4a62e029..6450e9b1 100644 --- a/tests/test_reporter.py +++ b/tests/test_reporter.py @@ -1,9 +1,10 @@ import sys -import moban.reporter as reporter from mock import patch from nose.tools import eq_ +from moban.externals import reporter + PY2 = sys.version_info[0] == 2 if PY2: from StringIO import StringIO diff --git a/tests/test_utils.py b/tests/test_utils.py deleted file mode 100644 index ab395fe6..00000000 --- a/tests/test_utils.py +++ /dev/null @@ -1,23 +0,0 @@ -import os -from shutil import rmtree - -from mock import patch -from moban.utils import mkdir_p - - -def test_mkdir_p(): - test_path = "a/b/c/d" - mkdir_p(test_path) - assert os.path.exists(test_path) - rmtree(test_path) - - -@patch("subprocess.check_call") -def test_pip_install(fake_check_all): - import sys - from moban.deprecated import pip_install - - pip_install(["package1", "package2"]) - fake_check_all.assert_called_with( - [sys.executable, "-m", "pip", "install", "package1 package2"] - ) diff --git a/tests/utils.py b/tests/utils.py index 986951ed..9f9983c4 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -3,11 +3,12 @@ from textwrap import dedent from mock import patch -from moban import file_system -from moban.main import main from nose.tools import eq_ from fs.opener.parse import parse_fs_url +from moban.main import main +from moban.externals import file_system + def verify_content(file_name, expected): with open(file_name, "r") as f: