From 57159331c5f2ab509c533162f0e0a5a9290c6cdd Mon Sep 17 00:00:00 2001 From: chfw Date: Sun, 6 Oct 2019 21:49:50 +0100 Subject: [PATCH 01/11] :books: add migration notes. #322 --- docs/index.rst | 8 ++++++++ docs/migration-notes.rst | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 docs/migration-notes.rst diff --git a/docs/index.rst b/docs/index.rst index d5a85674..e5deaaf5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -48,6 +48,14 @@ Developer Guide .. include:: ../CHANGELOG.rst +Migration Notes +================================================================================ + +.. toctree:: + + migration-note + + Indices and tables ================== 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. From dc8ab9593b4f0960f9c1d009dd1145a6a2ab8b2b Mon Sep 17 00:00:00 2001 From: chfw Date: Sun, 6 Oct 2019 22:43:22 +0100 Subject: [PATCH 02/11] :tractor: relocate files for coherence --- moban/constants.py | 2 +- moban/copy.py | 3 ++- moban/core/context.py | 3 ++- moban/core/moban_factory.py | 5 +++-- moban/data_loaders/json_loader.py | 2 +- moban/data_loaders/manager.py | 3 ++- moban/data_loaders/yaml.py | 2 +- moban/deprecated/__init__.py | 3 ++- moban/deprecated/repo.py | 3 ++- moban/{ => externals}/buffered_writer.py | 3 ++- moban/{ => externals}/file_system.py | 0 moban/{ => externals}/reporter.py | 0 moban/hashstore.py | 3 ++- moban/jinja2/engine.py | 3 ++- moban/main.py | 11 ++--------- moban/mobanfile/__init__.py | 3 ++- moban/mobanfile/targets.py | 3 ++- moban/mobanfile/templates.py | 3 ++- moban/utils.py | 3 ++- rnd_requirements.txt | 3 --- tests/integration_tests/test_command_line_options.py | 2 +- tests/mobanfile/test_templates.py | 4 ++-- tests/test_buffered_writer.py | 4 ++-- tests/test_copy_engine.py | 2 +- tests/test_file_system.py | 2 +- tests/test_hash_store.py | 2 +- tests/test_main.py | 8 ++++---- tests/test_reporter.py | 2 +- tests/utils.py | 2 +- 29 files changed, 46 insertions(+), 43 deletions(-) rename moban/{ => externals}/buffered_writer.py (95%) rename moban/{ => externals}/file_system.py (100%) rename moban/{ => externals}/reporter.py (100%) 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/copy.py b/moban/copy.py index e617366a..fe9d22c4 100644 --- a/moban/copy.py +++ b/moban/copy.py @@ -1,5 +1,6 @@ -from moban import constants, file_system +from moban import constants from lml.plugin import PluginInfo +from moban.externals import file_system @PluginInfo( diff --git a/moban/core/context.py b/moban/core/context.py index 10ce96f0..6a9a235f 100644 --- a/moban/core/context.py +++ b/moban/core/context.py @@ -1,7 +1,8 @@ import os import copy -from moban import utils, reporter, constants, exceptions +from moban import utils, constants, exceptions +from moban.externals import reporter from moban.program_options import OPTIONS from moban.data_loaders.manager import merge, load_data diff --git a/moban/core/moban_factory.py b/moban/core/moban_factory.py index e430f097..47aae88d 100644 --- a/moban/core/moban_factory.py +++ b/moban/core/moban_factory.py @@ -3,14 +3,15 @@ import logging from collections import defaultdict -from moban import utils, reporter, constants, exceptions, file_system +from moban import utils, constants, exceptions from fs.errors import ResourceNotFound from lml.plugin import PluginManager +from moban.externals import reporter, file_system from moban.hashstore import HASH_STORE 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.externals.buffered_writer import BufferedWriter log = logging.getLogger(__name__) PY3_ABOVE = sys.version_info[0] > 2 diff --git a/moban/data_loaders/json_loader.py b/moban/data_loaders/json_loader.py index 6393af47..2069ad78 100644 --- a/moban/data_loaders/json_loader.py +++ b/moban/data_loaders/json_loader.py @@ -2,7 +2,7 @@ from moban import constants from lml.plugin import PluginInfo -from moban.file_system import open_file +from moban.externals.file_system import open_file @PluginInfo(constants.DATA_LOADER_EXTENSION, tags=["json"]) diff --git a/moban/data_loaders/manager.py b/moban/data_loaders/manager.py index 6c7a9097..e1b75f0b 100644 --- a/moban/data_loaders/manager.py +++ b/moban/data_loaders/manager.py @@ -2,8 +2,9 @@ import moban.data_loaders.yaml # noqa: F401 import moban.data_loaders.json_loader # noqa: F401 -from moban import constants, file_system +from moban import constants from lml.plugin import PluginManager +from moban.externals import file_system class AnyDataLoader(PluginManager): diff --git a/moban/data_loaders/yaml.py b/moban/data_loaders/yaml.py index f082730c..bfa41185 100644 --- a/moban/data_loaders/yaml.py +++ b/moban/data_loaders/yaml.py @@ -1,7 +1,7 @@ from moban import constants from lml.plugin import PluginInfo from ruamel.yaml import YAML -from moban.file_system import open_file +from moban.externals.file_system import open_file @PluginInfo(constants.DATA_LOADER_EXTENSION, tags=["yaml", "yml"]) diff --git a/moban/deprecated/__init__.py b/moban/deprecated/__init__.py index a2218fbb..bea7c42a 100644 --- a/moban/deprecated/__init__.py +++ b/moban/deprecated/__init__.py @@ -1,7 +1,8 @@ import sys from functools import wraps -from moban import plugins, reporter, constants, file_system +from moban import plugins, constants +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/repo.py b/moban/deprecated/repo.py index 47c40635..4bcf822a 100644 --- a/moban/deprecated/repo.py +++ b/moban/deprecated/repo.py @@ -1,8 +1,9 @@ import sys import subprocess -from moban import reporter, constants, exceptions, file_system +from moban import constants, exceptions from moban.utils import mkdir_p +from moban.externals import reporter, file_system def git_clone(requires): diff --git a/moban/buffered_writer.py b/moban/externals/buffered_writer.py similarity index 95% rename from moban/buffered_writer.py rename to moban/externals/buffered_writer.py index ff980895..cb95e952 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 import utils +from moban.externals import file_system PY2 = sys.version_info[0] == 2 diff --git a/moban/file_system.py b/moban/externals/file_system.py similarity index 100% rename from moban/file_system.py rename to moban/externals/file_system.py diff --git a/moban/reporter.py b/moban/externals/reporter.py similarity index 100% rename from moban/reporter.py rename to moban/externals/reporter.py diff --git a/moban/hashstore.py b/moban/hashstore.py index 636e7165..3987ce65 100644 --- a/moban/hashstore.py +++ b/moban/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/jinja2/engine.py b/moban/jinja2/engine.py index 87aeb76d..eab7bc19 100644 --- a/moban/jinja2/engine.py +++ b/moban/jinja2/engine.py @@ -3,10 +3,11 @@ from importlib import import_module import fs.errors -from moban import constants, file_system +from moban import constants from jinja2 import Template, Environment from lml.loader import scan_plugins_regex from lml.plugin import PluginInfo, PluginManager +from moban.externals import file_system from jinja2.exceptions import TemplateNotFound from jinja2_fsloader import FSLoader diff --git a/moban/main.py b/moban/main.py index e855d5a5..217a9f04 100644 --- a/moban/main.py +++ b/moban/main.py @@ -14,16 +14,9 @@ import logging.config from collections import defaultdict -from moban import ( - core, - plugins, - reporter, - constants, - mobanfile, - exceptions, - file_system, -) +from moban import core, plugins, constants, mobanfile, exceptions from moban._version import __version__ +from moban.externals import reporter, file_system from moban.hashstore import HASH_STORE from moban.program_options import OPTIONS from moban.data_loaders.manager import merge, load_data diff --git a/moban/mobanfile/__init__.py b/moban/mobanfile/__init__.py index f3ae753d..a701bf7d 100644 --- a/moban/mobanfile/__init__.py +++ b/moban/mobanfile/__init__.py @@ -4,9 +4,10 @@ import logging from collections import OrderedDict -from moban import core, reporter, constants +from moban import core, constants from lml.utils import do_import from moban.utils import verify_the_existence_of_directories +from moban.externals import reporter from moban.deprecated import handle_copy, handle_requires from moban.mobanfile.targets import ( parse_targets, diff --git a/moban/mobanfile/targets.py b/moban/mobanfile/targets.py index 161de814..95dedd07 100644 --- a/moban/mobanfile/targets.py +++ b/moban/mobanfile/targets.py @@ -1,7 +1,8 @@ import uuid import logging -from moban import core, reporter, constants, exceptions +from moban import core, constants, exceptions +from moban.externals import reporter from moban.definitions import TemplateTarget from moban.mobanfile.templates import handle_template diff --git a/moban/mobanfile/templates.py b/moban/mobanfile/templates.py index 893ee09d..b344ec79 100644 --- a/moban/mobanfile/templates.py +++ b/moban/mobanfile/templates.py @@ -1,6 +1,7 @@ import logging -from moban import reporter, constants, file_system +from moban import constants +from moban.externals import reporter, file_system LOG = logging.getLogger(__name__) diff --git a/moban/utils.py b/moban/utils.py index 98672fed..281070da 100644 --- a/moban/utils.py +++ b/moban/utils.py @@ -2,7 +2,8 @@ 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__) 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/tests/integration_tests/test_command_line_options.py b/tests/integration_tests/test_command_line_options.py index 0a2bc8e7..bff71e67 100644 --- a/tests/integration_tests/test_command_line_options.py +++ b/tests/integration_tests/test_command_line_options.py @@ -23,7 +23,7 @@ def setUp(self): ) 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 = [ diff --git a/tests/mobanfile/test_templates.py b/tests/mobanfile/test_templates.py index bd07f6ff..cc50421b 100644 --- a/tests/mobanfile/test_templates.py +++ b/tests/mobanfile/test_templates.py @@ -15,7 +15,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 +64,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..3a6433c3 100644 --- a/tests/test_buffered_writer.py +++ b/tests/test_buffered_writer.py @@ -1,9 +1,9 @@ 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..830f595c 100644 --- a/tests/test_copy_engine.py +++ b/tests/test_copy_engine.py @@ -1,9 +1,9 @@ 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 class TestContentForwardEngine: diff --git a/tests/test_file_system.py b/tests/test_file_system.py index 5b2eb26b..c13a000c 100644 --- a/tests/test_file_system.py +++ b/tests/test_file_system.py @@ -3,8 +3,8 @@ import stat 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" diff --git a/tests/test_hash_store.py b/tests/test_hash_store.py index 3a8d5ae9..06725abc 100644 --- a/tests/test_hash_store.py +++ b/tests/test_hash_store.py @@ -2,7 +2,7 @@ import sys from nose import SkipTest -from moban import file_system +from moban.externals import file_system from moban.hashstore import HashStore diff --git a/tests/test_main.py b/tests/test_main.py index 0de35825..bf4976ea 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -80,7 +80,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 +96,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 +112,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 +176,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_reporter.py b/tests/test_reporter.py index 4a62e029..785419e6 100644 --- a/tests/test_reporter.py +++ b/tests/test_reporter.py @@ -1,8 +1,8 @@ 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: diff --git a/tests/utils.py b/tests/utils.py index 986951ed..c02c94c1 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -3,10 +3,10 @@ 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.externals import file_system def verify_content(file_name, expected): From 17ab1767f42b2034a942741222914e9acde9cbd4 Mon Sep 17 00:00:00 2001 From: chfw Date: Sun, 6 Oct 2019 22:49:57 +0100 Subject: [PATCH 03/11] :tractor: relocated plugins.py --- moban/{ => core}/plugins.py | 0 moban/deprecated/__init__.py | 3 ++- moban/main.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) rename moban/{ => core}/plugins.py (100%) diff --git a/moban/plugins.py b/moban/core/plugins.py similarity index 100% rename from moban/plugins.py rename to moban/core/plugins.py diff --git a/moban/deprecated/__init__.py b/moban/deprecated/__init__.py index bea7c42a..476350d4 100644 --- a/moban/deprecated/__init__.py +++ b/moban/deprecated/__init__.py @@ -1,7 +1,8 @@ import sys from functools import wraps -from moban import plugins, constants +from moban.core import plugins +from moban import constants from moban.externals import reporter, file_system from moban.deprecated import repo from moban.deprecated.repo import git_clone diff --git a/moban/main.py b/moban/main.py index 217a9f04..bbbf4ab4 100644 --- a/moban/main.py +++ b/moban/main.py @@ -14,7 +14,7 @@ import logging.config from collections import defaultdict -from moban import core, plugins, constants, mobanfile, exceptions +from moban import core, constants, mobanfile, exceptions from moban._version import __version__ from moban.externals import reporter, file_system from moban.hashstore import HASH_STORE @@ -267,7 +267,7 @@ def find_default_moban_file(): def load_engine_factory_and_engines(): - plugins.make_sure_all_pkg_are_loaded() + core.plugins.make_sure_all_pkg_are_loaded() def handle_custom_variables(list_of_definitions): From a93c04f80bfec6323d3c4659c2145599e8814bee Mon Sep 17 00:00:00 2001 From: chfw Date: Sun, 6 Oct 2019 22:56:24 +0100 Subject: [PATCH 04/11] :tractor: grouped all plugins to plugins directory --- .../custom-jj2-plugin/filter.py | 2 +- .../custom-jj2-plugin/global.py | 2 +- .../custom-jj2-plugin/test.py | 2 +- moban/core/plugins.py | 8 ++++---- moban/data_loaders/manager.py | 2 -- moban/deprecated/__init__.py | 2 +- moban/{ => plugins}/copy.py | 0 moban/{ => plugins}/jinja2/__init__.py | 0 moban/{ => plugins}/jinja2/engine.py | 0 moban/{ => plugins}/jinja2/extensions.py | 0 moban/{ => plugins}/jinja2/filters/__init__.py | 0 moban/{ => plugins}/jinja2/filters/github.py | 0 moban/{ => plugins}/jinja2/filters/repr.py | 0 moban/{ => plugins}/jinja2/filters/text.py | 0 moban/{ => plugins}/jinja2/tests/__init__.py | 0 moban/{ => plugins}/jinja2/tests/files.py | 0 moban/{ => plugins}/jinja2/tests/win32.py | 0 moban/{data_loaders => plugins}/json_loader.py | 0 moban/{data_loaders/yaml.py => plugins/yaml_loader.py} | 0 tests/test_copy_engine.py | 2 +- 20 files changed, 9 insertions(+), 11 deletions(-) rename moban/{ => plugins}/copy.py (100%) rename moban/{ => plugins}/jinja2/__init__.py (100%) rename moban/{ => plugins}/jinja2/engine.py (100%) rename moban/{ => plugins}/jinja2/extensions.py (100%) rename moban/{ => plugins}/jinja2/filters/__init__.py (100%) rename moban/{ => plugins}/jinja2/filters/github.py (100%) rename moban/{ => plugins}/jinja2/filters/repr.py (100%) rename moban/{ => plugins}/jinja2/filters/text.py (100%) rename moban/{ => plugins}/jinja2/tests/__init__.py (100%) rename moban/{ => plugins}/jinja2/tests/files.py (100%) rename moban/{ => plugins}/jinja2/tests/win32.py (100%) rename moban/{data_loaders => plugins}/json_loader.py (100%) rename moban/{data_loaders/yaml.py => plugins/yaml_loader.py} (100%) 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/moban/core/plugins.py b/moban/core/plugins.py index 88ce7f65..70e7281c 100644 --- a/moban/core/plugins.py +++ b/moban/core/plugins.py @@ -2,10 +2,10 @@ from lml.loader import scan_plugins_regex 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/data_loaders/manager.py b/moban/data_loaders/manager.py index e1b75f0b..35cf8bdd 100644 --- a/moban/data_loaders/manager.py +++ b/moban/data_loaders/manager.py @@ -1,7 +1,5 @@ from collections import OrderedDict -import moban.data_loaders.yaml # noqa: F401 -import moban.data_loaders.json_loader # noqa: F401 from moban import constants from lml.plugin import PluginManager from moban.externals import file_system diff --git a/moban/deprecated/__init__.py b/moban/deprecated/__init__.py index 476350d4..2751b422 100644 --- a/moban/deprecated/__init__.py +++ b/moban/deprecated/__init__.py @@ -1,8 +1,8 @@ import sys from functools import wraps -from moban.core import plugins 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 diff --git a/moban/copy.py b/moban/plugins/copy.py similarity index 100% rename from moban/copy.py rename to moban/plugins/copy.py diff --git a/moban/jinja2/__init__.py b/moban/plugins/jinja2/__init__.py similarity index 100% rename from moban/jinja2/__init__.py rename to moban/plugins/jinja2/__init__.py diff --git a/moban/jinja2/engine.py b/moban/plugins/jinja2/engine.py similarity index 100% rename from moban/jinja2/engine.py rename to moban/plugins/jinja2/engine.py diff --git a/moban/jinja2/extensions.py b/moban/plugins/jinja2/extensions.py similarity index 100% rename from moban/jinja2/extensions.py rename to moban/plugins/jinja2/extensions.py diff --git a/moban/jinja2/filters/__init__.py b/moban/plugins/jinja2/filters/__init__.py similarity index 100% rename from moban/jinja2/filters/__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 100% rename from moban/jinja2/filters/github.py rename to moban/plugins/jinja2/filters/github.py diff --git a/moban/jinja2/filters/repr.py b/moban/plugins/jinja2/filters/repr.py similarity index 100% rename from moban/jinja2/filters/repr.py rename to moban/plugins/jinja2/filters/repr.py diff --git a/moban/jinja2/filters/text.py b/moban/plugins/jinja2/filters/text.py similarity index 100% rename from moban/jinja2/filters/text.py rename to moban/plugins/jinja2/filters/text.py diff --git a/moban/jinja2/tests/__init__.py b/moban/plugins/jinja2/tests/__init__.py similarity index 100% rename from moban/jinja2/tests/__init__.py rename to moban/plugins/jinja2/tests/__init__.py diff --git a/moban/jinja2/tests/files.py b/moban/plugins/jinja2/tests/files.py similarity index 100% rename from moban/jinja2/tests/files.py rename to moban/plugins/jinja2/tests/files.py 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 100% rename from moban/data_loaders/json_loader.py rename to moban/plugins/json_loader.py diff --git a/moban/data_loaders/yaml.py b/moban/plugins/yaml_loader.py similarity index 100% rename from moban/data_loaders/yaml.py rename to moban/plugins/yaml_loader.py diff --git a/tests/test_copy_engine.py b/tests/test_copy_engine.py index 830f595c..2acf40e8 100644 --- a/tests/test_copy_engine.py +++ b/tests/test_copy_engine.py @@ -1,9 +1,9 @@ import os import fs.path -from moban.copy import ContentForwardEngine from nose.tools import eq_ from moban.externals import file_system +from moban.plugins.copy import ContentForwardEngine class TestContentForwardEngine: From 7baceedb76671536e208cfa18fba43e5db8c862b Mon Sep 17 00:00:00 2001 From: chfw Date: Sun, 6 Oct 2019 22:59:57 +0100 Subject: [PATCH 05/11] :tractor: relocated data loader manager to core folder --- moban/core/context.py | 2 +- moban/{data_loaders/manager.py => core/data_loader.py} | 0 moban/data_loaders/__init__.py | 0 moban/main.py | 2 +- moban/mobanfile/__init__.py | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) rename moban/{data_loaders/manager.py => core/data_loader.py} (100%) delete mode 100644 moban/data_loaders/__init__.py diff --git a/moban/core/context.py b/moban/core/context.py index 6a9a235f..b1d3e4ee 100644 --- a/moban/core/context.py +++ b/moban/core/context.py @@ -4,7 +4,7 @@ from moban import utils, constants, exceptions 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 100% rename from moban/data_loaders/manager.py rename to moban/core/data_loader.py diff --git a/moban/data_loaders/__init__.py b/moban/data_loaders/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/moban/main.py b/moban/main.py index bbbf4ab4..55c1c9bc 100644 --- a/moban/main.py +++ b/moban/main.py @@ -19,7 +19,7 @@ from moban.externals import reporter, file_system from moban.hashstore import HASH_STORE from moban.program_options import OPTIONS -from moban.data_loaders.manager import merge, load_data +from moban.core.data_loader import merge, load_data LOG = logging.getLogger() LOG_LEVEL = [logging.WARNING, logging.INFO, logging.DEBUG] diff --git a/moban/mobanfile/__init__.py b/moban/mobanfile/__init__.py index a701bf7d..8e1911ef 100644 --- a/moban/mobanfile/__init__.py +++ b/moban/mobanfile/__init__.py @@ -15,7 +15,7 @@ extract_group_targets, ) from moban.core.moban_factory import expand_template_directories -from moban.data_loaders.manager import merge +from moban.core.data_loader import merge LOG = logging.getLogger(__name__) From a714bfbe2b786d29dd05ea569f6f5cdce3a60b3b Mon Sep 17 00:00:00 2001 From: chfw Date: Sun, 6 Oct 2019 23:06:26 +0100 Subject: [PATCH 06/11] :tractor: relocated definitions to core folder --- moban/{ => core}/definitions.py | 0 moban/externals/__init__.py | 0 moban/mobanfile/__init__.py | 2 +- moban/mobanfile/targets.py | 2 +- tests/integration_tests/test_command_line_options.py | 2 +- tests/mobanfile/test_mobanfile.py | 2 +- tests/mobanfile/test_targets.py | 2 +- tests/test_definitions.py | 2 +- 8 files changed, 6 insertions(+), 6 deletions(-) rename moban/{ => core}/definitions.py (100%) create mode 100644 moban/externals/__init__.py diff --git a/moban/definitions.py b/moban/core/definitions.py similarity index 100% rename from moban/definitions.py rename to moban/core/definitions.py diff --git a/moban/externals/__init__.py b/moban/externals/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/moban/mobanfile/__init__.py b/moban/mobanfile/__init__.py index 8e1911ef..1fe00ccd 100644 --- a/moban/mobanfile/__init__.py +++ b/moban/mobanfile/__init__.py @@ -9,13 +9,13 @@ from moban.utils import verify_the_existence_of_directories from moban.externals import reporter from moban.deprecated import handle_copy, handle_requires +from moban.core.data_loader import merge from moban.mobanfile.targets import ( parse_targets, extract_target, extract_group_targets, ) from moban.core.moban_factory import expand_template_directories -from moban.core.data_loader import merge LOG = logging.getLogger(__name__) diff --git a/moban/mobanfile/targets.py b/moban/mobanfile/targets.py index 95dedd07..caa54812 100644 --- a/moban/mobanfile/targets.py +++ b/moban/mobanfile/targets.py @@ -3,7 +3,7 @@ from moban import core, constants, exceptions from moban.externals import reporter -from moban.definitions import TemplateTarget +from moban.core.definitions import TemplateTarget from moban.mobanfile.templates import handle_template LOG = logging.getLogger(__name__) diff --git a/tests/integration_tests/test_command_line_options.py b/tests/integration_tests/test_command_line_options.py index bff71e67..ff0f766b 100644 --- a/tests/integration_tests/test_command_line_options.py +++ b/tests/integration_tests/test_command_line_options.py @@ -5,7 +5,7 @@ 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 diff --git a/tests/mobanfile/test_mobanfile.py b/tests/mobanfile/test_mobanfile.py index db8c11b7..7d4c807a 100644 --- a/tests/mobanfile/test_mobanfile.py +++ b/tests/mobanfile/test_mobanfile.py @@ -1,7 +1,7 @@ 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") diff --git a/tests/mobanfile/test_targets.py b/tests/mobanfile/test_targets.py index dff5c850..23873aaa 100644 --- a/tests/mobanfile/test_targets.py +++ b/tests/mobanfile/test_targets.py @@ -4,7 +4,7 @@ from nose.tools import eq_, raises from moban.mobanfile import targets from moban.exceptions import GroupTargetNotFound -from moban.definitions import TemplateTarget +from moban.core.definitions import TemplateTarget TEMPLATE = "a.jj2" OUTPUT = "a.output" diff --git a/tests/test_definitions.py b/tests/test_definitions.py index 98a78741..b70639cd 100644 --- a/tests/test_definitions.py +++ b/tests/test_definitions.py @@ -1,6 +1,6 @@ from nose.tools import eq_ from moban.deprecated import GitRequire -from moban.definitions import TemplateTarget +from moban.core.definitions import TemplateTarget def test_git_require_repr(): From 2534afd4a0744f4b2701285fead9fb740e10ecbd Mon Sep 17 00:00:00 2001 From: chfw Date: Sun, 6 Oct 2019 23:08:43 +0100 Subject: [PATCH 07/11] :tractor: relocated hashstore to core folder --- moban/{ => core}/hashstore.py | 0 moban/core/moban_factory.py | 2 +- moban/main.py | 2 +- tests/test_hash_store.py | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename moban/{ => core}/hashstore.py (100%) diff --git a/moban/hashstore.py b/moban/core/hashstore.py similarity index 100% rename from moban/hashstore.py rename to moban/core/hashstore.py diff --git a/moban/core/moban_factory.py b/moban/core/moban_factory.py index 47aae88d..478c31ad 100644 --- a/moban/core/moban_factory.py +++ b/moban/core/moban_factory.py @@ -7,7 +7,7 @@ from fs.errors import ResourceNotFound from lml.plugin import PluginManager from moban.externals import reporter, file_system -from moban.hashstore import HASH_STORE +from moban.core.hashstore import HASH_STORE from moban.deprecated import deprecated_moban_path_notation from moban.core.context import Context from moban.core.strategy import Strategy diff --git a/moban/main.py b/moban/main.py index 55c1c9bc..ba1adf8a 100644 --- a/moban/main.py +++ b/moban/main.py @@ -17,7 +17,7 @@ from moban import core, constants, mobanfile, exceptions from moban._version import __version__ from moban.externals import reporter, file_system -from moban.hashstore import HASH_STORE +from moban.core.hashstore import HASH_STORE from moban.program_options import OPTIONS from moban.core.data_loader import merge, load_data diff --git a/tests/test_hash_store.py b/tests/test_hash_store.py index 06725abc..173b244b 100644 --- a/tests/test_hash_store.py +++ b/tests/test_hash_store.py @@ -3,7 +3,7 @@ from nose import SkipTest from moban.externals import file_system -from moban.hashstore import HashStore +from moban.core.hashstore import HashStore class TestHashStore: From 1cfe11a57b6093aedb8161de027a8e5bb2d476c1 Mon Sep 17 00:00:00 2001 From: chfw Date: Sun, 6 Oct 2019 23:11:37 +0100 Subject: [PATCH 08/11] :green_heart: enable plugins to be found as module --- moban/plugins/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 moban/plugins/__init__.py diff --git a/moban/plugins/__init__.py b/moban/plugins/__init__.py new file mode 100644 index 00000000..e69de29b From 903534a1fc3aad4e3404f2619d7178a0e961b3bf Mon Sep 17 00:00:00 2001 From: chfw Date: Sun, 6 Oct 2019 23:16:19 +0100 Subject: [PATCH 09/11] :shirt: update coding style --- moban/core/moban_factory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moban/core/moban_factory.py b/moban/core/moban_factory.py index 478c31ad..66d7e57e 100644 --- a/moban/core/moban_factory.py +++ b/moban/core/moban_factory.py @@ -7,10 +7,10 @@ from fs.errors import ResourceNotFound from lml.plugin import PluginManager from moban.externals import reporter, file_system -from moban.core.hashstore import HASH_STORE from moban.deprecated import deprecated_moban_path_notation from moban.core.context import Context from moban.core.strategy import Strategy +from moban.core.hashstore import HASH_STORE from moban.externals.buffered_writer import BufferedWriter log = logging.getLogger(__name__) From 5e6ae5e80451ca6953d7ecb9498445e076bd070b Mon Sep 17 00:00:00 2001 From: chfw Date: Sun, 6 Oct 2019 23:27:40 +0100 Subject: [PATCH 10/11] :green_heart: update hardcode references --- moban/plugins/jinja2/engine.py | 8 ++++---- moban/plugins/jinja2/filters/github.py | 2 +- moban/plugins/jinja2/filters/repr.py | 2 +- moban/plugins/jinja2/filters/text.py | 2 +- moban/plugins/jinja2/tests/files.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/moban/plugins/jinja2/engine.py b/moban/plugins/jinja2/engine.py index eab7bc19..df44a23b 100644 --- a/moban/plugins/jinja2/engine.py +++ b/moban/plugins/jinja2/engine.py @@ -14,10 +14,10 @@ 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/plugins/jinja2/filters/github.py b/moban/plugins/jinja2/filters/github.py index 5a12972a..815627e6 100644 --- a/moban/plugins/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/plugins/jinja2/filters/repr.py b/moban/plugins/jinja2/filters/repr.py index 3f278915..e0fd304e 100644 --- a/moban/plugins/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/plugins/jinja2/filters/text.py b/moban/plugins/jinja2/filters/text.py index 19c529e1..801a607f 100644 --- a/moban/plugins/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/files.py b/moban/plugins/jinja2/tests/files.py index f5977627..471a0b56 100644 --- a/moban/plugins/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 From dc35e57847a0d7ac6cf6bb02658bfc8a531758cc Mon Sep 17 00:00:00 2001 From: chfw Date: Sun, 6 Oct 2019 23:39:52 +0100 Subject: [PATCH 11/11] :tractor: relocate utils --- moban/core/context.py | 3 ++- moban/core/moban_factory.py | 3 ++- moban/{ => core}/utils.py | 0 moban/deprecated/repo.py | 2 +- moban/externals/buffered_writer.py | 2 +- moban/mobanfile/__init__.py | 2 +- .../test_command_line_options.py | 23 +++++++++++-------- tests/test_utils.py | 2 +- 8 files changed, 21 insertions(+), 16 deletions(-) rename moban/{ => core}/utils.py (100%) diff --git a/moban/core/context.py b/moban/core/context.py index b1d3e4ee..50d0ec4c 100644 --- a/moban/core/context.py +++ b/moban/core/context.py @@ -1,7 +1,8 @@ import os import copy -from moban import utils, 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.core.data_loader import merge, load_data diff --git a/moban/core/moban_factory.py b/moban/core/moban_factory.py index 66d7e57e..128483a4 100644 --- a/moban/core/moban_factory.py +++ b/moban/core/moban_factory.py @@ -3,9 +3,10 @@ import logging from collections import defaultdict -from moban import utils, constants, exceptions +from moban import constants, exceptions from fs.errors import ResourceNotFound from lml.plugin import PluginManager +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 diff --git a/moban/utils.py b/moban/core/utils.py similarity index 100% rename from moban/utils.py rename to moban/core/utils.py diff --git a/moban/deprecated/repo.py b/moban/deprecated/repo.py index 4bcf822a..8a854697 100644 --- a/moban/deprecated/repo.py +++ b/moban/deprecated/repo.py @@ -2,8 +2,8 @@ import subprocess from moban import constants, exceptions -from moban.utils import mkdir_p from moban.externals import reporter, file_system +from moban.core.utils import mkdir_p def git_clone(requires): diff --git a/moban/externals/buffered_writer.py b/moban/externals/buffered_writer.py index cb95e952..10f325e0 100644 --- a/moban/externals/buffered_writer.py +++ b/moban/externals/buffered_writer.py @@ -3,7 +3,7 @@ import fs import fs.path -from moban import utils +from moban.core import utils from moban.externals import file_system PY2 = sys.version_info[0] == 2 diff --git a/moban/mobanfile/__init__.py b/moban/mobanfile/__init__.py index 1fe00ccd..58e42bbb 100644 --- a/moban/mobanfile/__init__.py +++ b/moban/mobanfile/__init__.py @@ -6,8 +6,8 @@ from moban import core, constants from lml.utils import do_import -from moban.utils import verify_the_existence_of_directories 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.core.data_loader import merge from moban.mobanfile.targets import ( diff --git a/tests/integration_tests/test_command_line_options.py b/tests/integration_tests/test_command_line_options.py index ff0f766b..d3334ae2 100644 --- a/tests/integration_tests/test_command_line_options.py +++ b/tests/integration_tests/test_command_line_options.py @@ -19,7 +19,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() @@ -77,7 +77,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 +130,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 +221,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 +259,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 +294,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 +325,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 +388,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 +463,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 +484,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/test_utils.py b/tests/test_utils.py index ab395fe6..2c0ef8e8 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -2,7 +2,7 @@ from shutil import rmtree from mock import patch -from moban.utils import mkdir_p +from moban.core.utils import mkdir_p def test_mkdir_p():