Skip to content

Commit f15c958

Browse files
authored
Merge pull request #400 from moremoban/dev
release 0.8.1
2 parents d132353 + 556366f commit f15c958

File tree

22 files changed

+49
-35
lines changed

22 files changed

+49
-35
lines changed

.moban.cd/changelog.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
name: moban
22
organisation: moremoban
33
releases:
4+
- changes:
5+
- action: Fixed
6+
details:
7+
- "`#399`: content processor should be called only once"
8+
- "content processor shall pass on options to content processors"
9+
date: 04.09.2020
10+
version: 0.8.1
411
- changes:
512
- action: Removed
613
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: chfw
55
66
license: MIT
7-
version: 0.8.0
8-
current_version: 0.8.0
9-
release: 0.8.0
7+
version: 0.8.1
8+
current_version: 0.8.1
9+
release: 0.8.1
1010
branch: master
1111
master: index
1212
command_line_interface: "moban"

.moban.d/moban_readme.jj2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Given the following template type function, and saved in custom-plugin dir:
216216

217217

218218
@ContentProcessor("de-duplicate", "De-duplicating", "De-duplicated")
219-
def de_duplicate(content: str) -> str:
219+
def de_duplicate(content: str, options: dict) -> str:
220220
lines = content.split(b'\n')
221221
new_lines = []
222222
for line in lines:

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ stages:
3030
env:
3131
- MINREQ=0
3232
stage: moban
33-
install: pip install moban>=0.0.4 gitfs2 pypifs moban-jinja2-github
33+
install: pip install moban gitfs2 pypifs moban-jinja2-github moban-ansible
3434
script: make update git-diff-check
3535

3636
jobs:

CHANGELOG.rst

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

4+
0.8.1 - 04.09.2020
5+
--------------------------------------------------------------------------------
6+
7+
**Fixed**
8+
9+
#. `#399 <https://github.com/moremoban/moban/issues/399>`_: content processor
10+
should be called only once
11+
#. content processor shall pass on options to content processors
12+
413
0.8.0 - 02.09.2020
514
--------------------------------------------------------------------------------
615

Makefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ lint:
2121
yamllint -d "{extends: default, ignore: .moban.cd/changelog.yml}" .
2222

2323
format:
24-
isort $(find moban -name "*.py"|xargs echo) $(find tests -name "*.py"|xargs echo)
25-
git diff
26-
black -l 79 moban
27-
git diff
28-
black -l 79 tests
29-
git diff
24+
bash format.sh
3025

3126
uml:
3227
plantuml -tsvg -o ./images/ docs/*.uml

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ Given the following template type function, and saved in custom-plugin dir:
340340
341341
342342
@ContentProcessor("de-duplicate", "De-duplicating", "De-duplicated")
343-
def de_duplicate(content: str) -> str:
343+
def de_duplicate(content: str, options: dict) -> str:
344344
lines = content.split(b'\n')
345345
new_lines = []
346346
for line in lines:

docs/conf.py

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

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

format.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
isort $(find moban -name "*.py"|xargs echo) $(find tests -name "*.py"|xargs echo)
2+
black -l 79 moban
3+
black -l 79 tests

moban/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from moban._version import __version__
2-
from moban._version import __author__
1+
from moban._version import __author__, __version__
32

43
__all__ = ("__author__", "__version__")

moban/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.8.0"
1+
__version__ = "0.8.1"
22
__author__ = "chfw"

moban/core/content_processor.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,19 @@ class CustomEngine(object):
3131
ACTION_IN_PRESENT_CONTINUOUS_TENSE = continuing_tense
3232
ACTION_IN_PAST_TENSE = past_tense
3333

34-
def __init__(self, template_fs, extensions=None):
34+
def __init__(self, template_fs, options=None):
3535
self.template_fs = template_fs
36+
self.options = options
3637

3738
def get_template(self, template_file):
3839
content = self.template_fs.readbytes(template_file)
39-
ret = a_content_processor_function(content)
40-
return ret
40+
return content
4141

4242
def get_template_from_string(self, a_string):
43-
ret = a_content_processor_function(a_string)
44-
return ret
43+
return a_string
4544

4645
def apply_template(self, template, *_):
47-
ret = a_content_processor_function(template)
46+
ret = a_content_processor_function(template, self.options)
4847
return ret
4948

5049
super(ContentProcessor, self).__call__(CustomEngine)

moban/plugins/copy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
@ContentProcessor("copy", "Copying", "Copied")
5-
def copy(content: str) -> str:
5+
def copy(content: str, _: dict) -> str:
66
"""
77
Does no templating, works like 'copy'.
88

moban/plugins/delete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class DeleteEngine(object):
1717
ACTION_IN_PRESENT_CONTINUOUS_TENSE = "Deleting"
1818
ACTION_IN_PAST_TENSE = "Deleted"
1919

20-
def __init__(self, template_fs, extensions=None):
20+
def __init__(self, template_fs, options=None):
2121
self.template_fs = template_fs
2222

2323
def get_template(self, template_file):

moban/plugins/jinja2/engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
from jinja2 import Environment
88
from lml.loader import scan_plugins_regex
99
from lml.plugin import PluginInfo, PluginManager
10-
from jinja2_fsloader import FSLoader
1110
from jinja2.exceptions import TemplateNotFound, TemplateSyntaxError
1211

1312
from moban import constants, exceptions
13+
from jinja2_fsloader import FSLoader
1414
from moban.externals import file_system
1515

1616
JINJA2_LIBRARIES = "^moban_jinja2_.+$"

moban/plugins/strip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33

44
@ContentProcessor("strip", "Stripping", "Stripped")
5-
def strip(content: str) -> str:
5+
def strip(content: str, _: dict) -> str:
66
"""Works like 'copy', but strip empty spaces before and after"""
77
return content.strip()

mobanfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ configuration:
1414
targets:
1515
- README.rst: moban_readme.jj2
1616
- setup.py: moban_setup.py.jj2
17-
- moban/__init__.py: __init__.py.jj2
1817
- moban/_version.py: _version.py.jj2
1918
- docs/conf.py: conf.py.jj2
2019
- .travis.yml: moban_travis.yml.jj2
@@ -26,4 +25,4 @@ targets:
2625
- min_requirements.txt: min_requirements.txt.jj2
2726
- ".github/workflows/pythonpublish.yml": "pythonpublish.yml"
2827
- "CONTRIBUTORS.rst": "CONTRIBUTORS.rst.jj2"
29-
28+
- format.sh: format.sh.jj2

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
NAME = "moban"
4343
AUTHOR = "chfw"
44-
VERSION = "0.8.0"
44+
VERSION = "0.8.1"
4545
4646
LICENSE = "MIT"
4747
ENTRY_POINTS = {
@@ -53,7 +53,7 @@
5353
"General purpose static text generator"
5454
)
5555
URL = "https://github.com/moremoban/moban"
56-
DOWNLOAD_URL = "%s/archive/0.8.0.tar.gz" % URL
56+
DOWNLOAD_URL = "%s/archive/0.8.1.tar.gz" % URL
5757
FILES = ["README.rst", "CONTRIBUTORS.rst", "CHANGELOG.rst"]
5858
KEYWORDS = [
5959
"python",
@@ -97,8 +97,8 @@
9797
}
9898
# You do not need to read beyond this line
9999
PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable)
100-
GS_COMMAND = ("gs moban v0.8.0 " +
101-
"Find 0.8.0 in changelog for more details")
100+
GS_COMMAND = ("gs moban v0.8.1 " +
101+
"Find 0.8.1 in changelog for more details")
102102
NO_GS_MESSAGE = ("Automatic github release is disabled. " +
103103
"Please install gease to enable it.")
104104
UPLOAD_FAILED_MSG = (

tests/regression_tests/level-7-b-template-engine-plugin/custom-plugin/deduplicate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
@ContentProcessor("de-duplicate", "De-duplicating", "De-duplicated")
5-
def de_duplicate(content: str) -> str:
5+
def de_duplicate(content: str, _: dict) -> str:
66
"""
77
Does no templating, works like 'copy'.
88

tests/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ jinja2-python-version>=1.1.2
1818
httpfs
1919
collective.checkdocs
2020
Pygments
21+

tests/test_file_system.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ def test_mkdir_p():
268268
@patch("subprocess.check_call")
269269
def test_pip_install(fake_check_all):
270270
import sys
271+
271272
from moban.deprecated import pip_install
272273

273274
pip_install(["package1", "package2"])

tests/test_main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ def test_handle_moban_file(self):
3030
main.handle_moban_file(self.moban_file, {})
3131

3232
def test_check_none(self):
33-
import moban.main as main
3433
from ruamel.yaml import YAML
3534

35+
import moban.main as main
36+
3637
yaml = YAML()
3738

3839
invalid_data = [

0 commit comments

Comments
 (0)