Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release 0.4.3 #264

Merged
merged 10 commits into from
Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
name: moban
organisation: moremoban
releases:
- changes:
- action: Removed
details:
- "`#253`: symbolic link in regression pack causes python setup.py to do recursive include"
- action: Added
details:
- "`#209`: Alert moban user when `git` is not available and is used."
- action: Updated
details:
- "`#261`: since moban group template files per template type, this fill use first come first register to order moban group"
date: 16.03.2019
version: 0.4.3
- changes:
- action: Added
details:
- "`#234`: Define template parameters on the fly inside `targets` section"
- "`#180`: No longer two statistics will be shown in v0.4.x. legacy copy targets are injected into a normal targets. cli target is made a clear priority."
- "`#62`: select a group target to run"
- action: Updated
details:
- "`#180`: No longer two statistics will be shown in v0.4.x. legacy copy targets are injected into a normal targets. cli target is made a clear priority."
- "`#244`: version 0.4.2 is first version which would work perfectly on windows since 17 Nov 2018. Note that: file permissions are not used on windows. Why the date? because samefile is not avaiable on windows, causing unit tests to fail hence it lead to my conclusion that moban version between 17 Nov 2018 and March 2019 wont work well on Windows."
date: 08.03.2019
version: 0.4.2
Expand All @@ -21,7 +35,7 @@ releases:
- action: Added
details:
- "`#165`: Copy as plugins"
- action: Added
- action: Updated
details:
- "`#219`: git clone depth set to 2"
- "`#186`: lowest dependecy on ruamel.yaml is 0.15.5, Jun 2017"
Expand Down
6 changes: 3 additions & 3 deletions .moban.cd/moban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ organisation: moremoban
author: C. W.
contact: wangc_2011@hotmail.com
license: MIT
version: 0.4.2
current_version: 0.4.2
release: 0.4.2
version: 0.4.3
current_version: 0.4.3
release: 0.4.3
branch: master
master: index
command_line_interface: "moban"
Expand Down
32 changes: 29 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
Change log
================================================================================

0.4.3 - 16.03.2019
--------------------------------------------------------------------------------

Removed
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `#253 <https://github.com/moremoban/moban/issues/253>`_: symbolic link in
regression pack causes python setup.py to do recursive include

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

#. `#209 <https://github.com/moremoban/moban/issues/209>`_: Alert moban user
when `git` is not available and is used.

Updated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `#261 <https://github.com/moremoban/moban/issues/261>`_: since moban group
template files per template type, this fill use first come first register to
order moban group

0.4.2 - 08.03.2019
--------------------------------------------------------------------------------

Expand All @@ -9,11 +31,15 @@ Added

#. `#234 <https://github.com/moremoban/moban/issues/234>`_: Define template
parameters on the fly inside `targets` section
#. `#62 <https://github.com/moremoban/moban/issues/62>`_: select a group target
to run

Updated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `#180 <https://github.com/moremoban/moban/issues/180>`_: No longer two
statistics will be shown in v0.4.x. legacy copy targets are injected into a
normal targets. cli target is made a clear priority.
#. `#62 <https://github.com/moremoban/moban/issues/62>`_: select a group target
to run
#. `#244 <https://github.com/moremoban/moban/issues/244>`_: version 0.4.2 is
first version which would work perfectly on windows since 17 Nov 2018. Note
that: file permissions are not used on windows. Why the date? because
Expand Down Expand Up @@ -42,7 +68,7 @@ Added

#. `#165 <https://github.com/moremoban/moban/issues/165>`_: Copy as plugins

Added
Updated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `#219 <https://github.com/moremoban/moban/issues/219>`_: git clone depth set
Expand Down
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ moban - 模板 Yet another jinja2 cli command for static text generation


**moban** brings the high performance template engine (JINJA2) for web into
static text generation. It is used in pyexcel project to keep documentation
static text generation. It is used in `pyexcel` and `coala` project to keep documentation
consistent across the documentations of individual libraries.

Our vision is: any template, any data. Our current architecture enables moban
to plugin any python template engine: mako, handlebars, velocity, haml, slim and tornado
and to plugin any data format: json and yaml. Please look at our issues. We have many
more template engines and data format on the road map.

Installation
================================================================================
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
copyright = '2017-2019 Onni Software Ltd. and its contributors'
author = 'Onni Software Ltd.'
# The short X.Y version
version = '0.4.2'
version = '0.4.3'
# The full version, including alpha/beta/rc tags
release = '0.4.2'
release = '0.4.3'

# -- General configuration ---------------------------------------------------

Expand Down
7 changes: 0 additions & 7 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ examples folder.
level-18-user-defined-template-types/README.rst
level-19-moban-a-sub-group-in-targets/README.rst

In pratice, the following use cases were found interesting to go along with.

.. toctree::
:maxdepth: 1

misc-1-copying-templates/README.rst


For more complex use case, please look at `its usage in pyexcel project <http://pyexcel.readthedocs.io/en/latest/guide.html>`_

Expand Down
2 changes: 1 addition & 1 deletion moban/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.4.2"
__version__ = "0.4.3"
__author__ = "C. W."
4 changes: 4 additions & 0 deletions moban/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ class IncorrectDataInput(Exception):

class GroupTargetNotFound(Exception):
pass


class NoGitCommand(Exception):
pass
7 changes: 5 additions & 2 deletions moban/mobanfile/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import re
import sys
from collections import defaultdict
from collections import OrderedDict

from lml.utils import do_import

Expand Down Expand Up @@ -112,7 +112,7 @@ def _iterate_list_of_dicts(list_of_dict):

def handle_targets(merged_options, targets):
list_of_templating_parameters = parse_targets(merged_options, targets)
jobs_for_each_engine = defaultdict(list)
jobs_for_each_engine = OrderedDict()

for target in list_of_templating_parameters:
forced_template_type = merged_options.get(
Expand All @@ -129,6 +129,9 @@ def handle_targets(merged_options, targets):
]
target.set_template_type(primary_template_type)

if primary_template_type not in jobs_for_each_engine:
jobs_for_each_engine[primary_template_type] = []

jobs_for_each_engine[primary_template_type].append(target)

count = 0
Expand Down
17 changes: 16 additions & 1 deletion moban/repo.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import os
import sys
import subprocess

from moban import reporter, constants
from moban import reporter, constants, exceptions
from moban.utils import mkdir_p


def git_clone(requires):
from git import Repo

if sys.platform != "win32":
# Unfortunately for windows user, the following function
# needs shell=True, which expose security risk. I would
# rather not to trade it with its marginal benefit
make_sure_git_is_available()

moban_home = get_moban_home()
mkdir_p(moban_home)

Expand Down Expand Up @@ -51,3 +59,10 @@ def get_moban_home():

home_dir = user_cache_dir(appname=constants.PROGRAM_NAME)
return os.path.join(home_dir, constants.MOBAN_REPOS_DIR_NAME)


def make_sure_git_is_available():
try:
subprocess.check_output(["git", "--help"])
except Exception:
raise exceptions.NoGitCommand("Please install git command")
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

NAME = 'moban'
AUTHOR = 'C. W.'
VERSION = '0.4.2'
VERSION = '0.4.3'
EMAIL = 'wangc_2011@hotmail.com'
LICENSE = 'MIT'
ENTRY_POINTS = {
Expand All @@ -41,7 +41,7 @@
'Yet another jinja2 cli command for static text generation'
)
URL = 'https://github.com/moremoban/moban'
DOWNLOAD_URL = '%s/archive/0.4.2.tar.gz' % URL
DOWNLOAD_URL = '%s/archive/0.4.3.tar.gz' % URL
FILES = ['README.rst', 'CONTRIBUTORS.rst', 'CHANGELOG.rst']
KEYWORDS = [
'python',
Expand Down Expand Up @@ -79,8 +79,8 @@
# You do not need to read beyond this line
PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi'.format(
sys.executable)
GS_COMMAND = ('gs moban v0.4.2 ' +
"Find 0.4.2 in changelog for more details")
GS_COMMAND = ('gs moban v0.4.3 ' +
"Find 0.4.3 in changelog for more details")
NO_GS_MESSAGE = ('Automatic github release is disabled. ' +
'Please install gease to enable it.')
UPLOAD_FAILED_MSG = (
Expand Down
Empty file.
Empty file.
42 changes: 42 additions & 0 deletions tests/mobanfile/test_mobanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,45 @@ def test_handle_targets(fake_renderer):
)
],
)


@patch("moban.plugins.template.MobanEngine.render_to_files")
def test_handle_targets_sequence(fake_renderer):
from moban.mobanfile import handle_targets

TEMPLATE1 = "a.template.jj2"
OUTPUT1 = "filterme.handlebars" # in the future, this could dynamic output
OUTPUT2 = "filtered_output.txt"
CONFIGURATION = "child.yaml"
TEMPLATE_DIRS = [os.path.join("tests", "fixtures", "mobanfile")]
DEFAULT_TEMPLATE_TYPE = "jinja2"

options = dict(
configuration=CONFIGURATION,
template_type=DEFAULT_TEMPLATE_TYPE,
template_dir=TEMPLATE_DIRS,
configuration_dir=os.path.join("tests", "fixtures"),
)
short_hand_targets = [{OUTPUT1: TEMPLATE1}, {OUTPUT2: OUTPUT1}]
handle_targets(options, short_hand_targets)

call_args = list(fake_renderer.call_args_list)

eq_(
call_args[0][0][0][0],
TemplateTarget(
"a.template.jj2",
"child.yaml",
"filterme.handlebars",
template_type="jj2",
),
)
eq_(
call_args[1][0][0][0],
TemplateTarget(
"filterme.handlebars",
"child.yaml",
"filtered_output.txt",
template_type="handlebars",
),
)
2 changes: 1 addition & 1 deletion tests/mobanfile/test_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_handling_group_target():
def test_extract_group_targets():
test_targets = [
{"output": "a.output", "template": "a.template.jj2"},
{"copy": [{"output": "source"}], "copy1": [{"output1": "source1"}]}
{"copy": [{"output": "source"}], "copy1": [{"output1": "source1"}]},
]
actual = targets.extract_group_targets("copy1", test_targets)
expected = [{"copy1": [{"output1": "source1"}]}]
Expand Down
6 changes: 0 additions & 6 deletions tests/regression-pack/symbolic-link-gets-junk/.moban.yml

This file was deleted.

This file was deleted.

This file was deleted.

52 changes: 0 additions & 52 deletions tests/test_regression_pack.py

This file was deleted.

16 changes: 14 additions & 2 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import os

from mock import patch
from nose.tools import eq_
from nose.tools import eq_, raises

from moban.repo import git_clone, get_repo_name, get_moban_home
from moban.repo import (
git_clone,
get_repo_name,
get_moban_home,
make_sure_git_is_available,
)
from moban.exceptions import NoGitCommand
from moban.definitions import GitRequire


Expand Down Expand Up @@ -112,3 +118,9 @@ def test_get_repo_name_can_handle_invalid_url(fake_reporter):
def test_get_moban_home(_):
actual = get_moban_home()
eq_(os.path.join("root", "repos"), actual)


@raises(NoGitCommand)
@patch("subprocess.check_output", side_effect=Exception)
def test_make_git_is_available(_):
make_sure_git_is_available()