Skip to content

Commit 65bfc7e

Browse files
authored
Merge pull request #353 from moremoban/dev
🥚 🎡 Release 0.6.7
2 parents e456f2a + f043fb7 commit 65bfc7e

File tree

17 files changed

+157
-54
lines changed

17 files changed

+157
-54
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Python package
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
max-parallel: 4
11+
matrix:
12+
python-version: [3.6, 3.7]
13+
14+
steps:
15+
- uses: actions/checkout@v1
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v1
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install -r requirements.txt
24+
- name: Lint with flake8
25+
run: |
26+
make install_test format git-diff-check lint
27+
- name: Test with pytest
28+
run: |
29+
pip install -r tests/requirements.txt
30+
make

.moban.cd/changelog.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
name: moban
22
organisation: moremoban
33
releases:
4+
- changes:
5+
- action: Updated
6+
details:
7+
- "no verbose for error, -v for warning, -vv for warning+info, -vvv for warning+info+debug"
8+
- "`#351`, show template plugin name, i.e. 'copying' for copy instead of 'templating'"
9+
- action: Removed
10+
details:
11+
- "Message: 'Warning: Attempting to use environment vars as data...' became warning log"
12+
- "Message: 'Warning: Both data.yml and /.../.moban.cd/data.yml does not exist' became warning log"
13+
- "with -v, you would see them in such a situation"
14+
date: 1.12.2019
15+
version: 0.6.7
416
- changes:
517
- action: Added
618
details:

.moban.cd/moban.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ organisation: moremoban
44
author: C. W.
55
contact: wangc_2011@hotmail.com
66
license: MIT
7-
version: 0.6.6
8-
current_version: 0.6.6
9-
release: 0.6.6
7+
version: 0.6.7
8+
current_version: 0.6.7
9+
release: 0.6.7
1010
branch: master
1111
master: index
1212
command_line_interface: "moban"

CHANGELOG.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
Change log
22
================================================================================
33

4+
0.6.7 - 1.12.2019
5+
--------------------------------------------------------------------------------
6+
7+
**Updated**
8+
9+
#. no verbose for error, -v for warning, -vv for warning+info, -vvv for
10+
warning+info+debug
11+
#. `#351 <https://github.com/moremoban/moban/issues/351>`_, show template plugin
12+
name, i.e. 'copying' for copy instead of 'templating'
13+
14+
**Removed**
15+
16+
#. Message: 'Warning: Attempting to use environment vars as data...' became
17+
warning log
18+
#. Message: 'Warning: Both data.yml and /.../.moban.cd/data.yml does not exist'
19+
became warning log
20+
#. with -v, you would see them in such a situation
21+
422
0.6.6 - 10.11.2019
523
--------------------------------------------------------------------------------
624

README.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ moban - 模板 Any template, any data in any location
2626
:Author: C.W. and its contributors (See contributors.rst)
2727
:Issues: http://github.com/moremoban/moban/issues
2828
:License: MIT
29-
:Version: |version|
30-
:Generated: |today|
3129

3230

3331
**moban** started with bringing the high performance template engine (JINJA2) for web
@@ -82,8 +80,6 @@ Quick start
8280
8381
$ export HELLO="world"
8482
$ moban "{{HELLO}}"
85-
Warning: Both data.yml and /.../.moban.cd/data.yml does not exist
86-
Warning: Attempting to use environment vars as data...
8783
Templating {{HELLO}}... to moban.output
8884
Templated 1 file.
8985
$ cat moban.output
@@ -244,7 +240,7 @@ CLI documentation
244240
245241
--exit-code tell moban to change exit code
246242
-V, --version show program's version number and exit
247-
-v show verbose, try -v, -vv
243+
-v show verbose, try -v, -vv, -vvv
248244
249245
Exit codes
250246
--------------------------------------------------------------------------------

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
copyright = '2017-2019 Onni Software Ltd.'
2626
author = 'C. W.'
2727
# The short X.Y version
28-
version = '0.6.6'
28+
version = '0.6.7'
2929
# The full version, including alpha/beta/rc tags
30-
release = '0.6.6'
30+
release = '0.6.7'
3131

3232
# -- General configuration ---------------------------------------------------
3333

moban/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.6.6"
1+
__version__ = "0.6.7"
22
__author__ = "C. W."

moban/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
LABEL_FORCE_TEMPLATE_TYPE = "force_template_type"
7676
LABEL_TEMPLATE_TYPES = "template_types"
7777
LABEL_VERBOSE = "verbose"
78+
LABEL_MOBAN_ACTION_IN_PRESENT_CONTINUOUS_TENSE = "Mobanizing"
79+
LABEL_MOBAN_ACTION_IN_PAST_TENSE = "Mobanized"
7880

7981
# error messages
8082
ERROR_DATA_FILE_NOT_FOUND = "Both %s and %s does not exist"

moban/core/context.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import os
22
import copy
3+
import logging
34

45
from moban import constants, exceptions
56
from moban.core import utils
6-
from moban.externals import reporter
77
from moban.program_options import OPTIONS
88
from moban.core.data_loader import merge, load_data
99

10+
LOG = logging.getLogger(__name__)
11+
MESSAGE_USING_ENV_VARS = "Attempting to use environment vars as data..."
12+
1013

1114
class Context(object):
1215
def __init__(self, context_dirs):
@@ -27,7 +30,7 @@ def get_data(self, file_name):
2730
# If data file doesn't exist:
2831
# 1. Alert the user of their (potential) mistake
2932
# 2. Attempt to use environment vars as data
30-
reporter.report_warning_message(str(exception))
31-
reporter.report_using_env_vars()
33+
LOG.warn(str(exception))
34+
LOG.info(MESSAGE_USING_ENV_VARS)
3235
merge(custom_data, self.__cached_environ_variables)
3336
return custom_data

moban/core/moban_factory.py

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from moban.core.hashstore import HASH_STORE
1616
from moban.externals.buffered_writer import BufferedWriter
1717

18-
log = logging.getLogger(__name__)
18+
LOG = logging.getLogger(__name__)
1919
PY3_ABOVE = sys.version_info[0] > 2
2020

2121

@@ -29,7 +29,7 @@ def register_extensions(self, extensions):
2929
for user_template_type in extensions.keys():
3030
template_type = self.get_primary_key(user_template_type)
3131

32-
log.debug(
32+
LOG.debug(
3333
"Registering extensions: {0}={1}".format(
3434
user_template_type, extensions[user_template_type]
3535
)
@@ -92,14 +92,26 @@ def __init__(self, template_fs, context_dirs, engine):
9292
self.templated_count = 0
9393
self.file_count = 0
9494
self.buffered_writer = BufferedWriter()
95+
self.engine_action = getattr(
96+
engine,
97+
"ACTION_IN_PRESENT_CONTINUOUS_TENSE",
98+
constants.LABEL_MOBAN_ACTION_IN_PRESENT_CONTINUOUS_TENSE,
99+
)
100+
self.engine_actioned = getattr(
101+
engine,
102+
"ACTION_IN_PAST_TENSE",
103+
constants.LABEL_MOBAN_ACTION_IN_PAST_TENSE,
104+
)
95105

96106
def report(self):
97107
if self.templated_count == 0:
98108
reporter.report_no_action()
99109
elif self.templated_count == self.file_count:
100-
reporter.report_full_run(self.file_count)
110+
reporter.report_full_run(self.engine_actioned, self.file_count)
101111
else:
102-
reporter.report_partial_run(self.templated_count, self.file_count)
112+
reporter.report_partial_run(
113+
self.engine_actioned, self.templated_count, self.file_count
114+
)
103115

104116
def number_of_templated_files(self):
105117
return self.templated_count
@@ -119,7 +131,9 @@ def render_to_file(self, template_file, data_file, output_file):
119131
template_abs_path, template, data, output_file
120132
)
121133
if flag:
122-
reporter.report_templating(template_file, output_file)
134+
reporter.report_templating(
135+
self.engine_action, template_file, output_file
136+
)
123137
self.templated_count += 1
124138
self.buffered_writer.close()
125139

@@ -133,7 +147,9 @@ def render_string_to_file(
133147
template_abs_path, template, data, output_file
134148
)
135149
if flag:
136-
reporter.report_templating(template_abs_path, output_file)
150+
reporter.report_templating(
151+
self.engine_action, template_abs_path, output_file
152+
)
137153
self.templated_count += 1
138154
self.buffered_writer.close()
139155

@@ -159,7 +175,7 @@ def apply_template(self, template_abs_path, template, data, output_file):
159175
return flag
160176
except exceptions.FileNotFound:
161177
# the template is a string from command line
162-
log.info("{} is not a file".format(template_abs_path))
178+
LOG.info("{} is not a file".format(template_abs_path))
163179
self.buffered_writer.write_file_out(output_file, rendered_content)
164180
return True
165181

@@ -186,7 +202,9 @@ def _render_with_finding_template_first(self, template_file_index):
186202
template_abs_path, template, data, output
187203
)
188204
if flag:
189-
reporter.report_templating(template_file, output)
205+
reporter.report_templating(
206+
self.engine_action, template_file, output
207+
)
190208
self.templated_count += 1
191209
self.file_count += 1
192210

@@ -202,13 +220,15 @@ def _render_with_finding_data_first(self, data_file_index):
202220
template_abs_path, template, data, output
203221
)
204222
if flag:
205-
reporter.report_templating(template_file, output)
223+
reporter.report_templating(
224+
self.engine_action, template_file, output
225+
)
206226
self.templated_count += 1
207227
self.file_count += 1
208228

209229

210230
def expand_template_directories(dirs):
211-
log.debug("Expanding %s..." % dirs)
231+
LOG.debug("Expanding %s..." % dirs)
212232
if not isinstance(dirs, list):
213233
dirs = [dirs]
214234

@@ -217,7 +237,7 @@ def expand_template_directories(dirs):
217237

218238

219239
def expand_template_directory(directory):
220-
log.debug("Expanding %s..." % directory)
240+
LOG.debug("Expanding %s..." % directory)
221241
translated_directory = None
222242
if ":" in directory and directory[1] != ":" and "://" not in directory:
223243
translated_directory = deprecated_moban_path_notation(directory)

0 commit comments

Comments
 (0)