diff --git a/.azure-pipelines-steps-macos.yml b/.azure-pipelines-steps-macos.yml index 8958395b..37ab509e 100644 --- a/.azure-pipelines-steps-macos.yml +++ b/.azure-pipelines-steps-macos.yml @@ -2,6 +2,7 @@ steps: - task: UsePythonVersion@0 displayName: 'Use Python 3.x' - script: | + export SETUPTOOLS_USE_DISTUTILS="stdlib" python -m pip install --upgrade pip setuptools wheel test ! -f rnd_requirements.txt || pip install -r rnd_requirements.txt pip install -r requirements.txt diff --git a/.azure-pipelines-steps.yml b/.azure-pipelines-steps.yml index 2ef569c6..c51ade04 100644 --- a/.azure-pipelines-steps.yml +++ b/.azure-pipelines-steps.yml @@ -2,6 +2,7 @@ steps: - task: UsePythonVersion@0 displayName: 'Use Python 3.x' - script: | + set SETUPTOOLS_USE_DISTUTILS="stdlib" python -m pip install --upgrade pip setuptools wheel if exist rnd_requirements.txt pip install -r rnd_requirements.txt pip install -r requirements.txt diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f62cf653..dbceff6e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,5 +4,4 @@ Before raising the PR, here is a check list: - [ ] have you updated the change log? - [ ] can someone else understand your changes without your explanation? - [ ] are you proud of your code changes? -- [ ] please add your name and github link to contributors.rst in alphabetical order. diff --git a/.github/workflows/moban-update.yml b/.github/workflows/moban-update.yml new file mode 100644 index 00000000..52a82f48 --- /dev/null +++ b/.github/workflows/moban-update.yml @@ -0,0 +1,29 @@ +on: [push] + +jobs: + run_moban: + runs-on: ubuntu-latest + name: synchronize templates via moban + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: '3.7' + - name: check changes + run: | + pip install moban gitfs2 pypifs moban-jinja2-github + make update + git status + git diff --exit-code + - name: Auto-commit + if: failure() + uses: docker://cdssnc/auto-commit-github-action + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: >- + This is an auto-commit, updating project meta data, + such as changelog.rst, contributors.rst diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index 956567d2..3efc50d6 100644 --- a/.moban.cd/changelog.yml +++ b/.moban.cd/changelog.yml @@ -1,6 +1,13 @@ name: moban organisation: moremoban releases: + - changes: + - action: Removed + details: + - moban.plugins.jinja2.tests.files is moved to moban-ansible package + - moban.plugins.jinja2.filters.github is moved to moban-jinja2-github package + date: tbd + version: 0.8.0 - changes: - action: Updated details: diff --git a/.moban.cd/moban.yml b/.moban.cd/moban.yml index 2b739e6b..3d4fd65a 100644 --- a/.moban.cd/moban.yml +++ b/.moban.cd/moban.yml @@ -1,11 +1,11 @@ name: moban project: moban organisation: moremoban -author: C. W. +author: chfw contact: wangc_2011@hotmail.com license: MIT -version: 0.7.10 -current_version: 0.7.10 +version: 0.8.0 +current_version: 0.8.0 release: 0.7.10 branch: master master: index @@ -27,6 +27,7 @@ dependencies: - crayons>= 0.1.0 - fs>=2.4.11 - jinja2-fsloader>=0.2.0 + - moban-jinja2-github description: General purpose static text generator scm_host: github.com lint_command: make install_test format git-diff-check lint diff --git a/.moban.d/moban_readme.jj2 b/.moban.d/moban_readme.jj2 index 9990ba5c..28c4a86e 100644 --- a/.moban.d/moban_readme.jj2 +++ b/.moban.d/moban_readme.jj2 @@ -34,6 +34,12 @@ mó bǎn - 模板 General purpose static text generator Announcement ================================================================================ + +In version 0.8.0, `moban.plugins.jinja2.tests.files` is moved to moban-ansible +package. `moban.plugins.jinja2.filters.github` is moved to moban-jinja2-github +package Please install them for backward compatibility. + + From 2020 onwards, minimum requirement is Python 3.6 @@ -41,6 +47,8 @@ For existing moban users, python 2 support has been dropped. Please stay with versions lower than 0.7.0 if you are still using python 2. + + Quick start ================================================================================ diff --git a/.travis.yml b/.travis.yml index efb34ec7..e2cf54ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ stages: env: - MINREQ=0 stage: moban - install: pip install moban>=0.0.4 gitfs2 pypifs + install: pip install moban>=0.0.4 gitfs2 pypifs moban-jinja2-github script: make update git-diff-check jobs: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ae5dcfad..1d079775 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,14 @@ Change log ================================================================================ +0.8.0 - tbd +-------------------------------------------------------------------------------- + +**Removed** + +#. moban.plugins.jinja2.tests.files is moved to moban-ansible package +#. moban.plugins.jinja2.filters.github is moved to moban-jinja2-github package + 0.7.10 - 16.08.2020 -------------------------------------------------------------------------------- diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 7b8bbafb..95a9784d 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -1,12 +1,14 @@ -Contributors + +8 contributors ================================================================================ In alphabetical order: -* `Ayan Banerjee `_ -* `Charlie Liu `_ -* `John Vandenberg `_ -* `Joshua Chung `_ -* `PRAJWAL M `_ -* `salotz `_ -* `SerekKiri `_ +* `Andrew Scheller `_ +* `Ayan Banerjee `_ +* `Charlie Liu `_ +* `John Vandenberg `_ +* `Joshua Chung `_ +* `PRAJWAL M `_ +* `salotz `_ +* `SerekKiri `_ diff --git a/README.rst b/README.rst index c6a47504..acc63a4c 100644 --- a/README.rst +++ b/README.rst @@ -34,6 +34,12 @@ mó bǎn - 模板 General purpose static text generator Announcement ================================================================================ + +In version 0.8.0, `moban.plugins.jinja2.tests.files` is moved to moban-ansible +package. `moban.plugins.jinja2.filters.github` is moved to moban-jinja2-github +package Please install them for backward compatibility. + + From 2020 onwards, minimum requirement is Python 3.6 @@ -41,6 +47,8 @@ For existing moban users, python 2 support has been dropped. Please stay with versions lower than 0.7.0 if you are still using python 2. + + Quick start ================================================================================ diff --git a/docs/conf.py b/docs/conf.py index ca7afb4f..6e2b05ba 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,9 +23,9 @@ project = 'moban' copyright = '2017-2020 Onni Software Ltd.' -author = 'C. W.' +author = 'chfw' # The short X.Y version -version = '0.7.10' +version = '0.8.0' # The full version, including alpha/beta/rc tags release = '0.7.10' diff --git a/min_requirements.txt b/min_requirements.txt index aa6cb8d9..abf4fbd6 100644 --- a/min_requirements.txt +++ b/min_requirements.txt @@ -7,3 +7,4 @@ appdirs==1.4.3 crayons== 0.1.0 fs==2.4.11 jinja2-fsloader==0.2.0 +moban-jinja2-github diff --git a/moban/_version.py b/moban/_version.py index 23c6e5ea..4f0a5c0d 100644 --- a/moban/_version.py +++ b/moban/_version.py @@ -1,2 +1,2 @@ -__version__ = "0.7.10" -__author__ = "C. W." +__version__ = "0.8.0" +__author__ = "chfw" diff --git a/moban/constants.py b/moban/constants.py index 7522785b..5ff41711 100644 --- a/moban/constants.py +++ b/moban/constants.py @@ -25,7 +25,6 @@ # Command line options LABEL_CONFIG = "configuration" LABEL_CONFIG_DIR = "configuration_dir" -LABEL_PLUGIN_DIRS = "plugin_dir" LABEL_TEMPLATE = "template" POSITIONAL_LABEL_TEMPLATE = "template_in_string" LABEL_TMPL_DIRS = "template_dir" diff --git a/moban/core/mobanfile/__init__.py b/moban/core/mobanfile/__init__.py index 31c23f5c..d1f67b43 100644 --- a/moban/core/mobanfile/__init__.py +++ b/moban/core/mobanfile/__init__.py @@ -45,6 +45,7 @@ def handle_moban_file_v1(moban_file_configurations, command_line_options): merged_options = merge(command_line_options, constants.DEFAULT_OPTIONS) plugins_dirs = merged_options.get(constants.LABEL_PLUGIN_DIRS) + if plugins_dirs: handle_plugin_dirs(plugins_dirs) diff --git a/moban/plugins/jinja2/engine.py b/moban/plugins/jinja2/engine.py index 28ef6898..74acd249 100644 --- a/moban/plugins/jinja2/engine.py +++ b/moban/plugins/jinja2/engine.py @@ -4,7 +4,7 @@ from importlib import import_module import fs.errors -from jinja2 import Template, Environment +from jinja2 import Environment from lml.loader import scan_plugins_regex from lml.plugin import PluginInfo, PluginManager from jinja2_fsloader import FSLoader @@ -16,9 +16,7 @@ JINJA2_LIBRARIES = "^moban_jinja2_.+$" JINJA2_EXTENSIONS = [ "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__) @@ -135,7 +133,7 @@ def get_template(self, template_file): raise exceptions.PassOn(str(e)) def get_template_from_string(self, string): - return Template(string) + return self.jj2_environment.from_string(string) def apply_template(self, template, data, output): """ diff --git a/moban/plugins/jinja2/filters/github.py b/moban/plugins/jinja2/filters/github.py deleted file mode 100644 index 815627e6..00000000 --- a/moban/plugins/jinja2/filters/github.py +++ /dev/null @@ -1,43 +0,0 @@ -import re - -from moban.plugins.jinja2.extensions import JinjaFilter - -GITHUB_REF_PATTERN = "`([^`]*?#[0-9]+)`" -ISSUE = "^.*?" + GITHUB_REF_PATTERN + ".*?$" -SAME_PROJ_FULL_ISSUE = "`#{3} `_" -DIFF_PROJ_FULL_ISSUE = "`{1}#{3} `_" -PULL_REQUEST = "PR" -PULL = "pull" -ISSUES = "issues" - - -@JinjaFilter() -def github_expand(line, name, organisation): - result = re.match(ISSUE, line) - if result: - github_thing = result.group(1) - tokens = github_thing.split("#") - if len(tokens) == 4: - if tokens[2] == PULL_REQUEST: - tokens[2] = PULL - else: - tokens[2] = ISSUES - elif len(tokens) == 3: - if tokens[1] == PULL_REQUEST: - tokens = [organisation, tokens[0], PULL, tokens[2]] - else: - tokens = [organisation, tokens[0], ISSUES, tokens[2]] - elif len(tokens) == 2: - if tokens[0] == PULL_REQUEST: - tokens = [organisation, name, PULL] + tokens[1:] - elif tokens[0] != "": - tokens = [organisation, tokens[0], ISSUES] + tokens[1:] - else: - tokens = [organisation, name, ISSUES] + tokens[1:] - if tokens[1] != name: - reference = DIFF_PROJ_FULL_ISSUE.format(*tokens) - else: - reference = SAME_PROJ_FULL_ISSUE.format(*tokens) - return re.sub(GITHUB_REF_PATTERN, reference, line) - else: - return line diff --git a/moban/plugins/jinja2/tests/__init__.py b/moban/plugins/jinja2/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/moban/plugins/jinja2/tests/files.py b/moban/plugins/jinja2/tests/files.py deleted file mode 100644 index 471a0b56..00000000 --- a/moban/plugins/jinja2/tests/files.py +++ /dev/null @@ -1,27 +0,0 @@ -import sys -from os.path import isabs, isdir, exists, isfile, islink, ismount, lexists - -from moban.plugins.jinja2.extensions import jinja_tests - -if sys.platform == "win32": - from moban.jinja2.tests.win32 import samefile -else: - from os.path import samefile - -jinja_tests( - is_dir=isdir, - directory=isdir, - is_file=isfile, - file=isfile, - is_link=islink, - link=islink, - exists=exists, - link_exists=lexists, - # path testing - is_abs=isabs, - abs=isabs, - is_same_file=samefile, - same_file=samefile, - is_mount=ismount, - mount=ismount, -) diff --git a/moban/plugins/jinja2/tests/win32.py b/moban/plugins/jinja2/tests/win32.py deleted file mode 100644 index c560cc8f..00000000 --- a/moban/plugins/jinja2/tests/win32.py +++ /dev/null @@ -1,5 +0,0 @@ -from os.path import normcase, normpath - - -def samefile(file1, file2): - return normcase(normpath(file1)) == normcase(normpath(file2)) diff --git a/mobanfile b/mobanfile index 55f67431..f0057294 100644 --- a/mobanfile +++ b/mobanfile @@ -25,3 +25,5 @@ targets: template: CHANGELOG.rst.jj2 - min_requirements.txt: min_requirements.txt.jj2 - ".github/workflows/pythonpublish.yml": "pythonpublish.yml" + - "CONTRIBUTORS.rst": "CONTRIBUTORS.rst.jj2" + diff --git a/requirements.txt b/requirements.txt index 650b70d2..7eff6f9b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ appdirs>=1.4.3 crayons>= 0.1.0 fs>=2.4.11 jinja2-fsloader>=0.2.0 +moban-jinja2-github diff --git a/setup.py b/setup.py index 87fb4fac..f1ddf33f 100644 --- a/setup.py +++ b/setup.py @@ -40,8 +40,8 @@ locale.setlocale(locale.LC_ALL, "en_US.UTF-8") NAME = "moban" -AUTHOR = "C. W." -VERSION = "0.7.10" +AUTHOR = "chfw" +VERSION = "0.8.0" EMAIL = "wangc_2011@hotmail.com" LICENSE = "MIT" ENTRY_POINTS = { @@ -85,6 +85,7 @@ "crayons>= 0.1.0", "fs>=2.4.11", "jinja2-fsloader>=0.2.0", + "moban-jinja2-github", ] SETUP_COMMANDS = {} diff --git a/tests/jinja2/test_github.py b/tests/jinja2/test_github.py deleted file mode 100644 index 25aa58d1..00000000 --- a/tests/jinja2/test_github.py +++ /dev/null @@ -1,39 +0,0 @@ -from nose.tools import eq_ - -from moban.jinja2.filters.github import github_expand - - -def test_github_expand(): - inputs = [ - ["fix `#12`", "project", "organisation"], - ["fix `#13` too", "project", "organisation"], - ["`#14` works", "project", "organisation"], - ["`PR#15` works", "project", "organisation"], - ["`repo#PR#15` works", "project", "organisation"], - ["`cool#16` works", "project", "organisation"], - ["`microsoft#cool#PR#17` works", "project", "organisation"], - ["this `cool##18`", "project", "organisation"], - ["`goog#cool#19` works", "project", "organisation"], - ["`twitter#cool#weird#19` works", "project", "organisation"], - ["wont work", "project", "organisation"], - ["`wont work either`", "prj", "org"], - ["some `weird` `case` `#10` is", "prj", "org"], - ] - expectations = [ - "fix `#12 `_", - "fix `#13 `_ too", - "`#14 `_ works", - "`#15 `_ works", - "`repo#15 `_ works", - "`cool#16 `_ works", - "`cool#17 `_ works", - "this `cool#18 `_", - "`goog#19 `_ works", - "`cool#19 `_ works", - "wont work", - "`wont work either`", - "some `weird` `case` `#10 `_ is", - ] - for input_line, expect in zip(inputs, expectations): - actual = github_expand(*input_line) - eq_(actual, expect)