Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .azure-pipelines-steps-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- task: UsePythonVersion@0
displayName: 'Use Python 3.x'
- script: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
pip install -r tests/requirements.txt
displayName: 'Setup dependencies'
- script: |
make
displayName: 'Run tests'
11 changes: 11 additions & 0 deletions .azure-pipelines-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- task: UsePythonVersion@0
displayName: 'Use Python 3.x'
- script: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
pip install -r tests\requirements.txt
displayName: 'Setup dependencies'
- script: |
test.bat
displayName: 'Run tests'
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[settings]
line_length=79
known_first_party=lml, jinja2, ruamel.yaml
known_first_party=lml, jinja2, ruamel.yaml, mock, nose
indent=' '
multi_line_output=3
length_sort=1
Expand Down
7 changes: 7 additions & 0 deletions .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: moban
organisation: moremoban
releases:
- changes:
- action: Updated
details:
- "`#143`: moban shall report permission error and continue the rest of the copying task."
- "`#122`: Since 0.3.6, moban is tested on windows and macos too, using azure build pipelines. It is already tested extensively on travis-ci on linux os."
date: 30-12-2018
version: 0.3.6
- changes:
- action: Updated
details:
Expand Down
6 changes: 3 additions & 3 deletions .moban.cd/moban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ organisation: moremoban
author: C. W.
contact: wangc_2011@hotmail.com
license: MIT
version: 0.3.5
current_version: 0.3.5
release: 0.3.5
version: 0.3.6
current_version: 0.3.6
release: 0.3.6
branch: master
command_line_interface: "moban"
entry_point: "moban.main:main"
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Change log
================================================================================

0.3.6 - 30-12-2018
--------------------------------------------------------------------------------

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

#. `#143 <https://github.com/moremoban/moban/issues/143>`_: moban shall report
permission error and continue the rest of the copying task.
#. `#122 <https://github.com/moremoban/moban/issues/122>`_: Since 0.3.6, moban
is tested on windows and macos too, using azure build pipelines. It is
already tested extensively on travis-ci on linux os.

0.3.5 - 10-12-2018
--------------------------------------------------------------------------------

Expand Down
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ moban - 模板 Yet another jinja2 cli command for static text generation
.. image:: https://api.travis-ci.org/moremoban/moban.svg?branch=master
:target: http://travis-ci.org/moremoban/moban

.. image:: https://dev.azure.com/moremoban/moban/_apis/build/status/moremoban.moban
:target: https://dev.azure.com/moremoban/moban/_build?definitionId=1&_a=summary

.. image:: https://codecov.io/gh/moremoban/moban/branch/master/graph/badge.svg
:target: https://codecov.io/gh/moremoban/moban

Expand Down
15 changes: 15 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
jobs:
- job: 'Windows'
pool:
vmImage: vs2017-win2016
steps:
- template: '.azure-pipelines-steps.yml'
- job: 'MacOS'
pool:
vmImage: macOS-10.13
steps:
- template: '.azure-pipelines-steps-macos.yml'
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
author = u'C. W.'

# The short X.Y version
version = u'0.3.5'
version = u'0.3.6'
# The full version, including alpha/beta/rc tags
release = u'0.3.5'
release = u'0.3.6'


# -- General configuration ---------------------------------------------------
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.3.5"
__version__ = "0.3.6"
__author__ = "C. W."
12 changes: 10 additions & 2 deletions moban/copier.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import os
import sys
import shutil

import moban.utils as utils
import moban.reporter as reporter
from moban.hashstore import HASH_STORE

PY2 = sys.version_info[0] == 2
if PY2:
PermissionError = IOError


class Copier(object):
def __init__(self, template_dirs):
Expand Down Expand Up @@ -88,8 +93,11 @@ def _copy(self, src_path, dest):
if dest_folder:
utils.mkdir_p(dest_folder)
reporter.report_copying(src_path, dest)
shutil.copy(src_path, dest)
self._count = self._count + 1
try:
shutil.copy(src_path, dest)
self._count = self._count + 1
except PermissionError:
reporter.report_error_message("No permission to write %s" % dest)

def _increment_file_count(self):
self._file_count += 1
Expand Down
4 changes: 3 additions & 1 deletion moban/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ def expand_directories(file_list, template_dirs):
break
if os.path.isdir(true_template_file):
for file_name in os.listdir(true_template_file):
template_file = "/".join([template_file, file_name])
template_file = template_file.replace("\\", "/")
base_output_name, _ = os.path.splitext(file_name)
yield (
(
os.path.join(template_file, file_name),
template_file,
data_file,
os.path.join(output, base_output_name),
)
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

NAME = 'moban'
AUTHOR = 'C. W.'
VERSION = '0.3.5'
VERSION = '0.3.6'
EMAIL = 'wangc_2011@hotmail.com'
LICENSE = 'MIT'
ENTRY_POINTS = {
Expand All @@ -25,7 +25,7 @@
'Yet another jinja2 cli command for static text generation'
)
URL = 'https://github.com/moremoban/moban'
DOWNLOAD_URL = '%s/archive/0.3.5.tar.gz' % URL
DOWNLOAD_URL = '%s/archive/0.3.6.tar.gz' % URL
FILES = ['README.rst', 'CONTRIBUTORS.rst', 'CHANGELOG.rst']
KEYWORDS = [
'python',
Expand Down Expand Up @@ -60,8 +60,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.3.5 ' +
"Find 0.3.5 in changelog for more details")
GS_COMMAND = ('gs moban v0.3.6 ' +
"Find 0.3.6 in changelog for more details")
NO_GS_MESSAGE = ('Automatic github release is disabled. ' +
'Please install gease to enable it.')
UPLOAD_FAILED_MSG = (
Expand Down
4 changes: 2 additions & 2 deletions test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pip freeze
cd tests\moban-mako
python setup.py install
cd ..\..\
nosetests --with-coverage --with-doctest --doctest-extension=.rst --cover-package=moban --cover-package=tests
flake8 . --exclude=.moban.d --ignore=E203,E121,E123,E126,E226,E24,E704,W503,W504
nosetests --with-coverage --cover-package=moban --cover-package=tests
flake8 . --exclude=docs,.moban.d --ignore=E203,E121,E123,E126,E226,E24,E704,W503,W504
1 change: 1 addition & 0 deletions tests/test_context.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from nose.tools import eq_

from moban.plugins import Context


Expand Down
16 changes: 16 additions & 0 deletions tests/test_copier.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import os
import sys
import shutil

from mock import patch
from nose.tools import eq_

from moban.copier import Copier
from moban.mobanfile import handle_copy

PY2 = sys.version_info[0] == 2
if PY2:
PermissionError = IOError


class TestCopier:
def setUp(self):
Expand All @@ -31,6 +37,16 @@ def test_copy_files_file_not_found(self, reporter):
"copier-test-not-found.csv cannot be found"
)

@patch("moban.reporter.report_error_message")
def test_no_permission_to_write(self, reporter):
copier = Copier([os.path.join("tests", "fixtures")])
file_list = [{"/tmp/test_cannot_write": "copier-test01.csv"}]
self.fake_copy.side_effect = PermissionError
copier.copy_files(file_list)
reporter.assert_called_with(
"No permission to write /tmp/test_cannot_write"
)

def test_number_of_files(self):
copier = Copier([os.path.join("tests", "fixtures")])
file_list = [{"/tmp/test": "copier-test04.csv"}]
Expand Down
6 changes: 4 additions & 2 deletions tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import sys

from mock import patch
from moban.main import main
from nose.tools import eq_

from moban.main import main


class TestTutorial:
def setUp(self):
Expand Down Expand Up @@ -88,7 +89,8 @@ def test_level_7(self):
def test_level_8(self):
expected = "it is a test\n"
folder = "level-8-pass-a-folder-full-of-templates"
self._raw_moban(["moban"], folder, expected, "templated-folder/my")
check_file = os.path.join("templated-folder", "my")
self._raw_moban(["moban"], folder, expected, check_file)

def test_level_9(self):
expected = "pypi-mobans: moban dependency as pypi package"
Expand Down
10 changes: 6 additions & 4 deletions tests/test_engine.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os

from mock import patch
from lml.plugin import PluginInfo
from nose.tools import eq_, raises

import moban.exceptions as exceptions
from mock import patch
from nose.tools import eq_, raises
from moban.plugins import (
ENGINES,
Context,
Expand All @@ -13,6 +13,8 @@
)
from moban.jinja2.engine import Engine

USER_HOME = os.path.join("user", "home", ".moban", "repos")


@PluginInfo("library", tags=["testmobans"])
class TestPypkg:
Expand All @@ -27,12 +29,12 @@ def test_expand_pypi_dir():
assert os.path.exists(directory)


@patch("moban.utils.get_moban_home", return_value="/user/home/.moban/repos")
@patch("moban.utils.get_moban_home", return_value=USER_HOME)
@patch("os.path.exists", return_value=True)
def test_expand_repo_dir(_, __):
dirs = list(expand_template_directories("git_repo:template"))

expected = ["/user/home/.moban/repos/git_repo/template"]
expected = [os.path.join(USER_HOME, "git_repo", "template")]
eq_(expected, dirs)


Expand Down
1 change: 1 addition & 0 deletions tests/test_filter_github.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from nose.tools import eq_

from moban.jinja2.filters.github import github_expand


Expand Down
1 change: 1 addition & 0 deletions tests/test_filter_repr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from nose.tools import eq_

from moban.jinja2.filters.repr import repr as repr_function


Expand Down
8 changes: 7 additions & 1 deletion tests/test_hash_store.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import os
import sys

from nose import SkipTest

from moban.hashstore import HashStore

Expand All @@ -13,7 +16,8 @@ def setUp(self):
)

def tearDown(self):
os.unlink(".moban.hashes")
if os.path.exists(".moban.hashes"):
os.unlink(".moban.hashes")

def test_simple_use_case(self):
hs = HashStore()
Expand Down Expand Up @@ -76,6 +80,8 @@ def test_dest_file_file_permision_changed(self):
Save as above, but this time,
the generated file had file permision change
"""
if sys.platform == "win32":
raise SkipTest("No actual chmod on windows")
hs = HashStore()
flag = hs.is_file_changed(*self.fixture)
if flag:
Expand Down
1 change: 1 addition & 0 deletions tests/test_jinja2_engine.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from nose.tools import eq_

from moban.jinja2.engine import Engine


Expand Down
1 change: 1 addition & 0 deletions tests/test_jinja2_extensions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from nose.tools import eq_

from moban.plugins import BaseEngine
from moban.jinja2.engine import Engine
from moban.jinja2.extensions import jinja_global
Expand Down
3 changes: 2 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import sys
from shutil import copyfile

import moban.exceptions as exceptions
from mock import patch
from nose.tools import raises, assert_raises

import moban.exceptions as exceptions


class TestException:
def setUp(self):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_reporter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import sys

import moban.reporter as reporter
from mock import patch
from nose.tools import eq_

import moban.reporter as reporter

PY2 = sys.version_info[0] == 2
if PY2:
from StringIO import StringIO
Expand Down
1 change: 1 addition & 0 deletions tests/test_template.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from mock import patch

from moban.plugins import BaseEngine
from moban.jinja2.engine import Engine

Expand Down
1 change: 1 addition & 0 deletions tests/test_text_filter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from nose.tools import eq_

from moban.jinja2.filters.text import split_length


Expand Down
Loading