Skip to content

Commit

Permalink
Merge pull request #111 from moremoban/dev
Browse files Browse the repository at this point in the history
release 0.3.1
  • Loading branch information
chfw authored Nov 3, 2018
2 parents af29877 + 51f8351 commit 7d357b7
Show file tree
Hide file tree
Showing 47 changed files with 387 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Before raising the PR, here is a check list:

1) have you written unit tests for your code changes?
2) have you run "black -l 79 on_your_changed_files.py"?
2) have you run "make format"?
3) are you requesting to "dev"?
4) have you updated the change log?
5) do you think that you can understand your changes after 6 month?
Expand Down
10 changes: 10 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[settings]
line_length=79
known_first_party=lml, jinja2
indent=' '
multi_line_output=3
length_sort=1
forced_separate=django.contrib,django.utils
default_section=FIRSTPARTY
no_lines_before=LOCALFOLDER
sections=FUTURE,STDLIB,FIRSTPARTY,THIRDPARTY,LOCALFOLDER
6 changes: 6 additions & 0 deletions .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: moban
organisation: moremoban
releases:
- 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:
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.0
current_version: 0.3.0
release: 0.3.0
version: 0.3.1
current_version: 0.3.1
release: 0.3.1
branch: master
command_line_interface: "moban"
entry_point: "moban.main:main"
Expand Down
2 changes: 2 additions & 0 deletions .moban.d/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

{%block platform_block%}
{%endblock%}

{%block morefiles%} 'CONTRIBUTORS.rst',{%endblock%}
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Change log
================================================================================

0.3.1 - 02-11-2018
--------------------------------------------------------------------------------

Added
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `#97 <https://github.com/moremoban/moban/issues/97>`_: requires will clone a
repo if given. Note: only github, gitlab, bitbucket for now

0.3.0 - 27-18-2018
--------------------------------------------------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ $ pip install tests/requirements.txt
$ make
```

## In order to format the code automatically

you will need python 3.6 to run "make format"

When you enable travis-ci on your own account, you shall see travis-ci running a build on each of your pushed commit to your own fork.

## Steps for creating a Pull Request
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ update:

test:
bash test.sh

format:
isort -y $(find moban -name "*.py"|xargs echo) $(find tests -name "*.py"|xargs echo)
black -l 79 moban
black -l 79 tests
2 changes: 2 additions & 0 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This section covers the use cases for moban. Please check them out individually.
#. `Use custom jinja2 filter test n global`_
#. `Pass a folder full of templates`_
#. `Use pypi package as a moban dependency`_
#. `Use git repository as a moban dependency`_

.. _Jinja2 command line: level-1-jinja2-cli
.. _Template inheritance: level-2-template-inheritance
Expand All @@ -22,3 +23,4 @@ This section covers the use cases for moban. Please check them out individually.
.. _Use custom jinja2 filter test n global: level-7-use-custom-jinja2-filter-test-n-global
.. _Pass a folder full of templates: level-8-pass-a-folder-full-of-templates
.. _Use pypi package as a moban dependency: level-9-moban-dependency-as-pypi-package
.. _Use git repository as a moban dependency: level-10-moban-dependency-as-git-repo
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.0'
version = u'0.3.1'
# The full version, including alpha/beta/rc tags
release = u'0.3.0'
release = u'0.3.1'


# -- General configuration ---------------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions docs/level-10-moban-dependency-as-git-repo/.moban.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
requires:
- https://github.com/moremoban/pypi-mobans
configuration:
template_dir:
- "pypi-mobans:templates"
- local
configuration: config.yml
targets:
- mytravis.yml: travis.yml.jj2
- test.txt: demo.txt.jj2
26 changes: 26 additions & 0 deletions docs/level-10-moban-dependency-as-git-repo/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
level 10: moban dependency as git repo
================================================================================

Since the support to have a pypi package as dependency, the pro user of moban
find it more useful to have git repo so that the changes to static content
could get propagate as it happens using git push and git pull.

For now, github.com, gitlab.com and bitbucket.com are supported. Pull request
is welcome to add or improve this feature.


Here are the sample file::

requires:
- https://github.com/moremoban/pypi-mobans
configuration:
template_dir:
- "pypi-mobans:templates"
- local
configuration: config.yml
targets:
- mytravis.yml: travis.yml.jj2
- test.txt: demo.txt.jj2

where `requires` lead to a list of pypi packages. And when you refer to it,
please use "pypi-mobans:"
1 change: 1 addition & 0 deletions docs/level-10-moban-dependency-as-git-repo/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
level10: "moban dependency as git repo"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{level10}}
23 changes: 23 additions & 0 deletions docs/level-10-moban-dependency-as-git-repo/local/mytravis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
sudo: false
language: python
notifications:
email: false
python:
- pypy-5.3.1
- 3.7-dev
- 3.6
- 3.5
- 3.4
- 2.7
before_install:
- if [[ $TRAVIS_PYTHON_VERSION == "2.6" ]]; then pip install flake8==2.6.2; fi
- 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 -r rnd_requirements.txt ;
- pip install -r tests/requirements.txt
script:
- make test
after_success:
codecov
23 changes: 23 additions & 0 deletions docs/level-10-moban-dependency-as-git-repo/mytravis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
sudo: false
language: python
notifications:
email: false
python:
- pypy-5.3.1
- 3.7-dev
- 3.6
- 3.5
- 3.4
- 2.7
before_install:
- if [[ $TRAVIS_PYTHON_VERSION == "2.6" ]]; then pip install flake8==2.6.2; fi
- 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 -r rnd_requirements.txt ;
- pip install -r tests/requirements.txt
script:
- make test
after_success:
codecov
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import base64

from moban.extensions import JinjaFilter


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from moban.extensions import jinja_global


jinja_global('global', dict(hello='world'))
1 change: 0 additions & 1 deletion moban/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from moban.main import main


if __name__ == "__main__":
main()
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.0"
__version__ = "0.3.1"
__author__ = "C. W."
3 changes: 2 additions & 1 deletion moban/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os


# Configurations
PROGRAM_NAME = "moban"
PROGRAM_DESCRIPTION = (
Expand Down Expand Up @@ -49,6 +48,8 @@
# moban file version
MOBAN_VERSION = "moban_file_spec_version"
DEFAULT_MOBAN_VERSION = "1.0"
MOBAN_DIR_NAME_UNDER_USER_HOME = ".moban"
MOBAN_REPOS_DIR_NAME = "repos"

# error messages
ERROR_DATA_FILE_NOT_FOUND = "Both %s and %s does not exist"
Expand Down
39 changes: 30 additions & 9 deletions moban/engine.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import os
from collections import defaultdict

from jinja2 import Environment, FileSystemLoader
from lml.plugin import PluginManager, PluginInfo
from lml.loader import scan_plugins_regex
from moban.hashstore import HASH_STORE
from moban.extensions import JinjaFilterManager, JinjaTestManager
from moban.extensions import JinjaGlobalsManager, LibraryManager
from lml.plugin import PluginInfo, PluginManager

import moban.utils as utils
import moban.reporter as reporter
import moban.constants as constants
import moban.exceptions as exceptions
import moban.reporter as reporter
from moban.utils import get_template_path
from moban.hashstore import HASH_STORE
from moban.extensions import (
LibraryManager,
JinjaTestManager,
JinjaFilterManager,
JinjaGlobalsManager,
)

BUILTIN_EXENSIONS = [
"moban.filters.repr",
Expand Down Expand Up @@ -214,11 +220,26 @@ def expand_template_directories(dirs):

for directory in dirs:
if ":" in directory:
library_name, relative_path = directory.split(":")
library_path = LIBRARIES.resource_path_of(library_name)
yield os.path.join(library_path, relative_path)
library_or_repo_name, relative_path = directory.split(":")
potential_repo_path = os.path.join(
utils.get_moban_home(), library_or_repo_name
)
if os.path.exists(potential_repo_path):
# expand repo template path
if relative_path:
yield os.path.join(potential_repo_path, relative_path)
else:
yield potential_repo_path
else:
# expand pypi template path
library_path = LIBRARIES.resource_path_of(library_or_repo_name)
if relative_path:
yield os.path.join(library_path, relative_path)
else:
yield library_path
else:
yield directory
# local template path
yield os.path.abspath(directory)


def verify_the_existence_of_directories(dirs):
Expand Down
3 changes: 2 additions & 1 deletion moban/extensions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from lml.plugin import PluginManager, PluginInfo
from lml.plugin import PluginInfo, PluginManager

import moban.constants as constants


Expand Down
2 changes: 1 addition & 1 deletion moban/filters/github.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
from moban.extensions import JinjaFilter

from moban.extensions import JinjaFilter

GITHUB_REF_PATTERN = "`([^`]*?#[0-9]+)`"
ISSUE = "^.*?" + GITHUB_REF_PATTERN + ".*?$"
Expand Down
1 change: 1 addition & 0 deletions moban/filters/text.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re

from moban.extensions import JinjaFilter


Expand Down
1 change: 0 additions & 1 deletion moban/hashstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import moban.utils as utils
import moban.constants as constants


PY2 = sys.version_info[0] == 2


Expand Down
10 changes: 5 additions & 5 deletions moban/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import sys
import argparse

from moban.engine import ENGINES
from moban.hashstore import HASH_STORE
from moban.utils import merge, open_yaml
import moban.reporter as reporter
import moban.constants as constants
import moban.exceptions as exceptions
import moban.mobanfile as mobanfile
import moban.reporter as reporter
import moban.exceptions as exceptions
from moban.utils import merge, open_yaml
from moban.engine import ENGINES
from moban.hashstore import HASH_STORE


def main():
Expand Down
Loading

0 comments on commit 7d357b7

Please sign in to comment.