Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cc5e00a
:sparkles: initial prototype for any data loader
chfw Jan 18, 2019
dd4a4fd
:newspaper: add missing files
chfw Jan 20, 2019
a22539a
:sparkles: any data loader. in theory, any data with similar schema c…
chfw Jan 22, 2019
7c9706f
:hammer: code refactoring on data loader
chfw Jan 22, 2019
d87311d
:newspaper: add missing file
chfw Jan 22, 2019
2e6aefc
:microscope: fix unit test failure on python 2
chfw Jan 22, 2019
a309bf7
✨ Add `-v` to show current moban version
CLiu13 Jan 19, 2019
17c1a1b
Merge pull request #179 from CLiu13/version-number
chfw Jan 23, 2019
e1b2782
:books: update documentation
chfw Jan 23, 2019
1aaba7f
:books: update tutorial on data loader extensions
chfw Jan 24, 2019
b064658
:bug: python 2.7 thinks json.py is built-in json module
chfw Jan 24, 2019
ca79642
:handshake: Merge branch 'dev' into any-data-parsers
chfw Jan 24, 2019
21183fa
:books: update change log and pump version number
chfw Jan 24, 2019
5c1d5bf
:bug: Python 2 hates module name with '-' mixed
chfw Jan 24, 2019
e1d07fd
:fire: remove python 3.4 as test target
chfw Jan 24, 2019
d28718b
:bug: python 2.7 wanted __init__.py in plugin dir
chfw Jan 24, 2019
7e721e8
:fire: remove the unwanted folder name change and :books: update the …
chfw Jan 24, 2019
55e8d50
:hammer: refactor test docs code
chfw Jan 24, 2019
77a6eb5
:bug: update custom data loader plugin directory name
chfw Jan 24, 2019
4568124
:hammer: reformat code
chfw Jan 24, 2019
01d4102
:fire: remove rnd requirements as moban-handlebars have been updated
chfw Jan 24, 2019
dfbde16
:fire: remove traiing white spaces. black tool does not remove them
chfw Jan 24, 2019
1856d0a
:fire: now really kill off python 3.4 test target
chfw Jan 24, 2019
1b9f6cc
Merge pull request #181 from moremoban/any-data-parsers
chfw Jan 25, 2019
0226dd6
:bug: fix UnboundLocalError: local variable 'target' referenced befor…
chfw Jan 25, 2019
135ab8e
:tractor: relocated ~/.moban/repos to appdirs/user_cache_dir()/repos,…
chfw Jan 25, 2019
332d918
Merge pull request #182 from moremoban/fix-unbound-target
chfw Jan 26, 2019
f05fa43
Merge pull request #183 from moremoban/use-appdirs
chfw Jan 26, 2019
6833f55
:sparkles: feed in the missing changes from this branch
chfw Jan 28, 2019
ab77657
Merge pull request #197 from moremoban/use-appdirs
chfw Jan 28, 2019
41aa53a
:sparkles: initial prototype
chfw Jan 28, 2019
2b62d8c
:sparkles: replace barebone git with GitPython. fixed #169
chfw Jan 28, 2019
7849282
:hammer: code refactoring
chfw Jan 28, 2019
7bc5136
:hammer: code refactor test utils.py
chfw Jan 28, 2019
87a795b
:wheelchair: giving better log message
chfw Jan 28, 2019
aad375e
:books: update changelog
chfw Jan 28, 2019
aa06adb
Merge pull request #198 from moremoban/git-python
chfw Jan 30, 2019
fa4b19f
:hammer: code refactoring on git clone
chfw Jan 30, 2019
0d41805
:hammer: code refactoring on git clone functions
chfw Jan 31, 2019
7fb48f9
:sparkles: checkout default branch only and accept branch parameter i…
chfw Jan 31, 2019
f2cbee7
:green_heart: make pypy build pass as previous used 0.15.87
chfw Jan 31, 2019
93f833a
Merge pull request #210 from moremoban/single-branch-or-named-branch
chfw Jan 31, 2019
bfce80c
:sparkles: support git url in ssh syntax. resolves #207
chfw Jan 31, 2019
6feefa4
Merge pull request #211 from moremoban/git-ssh-syntax
chfw Jan 31, 2019
b7b0c18
:egg: :ferris_wheel: release 0.3.10
chfw Feb 2, 2019
0c86327
:muscle: add ayan-b into contributor list
chfw Feb 2, 2019
5a4d415
:books: minor update on readme
chfw Feb 2, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
name: moban
organisation: moremoban
releases:
- 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: 3.2.2019
version: 0.3.10
- changes:
- action: Updated
details:
Expand Down
13 changes: 8 additions & 5 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.9
current_version: 0.3.9
release: 0.3.9
version: 0.3.10
current_version: 0.3.10
release: 0.3.10
branch: master
command_line_interface: "moban"
entry_point: "moban.main:main"
Expand All @@ -15,9 +15,12 @@ keywords:
- jinja2
- moban
dependencies:
- ruamel.yaml
- ruamel.yaml==0.15.87
- jinja2>=2.7.1
- lml>=0.0.7
- lml>=0.0.9
- appdirs==1.4.3
- crayons
- GitPython==2.1.11
- git-url-parse
description: Yet another jinja2 cli command for static text generation
scm_host: github.com
1 change: 0 additions & 1 deletion .moban.d/travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ python:
- 3.7-dev
- 3.6
- 3.5
- 3.4
- 2.7
{%endblock%}
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ python:
- 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
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
Change log
================================================================================

0.3.10 - 3.2.2019
--------------------------------------------------------------------------------

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

#. `#174 <https://github.com/moremoban/moban/issues/174>`_: Store git cache in
XDG_CACHE_DIR
#. `#107 <https://github.com/moremoban/moban/issues/107>`_: Add -v to show
current moban version
#. `#164 <https://github.com/moremoban/moban/issues/164>`_: support additional
data formats

Updated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `#178 <https://github.com/moremoban/moban/issues/178>`_: UnboundLocalError:
local variable 'target' referenced before assignment
#. `#169 <https://github.com/moremoban/moban/issues/169>`_: uses GitPython
instead of barebone git commands

0.3.9 - 18-1-2019
--------------------------------------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Contributors

In alphabetical order:

* `Ayan Banerjee <https://github.com/ayan-b>`_
* `Charlie Liu <https://github.com/CLiu13>`_
* `John Vandenberg <https://github.com/jayvdb>`_
* `Joshua Chung <https://github.com/seeeturtle>`_
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Exit codes
--------------------------------------------------------------------------------
By default:

- 0 : no changes
- 0 : no error
- 1 : error occured

With `--exit-code`:
Expand Down
6 changes: 6 additions & 0 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ This section covers the use cases for moban. Please check them out individually.
#. `Use pypi package as a moban dependency`_
#. `Use git repository as a moban dependency`_
#. `Use handlebars template with moban`_
#. `Use template engine extensions`_
#. `Any data overrides any data`_
#. `Custom data loader`_

.. _Jinja2 command line: level-1-jinja2-cli
.. _Template inheritance: level-2-template-inheritance
Expand All @@ -26,3 +29,6 @@ This section covers the use cases for moban. Please check them out individually.
.. _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
.. _Use handlebars template with moban: level-11-use-handlebars
.. _Use template engine extensions: level-12-use-template-engine-extensions
.. _Any data overrides any data: level-13-any-data-override-any-data
.. _Custom data loader: level-14-custom-data-loader
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.9'
version = u'0.3.10'
# The full version, including alpha/beta/rc tags
release = u'0.3.9'
release = u'0.3.10'


# -- General configuration ---------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions docs/level-10-moban-dependency-as-git-repo/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ The alternative syntax is::
- type: git
url: https://github.com/your-git-url
submodule: true
branch: your_choice_or_default_branch_if_not_specified
...

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"nihao": "shijie from parent.json",
"hello": "shijie from parent.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nihao: shijie from parent.yaml
hello: shijie
9 changes: 9 additions & 0 deletions docs/level-13-any-data-override-any-data/.moban.td/base.jj2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{%block header %}
{%endblock%}

{{hello}}

{{nihao}}

{%block footer %}
{%endblock%}
52 changes: 52 additions & 0 deletions docs/level-13-any-data-override-any-data/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Level 13: any data override any data
================================================================================

It's thought that why shall we constrain ourselves on yaml file format. Along
the development path, json file format was added. What about other file formats?

By default yaml, json is supported. Due to the new capability `overrides` key
word can override any supported data format::

overrides: data.base.json
....

or simple use `.json` data instead of `.yaml` data.

Evaluation
--------------------------------------------------------------------------------

Please change directory to `docs/level-13-any-data-override-any-data` directory.

In this example, `child.yaml` overrides `.moban.cd/parent.json`, here is the
command to launch it:

.. code-block:: bash

moban -c child.yaml -t a.template

'moban.output' is the generated file::

========header============

world from child.yaml

shijie from parent.json

========footer============


And we can try `child.json`, which you can guess, overrides `.moban.cd/parent.yaml`

.. code-block:: bash

moban -c child.json -t a.template

'moban.output' is the generated file::

========header============

world from child.json

shijie from parent.yml

========footer============
9 changes: 9 additions & 0 deletions docs/level-13-any-data-override-any-data/a.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{%extends 'base.jj2' %}

{%block header %}
========header============
{%endblock%}

{%block footer %}
========footer============
{%endblock%}
4 changes: 4 additions & 0 deletions docs/level-13-any-data-override-any-data/child.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"overrides": "parent.yaml",
"hello": "world from child.json"
}
2 changes: 2 additions & 0 deletions docs/level-13-any-data-override-any-data/child.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
overrides: parent.json
hello: world from child.yaml
2 changes: 2 additions & 0 deletions docs/level-14-custom-data-loader/.moban.cd/parent.custom
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello,nihao
world from parent.cusom,shijie from parent.custom
4 changes: 4 additions & 0 deletions docs/level-14-custom-data-loader/.moban.cd/parent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"nihao": "shijie from parent.json",
"hello": "shijie from parent.json"
}
9 changes: 9 additions & 0 deletions docs/level-14-custom-data-loader/.moban.td/base.jj2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{%block header %}
{%endblock%}

{{hello}}

{{nihao}}

{%block footer %}
{%endblock%}
9 changes: 9 additions & 0 deletions docs/level-14-custom-data-loader/.moban.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
configuration:
plugin_dir:
- custom-data-loader
template: a.template
targets:
- output: a.output
configuration: child.custom
- output: b.output
configuration: override_custom.yaml
71 changes: 71 additions & 0 deletions docs/level-14-custom-data-loader/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Level 14: custom data loader
================================================================================

Continuing from level 13, `moban` since v0.4.0 allows data loader extension.
Due to the new capability `overrides` key word can override any
data format::

overrides: yours.custom
....

or simple use `.custom` data instead of `.yaml` data.

However, you will need to provide a data loader for `.custom` yourselves.

Evaluation
--------------------------------------------------------------------------------

Please change directory to `docs/level-14-custom-data-loader` directory.


In this tutorial, a custom data loader was provided to show case its dataloader
extension. Here is the mobanfile::

configuration:
plugin_dir:
- custom-data-loader
template: a.template
targets:
- output: a.output
configuration: child.custom
- output: b.output
configuration: override_custom.yaml

`custom-data-loader` is a directory where custom.py lives. The protocol is
that the custom loader register itself to a file extension and return
a data dictionary confirming mobanfile schema. On call, `moban` will provide
an absolute file name for your loader to work on.


Here is the code to do the registration:

.. code-block:: python

@PluginInfo(constants.DATA_LOADER_EXTENSION, tags=["custom"])


In order to evaluate, you can simply type::

$ moban
$ cat a.output
========header============

world from child.cusom

shijie from parent.json

========footer============
$ cat b.output
========header============

world from override_custom.yaml

shijie from parent.custom

========footer============


.. warning::

Python 2 dictates the existence of __init__.py in the plugin directory. Otheriwse
your plugin won't load
9 changes: 9 additions & 0 deletions docs/level-14-custom-data-loader/a.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{%extends 'base.jj2' %}

{%block header %}
========header============
{%endblock%}

{%block footer %}
========footer============
{%endblock%}
7 changes: 7 additions & 0 deletions docs/level-14-custom-data-loader/b.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
========header============

world from override_custom.yaml

shijie from parent.custom

========footer============
2 changes: 2 additions & 0 deletions docs/level-14-custom-data-loader/child.custom
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello,overrides
world from child.cusom,parent.json
Empty file.
17 changes: 17 additions & 0 deletions docs/level-14-custom-data-loader/custom-data-loader/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import csv

from lml.plugin import PluginInfo

from moban import constants


@PluginInfo(constants.DATA_LOADER_EXTENSION, tags=["custom"])
def open_custom(file_name):
with open(file_name, "r") as data_csv:
csvreader = csv.reader(data_csv)
rows = []
for row in csvreader:
rows.append(row)

data = dict(zip(rows[0], rows[1]))
return data
2 changes: 2 additions & 0 deletions docs/level-14-custom-data-loader/override_custom.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
overrides: parent.custom
hello: world from override_custom.yaml
2 changes: 1 addition & 1 deletion docs/level-3-data-override/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ command to launch it:

moban -c data.yaml -t a.template

'a.output' is the generated file::
'moban.output' is the generated file::

========header============

Expand Down
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.9"
__version__ = "0.3.10"
__author__ = "C. W."
Loading