diff --git a/.azure-pipelines-steps-macos.yml b/.azure-pipelines-steps-macos.yml index 81734822..8958395b 100644 --- a/.azure-pipelines-steps-macos.yml +++ b/.azure-pipelines-steps-macos.yml @@ -1,12 +1,12 @@ steps: -- task: UsePythonVersion@0 - displayName: 'Use Python 3.x' -- script: | - python -m pip install --upgrade pip setuptools wheel - test ! -f rnd_requirements.txt || pip install -r rnd_requirements.txt - pip install -r requirements.txt - pip install -r tests/requirements.txt - displayName: 'Setup dependencies' -- script: | - make - displayName: 'Run tests' + - task: UsePythonVersion@0 + displayName: 'Use Python 3.x' + - script: | + python -m pip install --upgrade pip setuptools wheel + test ! -f rnd_requirements.txt || pip install -r rnd_requirements.txt + pip install -r requirements.txt + pip install -r tests/requirements.txt + displayName: 'Setup dependencies' + - script: | + make + displayName: 'Run tests' diff --git a/.azure-pipelines-steps.yml b/.azure-pipelines-steps.yml index 4fc4925e..2ef569c6 100644 --- a/.azure-pipelines-steps.yml +++ b/.azure-pipelines-steps.yml @@ -1,12 +1,12 @@ steps: -- task: UsePythonVersion@0 - displayName: 'Use Python 3.x' -- script: | - python -m pip install --upgrade pip setuptools wheel - if exist rnd_requirements.txt pip install -r rnd_requirements.txt - pip install -r requirements.txt - pip install -r tests\requirements.txt - displayName: 'Setup dependencies' -- script: | - test.bat - displayName: 'Run tests' + - task: UsePythonVersion@0 + displayName: 'Use Python 3.x' + - script: | + python -m pip install --upgrade pip setuptools wheel + if exist rnd_requirements.txt pip install -r rnd_requirements.txt + pip install -r requirements.txt + pip install -r tests\requirements.txt + displayName: 'Setup dependencies' + - script: | + test.bat + displayName: 'Run tests' diff --git a/.isort.cfg b/.isort.cfg index 091b7305..d76a1394 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,9 +1,12 @@ [settings] line_length=79 -known_first_party=lml, jinja2, ruamel.yaml, mock, nose +# Ignore generated files +skip=setup.py, moban/__init__.py +known_first_party=lml, crayons, jinja2, ruamel.yaml, mock, nose indent=' ' multi_line_output=3 length_sort=1 +include_trailing_comma=true default_section=FIRSTPARTY no_lines_before=LOCALFOLDER sections=FUTURE,STDLIB,FIRSTPARTY,THIRDPARTY,LOCALFOLDER diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index 6560d83d..bc1ba839 100644 --- a/.moban.cd/changelog.yml +++ b/.moban.cd/changelog.yml @@ -1,305 +1,341 @@ name: moban organisation: moremoban releases: -- changes: - - action: Updated - details: - - "`#271`: support git branch change in later run." - date: 07.07.2019 - version: 0.4.5 -- changes: - - action: Updated - details: - - "`#265`: Use simple `read binary` to read instead of encoding" - date: 26.05.2019 - version: 0.4.4 -- 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" - - "`#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 -- changes: - - action: Added - details: - - "`#235`: user defined template types so that custom file extensions, template configurations can be controlled by moban user" - - "`#232`: the package dependencies have been fine tuning to lower versions, most of them are dated back to 2017." - date: 28.02.2019 - version: 0.4.1 -- changes: - - action: Added - details: - - "`#165`: Copy as plugins" - - action: Updated - details: - - "`#219`: git clone depth set to 2" - - "`#186`: lowest dependecy on ruamel.yaml is 0.15.5, Jun 2017" - date: 20.02.2019 - version: 0.4.0 -- changes: - - action: Added - details: - - "`#174`: Store git cache in XDG_CACHE_DIR" - - "`#107`: Add -v to show current moban version" - - "`#164`: support additional data formats" - - action: Updated - details: - - "`#178`: UnboundLocalError: local variable 'target' referenced before assignment" - - "`#169`: uses GitPython instead of barebone git commands" - date: 03.02.2019 - version: 0.3.10 -- changes: - - action: Updated - details: - - "`#90`: allow adding extra jinja2 extensions. `jinja2.ext.do`, `jinja2.ext.loopcontrols` are included by default. what's more, any other template enigne are eligible for extension additions." - - "`#158`: Empty file base_engine.py is finally removed" - date: 18-1-2019 - version: 0.3.9 -- changes: - - action: Updated - details: - - "`#141`: disable file permissions copy feature and not to check file permission changes on windows." - - "`#154`: introduce first ever positional argument for string base template." - - "`#157`: the exit code behavior changed. for backward compactibility please use --exit-code. Otherwise, moban will not tell if there is any changes." - date: 12-1-2019 - version: 0.3.8 -- changes: - - action: Updated - details: - - "`#146`: added a low-setup usage mode via environment variables to moban" - - "`#148`: include test related files in the package for package validation when distributing via linux system, i.e. OpenSuse" - date: 6-1-2019 - version: 0.3.7 -- 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: - - "`#37`: moban will report line number where the value is empty and the name of mobanfile. Switch from pyyaml to ruamel.yaml." - date: 10-12-2018 - version: 0.3.5 -- changes: - - action: Updated - details: - - "`#137`: missing contributors.rst file" - date: 28-11-2018 - version: 0.3.4.1 -- changes: - - action: Added - details: - - "global variables to store the target and template file names in the jinja2 engine" - - "moban-handlebars is tested to work well with this version and above" - - action: Updated - details: - - Template engine interface has been clarified and documented - date: 18-11-2018 - version: 0.3.4 -- changes: - - action: Added - details: - - "alternative and expanded syntax for requires, so as to accomendate github submodule recursive" - date: 05-11-2018 - version: 0.3.3 -- changes: - - action: Added - details: - - "`requires` shall support configuration dirs. In other words, configuration file could be stored in python package or git repository." - date: 04-11-2018 - version: 0.3.2 -- changes: - - action: Added - details: - - "`#97`: requires will clone a repo if given. Note: only github, gitlab, bitbucket for now" - date: 02-11-2018 - version: 0.3.1 -- changes: - - action: Added - details: - - "`#89`: Install pypi-hosted mobans through requires syntax" - - action: Updated - details: - - "`#96`: Fix for FileNotFoundError for plugins" - - "various documentation updates" - - action: Removed - details: - - "`#88`: removed python 2.6 support" - - removed python 3.3 support - date: 27-18-2018 - version: 0.3.0 -- changes: - - action: Added - details: - - "`#32`: option 1 copy a directory without its subdirectories." - - "`#30`: command line template option is ignore when a moban file is present" - date: 14-07-2018 - version: 0.2.4 -- changes: - - action: Added - details: - - "`#76`: running moban as a module from python command" - - "`#32`: copy a directory recusively" - - "`#33`: template all files in a directory" - date: 10-07-2018 - version: 0.2.3 -- changes: - - action: Added - details: - - "`#31`: create directory if missing during copying" - - action: Updated - details: - - "`#28`: if a template has been copied once before, it is skipped in the next moban call" - date: 16-06-2018 - version: 0.2.2 -- changes: - - action: Updated - details: - - templates using the same template engine will be templated as a group - - update lml dependency to 0.0.3 - date: 13-06-2018 - version: 0.2.1 -- changes: - - action: Added - details: - - '`#18`: file exists test' - - "`#23`: custom jinja plugins" - - '`#26`: repr filter' - - "`#47`: allow the expansion of template engine" - - "`#58`: allow template type per template" - - action: Updated - details: - - "`#34`: fix plural message if single file is processed" - date: 11-06-2018 - version: 0.2.0 -- changes: - - action: Updated - details: - - '`#21`: targets become optional' - - "`#19`: transfer symlink's target file's file permission under unix/linux systems" - - '`#16`: introduce copy key word in mobanfile' - date: 29-May-2018 - version: 0.1.4 -- changes: - - action: Updated - details: - - handle unicode on python 2 - date: 12-Mar-2018 - version: 0.1.3 -- changes: - - action: Added - details: - - '`#13`: strip off new lines in the templated file' - date: 10-Jan-2018 - version: 0.1.2 -- changes: - - action: Added - details: - - the ability to present a long text as multi-line paragraph with a custom upper - limit - - 'speical filter expand github references: pull request and issues' - - '`#15`: fix templating syntax to enable python 2.6' - date: 08-Jan-2018 - version: 0.1.1 -- changes: - - action: Added - details: - - '`#14`, provide shell exit code' - date: 19-Dec-2017 - version: 0.1.0 -- changes: - - action: Added - details: - - '`#11`, recognize .moban.yaml as well as .moban.yml.' - - '`#9`, preserve file permissions of the source template.' - - '`-m` option is added to allow you to specify a custom moban file. kinda related - to issue 11.' - - action: Updated - details: - - 'use explicit version name: `moban_file_spec_version` so that `version` can - be used by users. `#10` Please note: moban_file_spec_version is reserved for - future file spec upgrade. For now, all files are assumed to be ''1.0''. When - there comes a new version i.e. 2.0, new moban file based on 2.0 will have to - include ''moban_file_spec_version: 2.0''' - date: 24-Nov-2017 - version: 0.0.9 -- changes: - - action: Added - details: - - '`#8`, verify the existence of custom template and configuration directories. - default .moban.td, .moban.cd are ignored if they do not exist.' - - action: Updated - details: - - Colorize error messages and processing messages. crayons become a dependency. - date: 18-Nov-2017 - version: 0.0.8 -- changes: - - action: Added - details: - - 'Bring the visibility of environment variable into jinja2 templating process: `#7`' - date: 19-Jul-2017 - version: 0.0.7 -- changes: - - action: Added - details: - - added '-f' flag to force moban to template all files despite of .moban.hashes - - action: Updated - details: - - 'moban will not template target file in the situation where the changes occured - in target file than in the source: the template file + the data configuration - after moban has been applied. This new release will remove the change during - mobanization process.' - date: 16-Jun-2017 - version: 0.0.6 -- changes: - - action: Added - details: - - Create a default hash store when processing a moban file. It will save unnecessary - file write to the disc if the rendered content is not changed. - - Added summary reports - date: 17-Mar-2017 - version: 0.0.5 -- changes: - - action: Updated - details: - - Bug fix `#5`, should detect duplicated targets in `.moban.yml` file. - date: 11-May-2016 - version: 0.0.4 -- changes: - - action: Updated - details: - - Bug fix `#4`, keep trailing new lines - date: 09-May-2016 - version: 0.0.3 -- changes: - - action: Updated - details: - - Bug fix `#1`, failed to save utf-8 characters - date: 27-Apr-2016 - version: 0.0.2 -- changes: - - action: Added - details: - - Initial release - date: 23-Mar-2016 - version: 0.0.1 + - changes: + - action: Updated + details: + - "`#277`: Restored dependency git-url-parse, replacing incompatible + giturlparse which was used during moban 0.4.x" + - "`#281`: Fixed unicode support on Python 2.7" + - "`#274`: Updated ruamel.yaml dependency pins to restore support for + Python 3.4, and prevent installation of versions that can not be + installed on Python 3.7" + - "`#285`: Fixed CI testing of minimum requirements" + - "`#271`: Fixed repository caching bug preventing branch switching" + - "`#292`: Reformatted YAML files according to yamllint rules" + - "`#291`: Fixed filename typos in README" + - "`#280`: Added CI to ensure repository is in sync with upstream" + - "`#280`: sync setup.py from pypi-mobans" + date: 14.07.2019 + version: 0.5.0 + - changes: + - action: Updated + details: + - "`#271`: support git branch change in later run." + date: 07.07.2019 + version: 0.4.5 + - changes: + - action: Updated + details: + - "`#265`: Use simple `read binary` to read instead of encoding" + date: 26.05.2019 + version: 0.4.4 + - 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" + - "`#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 + - changes: + - action: Added + details: + - "`#235`: user defined template types so that custom file extensions, + template configurations can be controlled by moban user" + - "`#232`: the package dependencies have been fine tuning to lower + versions, most of them are dated back to 2017." + date: 28.02.2019 + version: 0.4.1 + - changes: + - action: Added + details: + - "`#165`: Copy as plugins" + - action: Updated + details: + - "`#219`: git clone depth set to 2" + - "`#186`: lowest dependecy on ruamel.yaml is 0.15.5, Jun 2017" + date: 20.02.2019 + version: 0.4.0 + - changes: + - action: Added + details: + - "`#174`: Store git cache in XDG_CACHE_DIR" + - "`#107`: Add -v to show current moban version" + - "`#164`: support additional data formats" + - action: Updated + details: + - "`#178`: UnboundLocalError: local variable 'target' referenced before assignment" + - "`#169`: uses GitPython instead of barebone git commands" + date: 03.02.2019 + version: 0.3.10 + - changes: + - action: Updated + details: + - "`#90`: allow adding extra jinja2 extensions. `jinja2.ext.do`, + `jinja2.ext.loopcontrols` are included by default. what's more, + any other template enigne are eligible for extension additions." + - "`#158`: Empty file base_engine.py is finally removed" + date: 18-1-2019 + version: 0.3.9 + - changes: + - action: Updated + details: + - "`#141`: disable file permissions copy feature and not to check file permission changes on windows." + - "`#154`: introduce first ever positional argument for string base template." + - "`#157`: the exit code behavior changed. for backward compactibility + please use --exit-code. Otherwise, moban will not tell if there is + any changes." + date: 12-1-2019 + version: 0.3.8 + - changes: + - action: Updated + details: + - "`#146`: added a low-setup usage mode via environment variables to moban" + - "`#148`: include test related files in the package for package + validation when distributing via linux system, i.e. OpenSuse" + date: 6-1-2019 + version: 0.3.7 + - 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: + - "`#37`: moban will report line number where the value is empty and + the name of mobanfile. Switch from pyyaml to ruamel.yaml." + date: 10-12-2018 + version: 0.3.5 + - changes: + - action: Updated + details: + - "`#137`: missing contributors.rst file" + date: 28-11-2018 + version: 0.3.4.1 + - changes: + - action: Added + details: + - "global variables to store the target and template file names in the jinja2 engine" + - "moban-handlebars is tested to work well with this version and above" + - action: Updated + details: + - Template engine interface has been clarified and documented + date: 18-11-2018 + version: 0.3.4 + - changes: + - action: Added + details: + - "alternative and expanded syntax for requires, so as to accomendate github submodule recursive" + date: 05-11-2018 + version: 0.3.3 + - changes: + - action: Added + details: + - configuration dirs may be located by `requires`, i.e. + configuration files may be in a python package or git repository. + date: 04-11-2018 + version: 0.3.2 + - changes: + - action: Added + details: + - "`#97`: requires will clone a repo if given. Note: only github, gitlab, bitbucket for now" + date: 02-11-2018 + version: 0.3.1 + - changes: + - action: Added + details: + - "`#89`: Install pypi-hosted mobans through requires syntax" + - action: Updated + details: + - "`#96`: Fix for FileNotFoundError for plugins" + - "various documentation updates" + - action: Removed + details: + - "`#88`: removed python 2.6 support" + - removed python 3.3 support + date: 27-18-2018 + version: 0.3.0 + - changes: + - action: Added + details: + - "`#32`: option 1 copy a directory without its subdirectories." + - "`#30`: command line template option is ignore when a moban file is present" + date: 14-07-2018 + version: 0.2.4 + - changes: + - action: Added + details: + - "`#76`: running moban as a module from python command" + - "`#32`: copy a directory recusively" + - "`#33`: template all files in a directory" + date: 10-07-2018 + version: 0.2.3 + - changes: + - action: Added + details: + - "`#31`: create directory if missing during copying" + - action: Updated + details: + - "`#28`: if a template has been copied once before, it is skipped in the next moban call" + date: 16-06-2018 + version: 0.2.2 + - changes: + - action: Updated + details: + - templates using the same template engine will be templated as a group + - update lml dependency to 0.0.3 + date: 13-06-2018 + version: 0.2.1 + - changes: + - action: Added + details: + - '`#18`: file exists test' + - "`#23`: custom jinja plugins" + - '`#26`: repr filter' + - "`#47`: allow the expansion of template engine" + - "`#58`: allow template type per template" + - action: Updated + details: + - "`#34`: fix plural message if single file is processed" + date: 11-06-2018 + version: 0.2.0 + - changes: + - action: Updated + details: + - '`#21`: targets become optional' + - "`#19`: transfer symlink's target file's file permission under unix/linux systems" + - '`#16`: introduce copy key word in mobanfile' + date: 29-May-2018 + version: 0.1.4 + - changes: + - action: Updated + details: + - handle unicode on python 2 + date: 12-Mar-2018 + version: 0.1.3 + - changes: + - action: Added + details: + - '`#13`: strip off new lines in the templated file' + date: 10-Jan-2018 + version: 0.1.2 + - changes: + - action: Added + details: + - the ability to present a long text as multi-line paragraph with a custom upper + limit + - 'speical filter expand github references: pull request and issues' + - '`#15`: fix templating syntax to enable python 2.6' + date: 08-Jan-2018 + version: 0.1.1 + - changes: + - action: Added + details: + - '`#14`, provide shell exit code' + date: 19-Dec-2017 + version: 0.1.0 + - changes: + - action: Added + details: + - '`#11`, recognize .moban.yaml as well as .moban.yml.' + - '`#9`, preserve file permissions of the source template.' + - '`-m` option is added to allow you to specify a custom moban file. kinda related + to issue 11.' + - action: Updated + details: + - 'use explicit version name: `moban_file_spec_version` so that `version` can + be used by users. `#10` Please note: moban_file_spec_version is reserved for + future file spec upgrade. For now, all files are assumed to be ''1.0''. When + there comes a new version i.e. 2.0, new moban file based on 2.0 will have to + include ''moban_file_spec_version: 2.0''' + date: 24-Nov-2017 + version: 0.0.9 + - changes: + - action: Added + details: + - '`#8`, verify the existence of custom template and configuration directories. + default .moban.td, .moban.cd are ignored if they do not exist.' + - action: Updated + details: + - Colorize error messages and processing messages. crayons become a dependency. + date: 18-Nov-2017 + version: 0.0.8 + - changes: + - action: Added + details: + - 'Bring the visibility of environment variable into jinja2 templating process: `#7`' + date: 19-Jul-2017 + version: 0.0.7 + - changes: + - action: Added + details: + - added '-f' flag to force moban to template all files despite of .moban.hashes + - action: Updated + details: + - 'moban will not template target file in the situation where the changes occured + in target file than in the source: the template file + the data configuration + after moban has been applied. This new release will remove the change during + mobanization process.' + date: 16-Jun-2017 + version: 0.0.6 + - changes: + - action: Added + details: + - Create a default hash store when processing a moban file. It will save unnecessary + file write to the disc if the rendered content is not changed. + - Added summary reports + date: 17-Mar-2017 + version: 0.0.5 + - changes: + - action: Updated + details: + - Bug fix `#5`, should detect duplicated targets in `.moban.yml` file. + date: 11-May-2016 + version: 0.0.4 + - changes: + - action: Updated + details: + - Bug fix `#4`, keep trailing new lines + date: 09-May-2016 + version: 0.0.3 + - changes: + - action: Updated + details: + - Bug fix `#1`, failed to save utf-8 characters + date: 27-Apr-2016 + version: 0.0.2 + - changes: + - action: Added + details: + - Initial release + date: 23-Mar-2016 + version: 0.0.1 diff --git a/.moban.cd/moban.yml b/.moban.cd/moban.yml index 56490822..2a3dca1f 100644 --- a/.moban.cd/moban.yml +++ b/.moban.cd/moban.yml @@ -4,9 +4,9 @@ organisation: moremoban author: C. W. contact: wangc_2011@hotmail.com license: MIT -version: 0.4.5 -current_version: 0.4.5 -release: 0.4.5 +version: 0.5.0 +current_version: 0.5.0 +release: 0.5.0 branch: master master: index command_line_interface: "moban" @@ -18,13 +18,19 @@ keywords: - jinja2 - moban dependencies: - - ruamel.yaml>=0.15.5 + - ruamel.yaml>=0.15.5,<=0.15.94;python_version == '3.4' + - ruamel.yaml>=0.15.42;python_version == '3.7' + - ruamel.yaml>=0.15.5;python_version != '3.4' and python_version < '3.7' + - ruamel.yaml>=0.15.98;python_version == '3.8' - jinja2>=2.7.1 - lml>=0.0.9 - appdirs>=1.2.0 - crayons>= 0.1.0 - GitPython>=2.0.0 - - giturlparse>=0.9.1 + - git-url-parse>=1.2.2 description: Yet another jinja2 cli command for static text generation scm_host: github.com -lint: sh lint.sh \ No newline at end of file +lint_command: make install_test format git-diff-check lint +moban_command: make update git-diff-check +setup_use_markers: true +setup_use_markers_fix: true diff --git a/.moban.d/travis.yml b/.moban.d/moban_travis.yml.jj2 similarity index 77% rename from .moban.d/travis.yml rename to .moban.d/moban_travis.yml.jj2 index 741fd994..91ba2fd4 100644 --- a/.moban.d/travis.yml +++ b/.moban.d/moban_travis.yml.jj2 @@ -1,18 +1,18 @@ {% extends 'travis.yml.jj2' %} {%block extra_matrix %} -matrix: - include: - - python: 2.7 - env: MINREQ=1 +env: + - MINREQ=0 + - MINREQ=1 {%endblock%} {%block custom_python_versions%} python: - &pypy2 pypy2.7-6.0 - - 3.8-dev - 3.7 - 3.6 - 3.5 + - 3.4 - 2.7 + - 3.8-dev {%endblock%} diff --git a/.moban.d/setup.py b/.moban.d/setup.py index 901b9222..ee8313e0 100644 --- a/.moban.d/setup.py +++ b/.moban.d/setup.py @@ -3,4 +3,4 @@ {%block platform_block%} {%endblock%} -{%block morefiles%} 'CONTRIBUTORS.rst',{%endblock%} +{%block morefiles%} "CONTRIBUTORS.rst",{%endblock%} diff --git a/.travis.yml b/.travis.yml index d7b0b96d..4f34a3e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ - sudo: false dist: xenial language: python @@ -6,47 +5,63 @@ notifications: email: false python: - &pypy2 pypy2.7-6.0 - - 3.8-dev - 3.7 - 3.6 - 3.5 + - 3.4 - 2.7 -matrix: - include: - - python: 2.7 - env: MINREQ=1 + - 3.8-dev +env: + - MINREQ=0 + - MINREQ=1 stages: - test - lint + - moban .disable_global: &disable_global + addons: false + cache: false + env: {} + python: false before_install: false - install: true + install: false before_script: false + script: false after_success: false after_failure: false + before_deploy: false + deploy: false .lint: &lint <<: *disable_global + git: + submodules: false python: 3.6 stage: lint - install: pip install flake8 - script: sh lint.sh + script: make install_test format git-diff-check lint + +.moban: &moban + <<: *disable_global + python: 3.6 + stage: moban + install: pip install moban>=0.0.4 + script: make update git-diff-check jobs: include: + - *moban - *lint stage: test -script: make test - before_install: - if [[ -f min_requirements.txt && "$MINREQ" -eq 1 ]]; then mv min_requirements.txt requirements.txt ; fi - - test ! -f rnd_requirements.txt || pip install --no-deps -r rnd_requirements.txt + - test ! -f rnd_requirements.txt || + pip install --no-deps -r rnd_requirements.txt - test ! -f rnd_requirements.txt || pip install -r rnd_requirements.txt ; - pip install -r tests/requirements.txt script: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b2a846a4..21e34261 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,33 @@ Change log ================================================================================ +0.5.0 - 14.07.2019 +-------------------------------------------------------------------------------- + +Updated +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +#. `#277 `_: Restored dependency + git-url-parse, replacing incompatible giturlparse which was used during moban + 0.4.x +#. `#281 `_: Fixed unicode + support on Python 2.7 +#. `#274 `_: Updated ruamel.yaml + dependency pins to restore support for Python 3.4, and prevent installation + of versions that can not be installed on Python 3.7 +#. `#285 `_: Fixed CI testing of + minimum requirements +#. `#271 `_: Fixed repository + caching bug preventing branch switching +#. `#292 `_: Reformatted YAML + files according to yamllint rules +#. `#291 `_: Fixed filename typos + in README +#. `#280 `_: Added CI to ensure + repository is in sync with upstream +#. `#280 `_: sync setup.py from + pypi-mobans + 0.4.5 - 07.07.2019 -------------------------------------------------------------------------------- @@ -215,8 +242,8 @@ Added Added ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -#. `requires` shall support configuration dirs. In other words, configuration - file could be stored in python package or git repository. +#. configuration dirs may be located by `requires`, i.e. configuration files may + be in a python package or git repository. 0.3.1 - 02-11-2018 -------------------------------------------------------------------------------- diff --git a/Makefile b/Makefile index d275cdef..b7e5f2c3 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,29 @@ all: test +install: + pip install . + +install_test: + pip install -r tests/requirements.txt + update: moban -m mobanfile +git-diff-check: + git diff --exit-code + test: bash test.sh +lint: + bash lint.sh + yamllint -d "{extends: default, rules: {line-length: {max: 120}}}" .moban.cd/changelog.yml + yamllint -d "{extends: default, ignore: .moban.cd/changelog.yml}" . + format: isort -y $(find moban -name "*.py"|xargs echo) $(find tests -name "*.py"|xargs echo) + git diff black -l 79 moban + git diff black -l 79 tests + git diff diff --git a/README.rst b/README.rst index dfd13714..528b5aec 100644 --- a/README.rst +++ b/README.rst @@ -163,7 +163,7 @@ It breaks down the given string into a fixed length paragraph. Here is the synta {% endfor %} It is used to keep changelog formatted in -`CHANGELOG.rst.jjs in pypi-mobans project `_ +`CHANGELOG.rst.jj2 in pypi-mobans project `_ github_expand -------------------------------------------------------------------------------- @@ -175,7 +175,7 @@ It expands simple hashtags into github issues. Here is the syntax:: It makes it easy to mention github reference in change log in all projects. Here is the place it is applied: -`CHANGELOG.rst.jjs in pypi-mobans project `_ +`CHANGELOG.rst.jj2 in pypi-mobans project `_ Here is Grammar in the changelog.yml:: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8bcd2991..f4f80f5a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,15 +1,14 @@ # 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' + - 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' diff --git a/docs/conf.py b/docs/conf.py index 018af81e..4f768e04 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,9 +25,9 @@ copyright = '2017-2019 Onni Software Ltd.' author = 'C. W.' # The short X.Y version -version = '0.4.5' +version = '0.5.0' # The full version, including alpha/beta/rc tags -release = '0.4.5' +release = '0.5.0' # -- General configuration --------------------------------------------------- diff --git a/docs/level-1-jinja2-cli/data.yml b/docs/level-1-jinja2-cli/data.yml index 0d8e794f..bb56b055 100644 --- a/docs/level-1-jinja2-cli/data.yml +++ b/docs/level-1-jinja2-cli/data.yml @@ -1 +1 @@ -hello: world \ No newline at end of file +hello: world diff --git a/docs/level-10-moban-dependency-as-git-repo/.moban.yml b/docs/level-10-moban-dependency-as-git-repo/.moban.yml index e589b3d2..9286746c 100644 --- a/docs/level-10-moban-dependency-as-git-repo/.moban.yml +++ b/docs/level-10-moban-dependency-as-git-repo/.moban.yml @@ -1,5 +1,5 @@ requires: - - https://github.com/moremoban/pypi-mobans + - https://github.com/moremoban/pypi-mobans configuration: template_dir: - "pypi-mobans:templates" diff --git a/docs/level-10-moban-dependency-as-git-repo/config.yml b/docs/level-10-moban-dependency-as-git-repo/config.yml index da73400d..a4d9f0c9 100644 --- a/docs/level-10-moban-dependency-as-git-repo/config.yml +++ b/docs/level-10-moban-dependency-as-git-repo/config.yml @@ -1,2 +1,2 @@ overrides: data.yml -level10: "moban dependency as git repo" \ No newline at end of file +level10: "moban dependency as git repo" diff --git a/docs/level-10-moban-dependency-as-git-repo/local/mytravis.yml b/docs/level-10-moban-dependency-as-git-repo/local/mytravis.yml index 8295c536..dc7bd8c8 100644 --- a/docs/level-10-moban-dependency-as-git-repo/local/mytravis.yml +++ b/docs/level-10-moban-dependency-as-git-repo/local/mytravis.yml @@ -14,7 +14,8 @@ before_install: - if [[ -f min_requirements.txt && "$MINREQ" -eq 1 ]]; then mv min_requirements.txt requirements.txt ; fi - - test ! -f rnd_requirements.txt || pip install --no-deps -r rnd_requirements.txt + - test ! -f rnd_requirements.txt || + pip install --no-deps -r rnd_requirements.txt - test ! -f rnd_requirements.txt || pip install -r rnd_requirements.txt ; - pip install -r tests/requirements.txt script: diff --git a/docs/level-11-use-handlebars/.moban.cd/data.base.yaml b/docs/level-11-use-handlebars/.moban.cd/data.base.yaml index 2c16d47a..3a35fadb 100644 --- a/docs/level-11-use-handlebars/.moban.cd/data.base.yaml +++ b/docs/level-11-use-handlebars/.moban.cd/data.base.yaml @@ -1,2 +1,2 @@ nihao: shijie -hello: shijie \ No newline at end of file +hello: shijie diff --git a/docs/level-11-use-handlebars/data.yml b/docs/level-11-use-handlebars/data.yml index dc8c957d..dd77481e 100644 --- a/docs/level-11-use-handlebars/data.yml +++ b/docs/level-11-use-handlebars/data.yml @@ -1,3 +1,3 @@ overrides: data.base.yaml hello: world -no-inheritance: handlebars does not support inheritance \ No newline at end of file +no-inheritance: handlebars does not support inheritance diff --git a/docs/level-13-any-data-override-any-data/.moban.cd/parent.yaml b/docs/level-13-any-data-override-any-data/.moban.cd/parent.yaml index ff67cd90..69c9ef15 100644 --- a/docs/level-13-any-data-override-any-data/.moban.cd/parent.yaml +++ b/docs/level-13-any-data-override-any-data/.moban.cd/parent.yaml @@ -1,2 +1,2 @@ nihao: shijie from parent.yaml -hello: shijie \ No newline at end of file +hello: shijie diff --git a/docs/level-14-custom-data-loader/override_custom.yaml b/docs/level-14-custom-data-loader/override_custom.yaml index d24ae6b5..80f3b077 100644 --- a/docs/level-14-custom-data-loader/override_custom.yaml +++ b/docs/level-14-custom-data-loader/override_custom.yaml @@ -1,2 +1,2 @@ overrides: parent.custom -hello: world from override_custom.yaml \ No newline at end of file +hello: world from override_custom.yaml diff --git a/docs/level-16-group-targets-using-template-type/.moban.yml b/docs/level-16-group-targets-using-template-type/.moban.yml index 4d661b91..b5ca4d91 100644 --- a/docs/level-16-group-targets-using-template-type/.moban.yml +++ b/docs/level-16-group-targets-using-template-type/.moban.yml @@ -3,7 +3,8 @@ configuration: - template-sources targets: - copy: - - simple.file.copy: file-in-template-sources-folder.txt - - "misc-1-copying/can-create-folder/if-not-exists.txt": file-in-template-sources-folder.txt - - "test-dir": dir-for-copying - - "test-recursive-dir": dir-for-recusive-copying/** + - simple.file.copy: file-in-template-sources-folder.txt + - "misc-1-copying/can-create-folder/if-not-exists.txt": + file-in-template-sources-folder.txt + - "test-dir": dir-for-copying + - "test-recursive-dir": dir-for-recusive-copying/** diff --git a/docs/level-17-force-template-type-from-moban-file/.moban.yml b/docs/level-17-force-template-type-from-moban-file/.moban.yml index aefaa37f..68b3ea00 100644 --- a/docs/level-17-force-template-type-from-moban-file/.moban.yml +++ b/docs/level-17-force-template-type-from-moban-file/.moban.yml @@ -4,6 +4,7 @@ configuration: force_template_type: copy targets: - simple.file.copy: file-in-template-sources-folder.txt - - "misc-1-copying/can-create-folder/if-not-exists.txt": file-in-template-sources-folder.txt + - "misc-1-copying/can-create-folder/if-not-exists.txt": + file-in-template-sources-folder.txt - "test-dir": dir-for-copying - "test-recursive-dir": dir-for-recusive-copying/** diff --git a/docs/level-19-moban-a-sub-group-in-targets/.moban.yml b/docs/level-19-moban-a-sub-group-in-targets/.moban.yml index 788cf965..af8e6098 100644 --- a/docs/level-19-moban-a-sub-group-in-targets/.moban.yml +++ b/docs/level-19-moban-a-sub-group-in-targets/.moban.yml @@ -5,7 +5,8 @@ configuration: targets: - a.output: a.template.jj2 - copy: - - simple.file.copy: file-in-template-sources-folder.txt - - "misc-1-copying/can-create-folder/if-not-exists.txt": file-in-template-sources-folder.txt - - "test-dir": dir-for-copying - - "test-recursive-dir": dir-for-recusive-copying/** + - simple.file.copy: file-in-template-sources-folder.txt + - "misc-1-copying/can-create-folder/if-not-exists.txt": + file-in-template-sources-folder.txt + - "test-dir": dir-for-copying + - "test-recursive-dir": dir-for-recusive-copying/** diff --git a/docs/level-2-template-inheritance/data.yml b/docs/level-2-template-inheritance/data.yml index 0d8e794f..bb56b055 100644 --- a/docs/level-2-template-inheritance/data.yml +++ b/docs/level-2-template-inheritance/data.yml @@ -1 +1 @@ -hello: world \ No newline at end of file +hello: world diff --git a/docs/level-3-data-override/.moban.cd/data.base.yaml b/docs/level-3-data-override/.moban.cd/data.base.yaml index 2c16d47a..3a35fadb 100644 --- a/docs/level-3-data-override/.moban.cd/data.base.yaml +++ b/docs/level-3-data-override/.moban.cd/data.base.yaml @@ -1,2 +1,2 @@ nihao: shijie -hello: shijie \ No newline at end of file +hello: shijie diff --git a/docs/level-3-data-override/data.yml b/docs/level-3-data-override/data.yml index 7813e820..168bfb12 100644 --- a/docs/level-3-data-override/data.yml +++ b/docs/level-3-data-override/data.yml @@ -1,2 +1,2 @@ overrides: data.base.yaml -hello: world \ No newline at end of file +hello: world diff --git a/docs/level-5-custom-configuration/custom-config/data.base.yaml b/docs/level-5-custom-configuration/custom-config/data.base.yaml index 2c16d47a..3a35fadb 100644 --- a/docs/level-5-custom-configuration/custom-config/data.base.yaml +++ b/docs/level-5-custom-configuration/custom-config/data.base.yaml @@ -1,2 +1,2 @@ nihao: shijie -hello: shijie \ No newline at end of file +hello: shijie diff --git a/docs/level-5-custom-configuration/data.yml b/docs/level-5-custom-configuration/data.yml index 7813e820..168bfb12 100644 --- a/docs/level-5-custom-configuration/data.yml +++ b/docs/level-5-custom-configuration/data.yml @@ -1,2 +1,2 @@ overrides: data.base.yaml -hello: world \ No newline at end of file +hello: world diff --git a/docs/level-6-complex-configuration/custom-config/data.base.yaml b/docs/level-6-complex-configuration/custom-config/data.base.yaml index 2c16d47a..3a35fadb 100644 --- a/docs/level-6-complex-configuration/custom-config/data.base.yaml +++ b/docs/level-6-complex-configuration/custom-config/data.base.yaml @@ -1,2 +1,2 @@ nihao: shijie -hello: shijie \ No newline at end of file +hello: shijie diff --git a/docs/level-6-complex-configuration/data.yml b/docs/level-6-complex-configuration/data.yml index 7813e820..168bfb12 100644 --- a/docs/level-6-complex-configuration/data.yml +++ b/docs/level-6-complex-configuration/data.yml @@ -1,2 +1,2 @@ overrides: data.base.yaml -hello: world \ No newline at end of file +hello: world diff --git a/docs/level-6-complex-configuration/data2.yml b/docs/level-6-complex-configuration/data2.yml index 3653190d..e75891e6 100644 --- a/docs/level-6-complex-configuration/data2.yml +++ b/docs/level-6-complex-configuration/data2.yml @@ -1,2 +1,2 @@ overrides: data.base.yaml -hello: world2 \ No newline at end of file +hello: world2 diff --git a/docs/level-8-pass-a-folder-full-of-templates/config/level8.yml b/docs/level-8-pass-a-folder-full-of-templates/config/level8.yml index f888746d..696cde50 100644 --- a/docs/level-8-pass-a-folder-full-of-templates/config/level8.yml +++ b/docs/level-8-pass-a-folder-full-of-templates/config/level8.yml @@ -1 +1 @@ -a: "test" \ No newline at end of file +a: "test" diff --git a/docs/level-9-moban-dependency-as-pypi-package/.moban.yml b/docs/level-9-moban-dependency-as-pypi-package/.moban.yml index 1e67684f..63fbe12f 100644 --- a/docs/level-9-moban-dependency-as-pypi-package/.moban.yml +++ b/docs/level-9-moban-dependency-as-pypi-package/.moban.yml @@ -1,5 +1,5 @@ requires: - - pypi-mobans-pkg + - pypi-mobans-pkg configuration: template_dir: - "pypi-mobans-pkg:templates" diff --git a/docs/misc-1-copying-templates/.moban.yml b/docs/misc-1-copying-templates/.moban.yml index 71d8a3f2..7a895f1b 100644 --- a/docs/misc-1-copying-templates/.moban.yml +++ b/docs/misc-1-copying-templates/.moban.yml @@ -3,6 +3,7 @@ configuration: - template-sources copy: - simple.file.copy: file-in-template-sources-folder.txt - - "misc-1-copying/can-create-folder/if-not-exists.txt": file-in-template-sources-folder.txt + - "misc-1-copying/can-create-folder/if-not-exists.txt": + file-in-template-sources-folder.txt - "test-dir": dir-for-copying - "test-recursive-dir": dir-for-recusive-copying/** diff --git a/lint.sh b/lint.sh index b53891e2..08f7c655 100644 --- a/lint.sh +++ b/lint.sh @@ -1 +1 @@ -flake8 . --exclude=.moban.d,docs --ignore=E203,E121,E123,E126,E226,E24,E704,W503,W504 +flake8 --max-line-length=88 --exclude=.moban.d,docs --ignore=W503,W504 diff --git a/min_requirements.txt b/min_requirements.txt index 3f7c2ca6..b5c854ba 100644 --- a/min_requirements.txt +++ b/min_requirements.txt @@ -1,7 +1,10 @@ -ruamel.yaml==0.15.5 +ruamel.yaml==0.15.5;python_version == '3.4' +ruamel.yaml==0.15.42;python_version == '3.7' +ruamel.yaml==0.15.5;python_version != '3.4' and python_version < '3.7' +ruamel.yaml==0.15.98;python_version == '3.8' jinja2==2.7.1 lml==0.0.9 appdirs==1.2.0 crayons== 0.1.0 GitPython==2.0.0 -giturlparse==0.9.1 +git-url-parse==1.2.2 diff --git a/moban/_version.py b/moban/_version.py index de146422..b407eb3a 100644 --- a/moban/_version.py +++ b/moban/_version.py @@ -1,2 +1,2 @@ -__version__ = "0.4.5" +__version__ = "0.5.0" __author__ = "C. W." diff --git a/moban/hashstore.py b/moban/hashstore.py index 17c9efd9..25b72518 100644 --- a/moban/hashstore.py +++ b/moban/hashstore.py @@ -65,6 +65,8 @@ def get_file_hash(afile): def get_hash(content): md5 = hashlib.md5() + if PY2 and content.__class__.__name__ == "unicode": + content = content.encode("utf-8") md5.update(content) return md5.digest().decode("latin1") diff --git a/moban/repo.py b/moban/repo.py index c614aeeb..02fdd6de 100644 --- a/moban/repo.py +++ b/moban/repo.py @@ -44,14 +44,12 @@ def git_clone(requires): def get_repo_name(repo_url): import giturlparse + from giturlparse.parser import ParserError try: - repo = giturlparse.parse(repo_url) - name = repo.repo - if name.endswith("/"): - name = name[:-1] - return name - except AttributeError: + repo = giturlparse.parse(repo_url.rstrip("/")) + return repo.name + except ParserError: reporter.report_error_message( constants.MESSAGE_INVALID_GIT_URL % repo_url ) diff --git a/moban/reporter.py b/moban/reporter.py index b706ef79..e79ad989 100644 --- a/moban/reporter.py +++ b/moban/reporter.py @@ -1,6 +1,5 @@ -import moban.constants as constants - import crayons +import moban.constants as constants MESSAGE_TEMPLATING = "Templating {0} to {1}" MESSAGE_UP_TO_DATE = "Everything is up to date!" diff --git a/moban/utils.py b/moban/utils.py index 3c498c95..87e0f63b 100644 --- a/moban/utils.py +++ b/moban/utils.py @@ -7,6 +7,7 @@ from moban import constants, exceptions log = logging.getLogger(__name__) +PY2 = sys.version_info[0] == 2 def merge(left, right): @@ -60,6 +61,8 @@ def file_permissions(afile): def write_file_out(filename, content): + if PY2 and content.__class__.__name__ == "unicode": + content = content.encode("utf-8") dest_folder = os.path.dirname(filename) if dest_folder: mkdir_p(dest_folder) diff --git a/mobanfile b/mobanfile index 2360459b..38d82987 100644 --- a/mobanfile +++ b/mobanfile @@ -1,8 +1,11 @@ requires: - - pypi-mobans-pkg + - type: git + url: https://github.com/moremoban/pypi-mobans + submodule: true + branch: dev configuration: template_dir: - - "setupmobans:templates" + - "pypi-mobans:templates" - ".moban.d" configuration: moban.yml targets: @@ -10,7 +13,7 @@ targets: - moban/__init__.py: __init__.py.jj2 - moban/_version.py: _version.py.jj2 - docs/conf.py: custom_conf.py.jj2 - - .travis.yml: travis.yml + - .travis.yml: moban_travis.yml.jj2 - requirements.txt: requirements.txt.jj2 - .gitignore: moban_gitignore.jj2 - output: CHANGELOG.rst diff --git a/requirements.txt b/requirements.txt index 7dd42624..2305c66a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,10 @@ -ruamel.yaml>=0.15.5 +ruamel.yaml>=0.15.5,<=0.15.94;python_version == '3.4' +ruamel.yaml>=0.15.42;python_version == '3.7' +ruamel.yaml>=0.15.5;python_version != '3.4' and python_version < '3.7' +ruamel.yaml>=0.15.98;python_version == '3.8' jinja2>=2.7.1 lml>=0.0.9 appdirs>=1.2.0 crayons>= 0.1.0 GitPython>=2.0.0 -giturlparse>=0.9.1 +git-url-parse>=1.2.2 diff --git a/setup.py b/setup.py index 06ee131a..a7564107 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,15 @@ from shutil import rmtree from setuptools import Command, find_packages, setup +from setuptools import __version__ as setuptools_version +from pkg_resources import parse_version + +import pkg_resources + +try: + import _markerlib.markers +except ImportError: + _markerlib = None PY2 = sys.version_info[0] == 2 PY26 = PY2 and sys.version_info[1] < 7 @@ -29,15 +38,25 @@ NAME = "moban" AUTHOR = "C. W." -VERSION = "0.4.5" +VERSION = "0.5.0" EMAIL = "wangc_2011@hotmail.com" LICENSE = "MIT" -ENTRY_POINTS = {"console_scripts": ["moban = moban.main:main"]} -DESCRIPTION = "Yet another jinja2 cli command for static text generation" +ENTRY_POINTS = { + "console_scripts": [ + "moban = moban.main:main" + ], +} +DESCRIPTION = ( + "Yet another jinja2 cli command for static text generation" +) URL = "https://github.com/moremoban/moban" -DOWNLOAD_URL = "%s/archive/0.4.5.tar.gz" % URL +DOWNLOAD_URL = "%s/archive/0.5.0.tar.gz" % URL FILES = ["README.rst", "CONTRIBUTORS.rst", "CHANGELOG.rst"] -KEYWORDS = ["python", "jinja2", "moban"] +KEYWORDS = [ + "python", + "jinja2", + "moban", +] CLASSIFIERS = [ "Topic :: Software Development :: Libraries", @@ -49,36 +68,39 @@ "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + ] INSTALL_REQUIRES = [ - "ruamel.yaml>=0.15.5", "jinja2>=2.7.1", "lml>=0.0.9", "appdirs>=1.2.0", "crayons>= 0.1.0", "GitPython>=2.0.0", - "giturlparse>=0.9.1", + "git-url-parse>=1.2.2", ] SETUP_COMMANDS = {} PACKAGES = find_packages(exclude=["ez_setup", "examples", "tests"]) -EXTRAS_REQUIRE = {} +EXTRAS_REQUIRE = { + ":python_version == '3.4'": ["ruamel.yaml>=0.15.5,<=0.15.94"], + ":python_version == '3.7'": ["ruamel.yaml>=0.15.42"], + ":python_version != '3.4' and python_version < '3.7'": ["ruamel.yaml>=0.15.5"], + ":python_version == '3.8'": ["ruamel.yaml>=0.15.98"], +} # 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.5 " + "Find 0.4.5 in changelog for more details" -NO_GS_MESSAGE = ( - "Automatic github release is disabled. " - + "Please install gease to enable it." -) +PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable) +GS_COMMAND = ("gs moban v0.5.0 " + + "Find 0.5.0 in changelog for more details") +NO_GS_MESSAGE = ("Automatic github release is disabled. " + + "Please install gease to enable it.") UPLOAD_FAILED_MSG = ( - 'Upload failed. please run "%s" yourself.' % PUBLISH_COMMAND -) + 'Upload failed. please run "%s" yourself.' % PUBLISH_COMMAND) HERE = os.path.abspath(os.path.dirname(__file__)) @@ -121,7 +143,9 @@ def run(self): sys.exit() -SETUP_COMMANDS.update({"publish": PublishCommand}) +SETUP_COMMANDS.update({ + "publish": PublishCommand +}) def has_gease(): @@ -132,7 +156,6 @@ def has_gease(): """ try: import gease # noqa - return True except ImportError: return False @@ -180,6 +203,48 @@ def filter_out_test_code(file_handle): yield line +# _markerlib.default_environment() obtains its data from _VARS +# and wraps it in another dict, but _markerlib_evaluate writes +# to the dict while it is iterating the keys, causing an error +# on Python 3 only. +# Replace _markerlib.default_environment to return a custom dict +# that has all the necessary markers, and ignores any writes. + +class Python3MarkerDict(dict): + + def __setitem__(self, key, value): + pass + + def pop(self, i=-1): + return self[i] + + +if _markerlib and sys.version_info[0] == 3: + env = _markerlib.markers._VARS + for key in list(env.keys()): + new_key = key.replace(".", "_") + if new_key != key: + env[new_key] = env[key] + + _markerlib.markers._VARS = Python3MarkerDict(env) + + def default_environment(): + return _markerlib.markers._VARS + + _markerlib.default_environment = default_environment + +# Avoid the very buggy pkg_resources.parser, which does not consistently +# recognise the markers needed by this setup.py +# See https://github.com/pypa/packaging/issues/72 for details +# Change this to setuptools 20.10.0 to support all markers. +if pkg_resources: + if parse_version(setuptools_version) < parse_version("18.5"): + MarkerEvaluation = pkg_resources.MarkerEvaluation + + del pkg_resources.parser + pkg_resources.evaluate_marker = MarkerEvaluation._markerlib_evaluate + MarkerEvaluation.evaluate_marker = MarkerEvaluation._markerlib_evaluate + if __name__ == "__main__": setup( test_suite="tests", @@ -201,5 +266,5 @@ def filter_out_test_code(file_handle): zip_safe=False, entry_points=ENTRY_POINTS, classifiers=CLASSIFIERS, - cmdclass=SETUP_COMMANDS, + cmdclass=SETUP_COMMANDS ) diff --git a/test.bat b/test.bat index 7f79f8f4..399c6eda 100644 --- a/test.bat +++ b/test.bat @@ -1,3 +1,9 @@ pip freeze -nosetests --with-coverage --cover-package=moban --cover-package=tests && flake8 . --exclude=docs,.moban.d --ignore=E203,E121,E123,E126,E226,E24,E704,W503,W504 +nosetests --with-coverage --cover-package=moban --cover-package=tests || goto :error + +flake8 --max-line-length=88 --exclude=docs,.moban.d --ignore=W503,W504 || goto :error + +:error +echo Failed with error #%errorlevel%. +exit /b %errorlevel% diff --git a/tests/fixtures/.moban-2.yml b/tests/fixtures/.moban-2.yml index 5a3af05d..59ed39fc 100644 --- a/tests/fixtures/.moban-2.yml +++ b/tests/fixtures/.moban-2.yml @@ -1,5 +1,5 @@ requires: - - pypi-mobans-pkg + - pypi-mobans-pkg configuration: configuration_dir: "setupmobans:config" template_dir: diff --git a/tests/fixtures/.moban.yml b/tests/fixtures/.moban.yml index 61880192..182a0293 100644 --- a/tests/fixtures/.moban.yml +++ b/tests/fixtures/.moban.yml @@ -1,5 +1,5 @@ requires: - - pypi-mobans-pkg + - pypi-mobans-pkg configuration: template_dir: - "setupmobans:templates" diff --git a/tests/fixtures/child.yaml b/tests/fixtures/child.yaml index 969a4747..4b082225 100644 --- a/tests/fixtures/child.yaml +++ b/tests/fixtures/child.yaml @@ -1,2 +1,2 @@ overrides: base.yaml -key: hello world \ No newline at end of file +key: hello world diff --git a/tests/fixtures/globals/basic.yml b/tests/fixtures/globals/basic.yml index 4f804496..6268fdfc 100644 --- a/tests/fixtures/globals/basic.yml +++ b/tests/fixtures/globals/basic.yml @@ -1 +1 @@ -globals: test \ No newline at end of file +globals: test diff --git a/tests/fixtures/globals/variables.yml b/tests/fixtures/globals/variables.yml index a0067b10..08f1fe69 100644 --- a/tests/fixtures/globals/variables.yml +++ b/tests/fixtures/globals/variables.yml @@ -1 +1 @@ -test: here \ No newline at end of file +test: here diff --git a/tests/fixtures/jinja_tests/file_tests.yml b/tests/fixtures/jinja_tests/file_tests.yml index a0067b10..08f1fe69 100644 --- a/tests/fixtures/jinja_tests/file_tests.yml +++ b/tests/fixtures/jinja_tests/file_tests.yml @@ -1 +1 @@ -test: here \ No newline at end of file +test: here diff --git a/tests/fixtures/mobanengine/sample_template_type.yml b/tests/fixtures/mobanengine/sample_template_type.yml index 60eeb617..75e6d268 100644 --- a/tests/fixtures/mobanengine/sample_template_type.yml +++ b/tests/fixtures/mobanengine/sample_template_type.yml @@ -1,10 +1,10 @@ template_types: custom_jinja: - base_type: jinja2 # use base_type, instead of overrides - file_extensions: - - moban - - new - - demo_file_suffix - options: - extensions: - - jinja2.ext.do + base_type: jinja2 # use base_type, instead of overrides + file_extensions: + - moban + - new + - demo_file_suffix + options: + extensions: + - jinja2.ext.do diff --git a/tests/fixtures/orphan.yaml b/tests/fixtures/orphan.yaml index 9ac4627c..e831e1fc 100644 --- a/tests/fixtures/orphan.yaml +++ b/tests/fixtures/orphan.yaml @@ -1 +1 @@ -overrides: darkmatter.yaml \ No newline at end of file +overrides: darkmatter.yaml diff --git a/tests/fixtures/simple.yaml b/tests/fixtures/simple.yaml index 06e472d1..cfeb9d58 100644 --- a/tests/fixtures/simple.yaml +++ b/tests/fixtures/simple.yaml @@ -1 +1 @@ -simple: yaml \ No newline at end of file +simple: yaml diff --git a/tests/requirements.txt b/tests/requirements.txt index 2e86b007..a6b17478 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -2,9 +2,13 @@ nose codecov coverage mock +yamllint flake8 black;python_version>="3.6" isort;python_version>="3.6" moban-handlebars pypi-mobans-pkg +# arrow 0.14.0 doesnt support Python 3.4 +arrow<0.14.0;python_version=="3.4" +arrow;python_version!="3.4" jinja2_time diff --git a/tests/test_repo.py b/tests/test_repo.py index aa70beed..1c82e258 100644 --- a/tests/test_repo.py +++ b/tests/test_repo.py @@ -125,14 +125,16 @@ def test_update_existing_with_reference_parameter( def test_get_repo_name(): repos = [ - "https://github.com/sphinx-doc/sphinx", + "https://github.com/repo-abc-def/repo", "https://github.com/abc/repo", "https://github.com/abc/repo.git", "https://github.com/abc/repo/", - "git@github.com:moremoban/moban.git", + "git@github.com:abc/repo.git", + "git@bitbucket.org:abc/repo.git", + "git://github.com/abc/repo.git", ] actual = [get_repo_name(repo) for repo in repos] - expected = ["sphinx", "repo", "repo", "repo", "moban"] + expected = ["repo"] * len(repos) eq_(expected, actual)