Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Before raising the PR, here is a check list:
5) do you think that you can understand your changes after 6 month?
5.1) can someone else understand your changes without your explanation?
6) are you pround of your code changes?
6.1) do you have the feeling of achievement?
6.1) do you have the feeling of achievement?
7) please add your name and github link to contributors.rst in alphabetical order.
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[settings]
line_length=79
known_first_party=lml, jinja2
known_first_party=lml, jinja2, ruamel.yaml
indent=' '
multi_line_output=3
length_sort=1
Expand Down
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: 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:
Expand Down
8 changes: 4 additions & 4 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.4.1
current_version: 0.3.4.1
release: 0.3.4.1
version: 0.3.5
current_version: 0.3.5
release: 0.3.5
branch: master
command_line_interface: "moban"
entry_point: "moban.main:main"
Expand All @@ -15,7 +15,7 @@ keywords:
- jinja2
- moban
dependencies:
- pyyaml>=3.11
- ruamel.yaml
- jinja2>=2.7.1
- lml>=0.0.7
- crayons
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Change log
================================================================================

0.3.5 - 10-12-2018
--------------------------------------------------------------------------------

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

#. `#37 <https://github.com/moremoban/moban/issues/37>`_: moban will report line
number where the value is empty and the name of mobanfile. Switch from pyyaml
to ruamel.yaml.

0.3.4.1 - 28-11-2018
--------------------------------------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ In alphabetical order:

* `Charlie Liu <https://github.com/CLiu13>`_
* `John Vandenberg <https://github.com/jayvdb>`_
* `Joshua Chung <https://github.com/seeeturtle>`_
* `PRAJWAL M <https://github.com/PrajwalM2212>`_
* `SerekKiri <https://github.com/SerekKiri>`_
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.4.1'
version = u'0.3.5'
# The full version, including alpha/beta/rc tags
release = u'0.3.4.1'
release = u'0.3.5'


# -- General configuration ---------------------------------------------------
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.4.1"
__version__ = "0.3.5"
__author__ = "C. W."
1 change: 1 addition & 0 deletions moban/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
ERROR_INVALID_MOBAN_FILE = "%s is an invalid yaml file."
ERROR_NO_TARGETS = "No targets in %s"
ERROR_NO_TEMPLATE = "No template found"
ERROR_MALFORMED_YAML = "Empty value in %s at line %s"


# Shell messages
Expand Down
23 changes: 23 additions & 0 deletions moban/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def handle_moban_file(moban_file, options):
raise exceptions.MobanfileGrammarException(
constants.ERROR_NO_TARGETS % moban_file
)
check_none(moban_file_configurations, moban_file)
version = moban_file_configurations.get(
constants.MOBAN_VERSION, constants.DEFAULT_MOBAN_VERSION
)
Expand All @@ -125,6 +126,28 @@ def handle_moban_file(moban_file, options):
HASH_STORE.save_hashes()


def check_none(data, moban_file):
"""
check whether the yaml data has empty value such as:
"""
if isinstance(data, dict):
for k, v in data.items():
if check_none(v, moban_file) is None:
loc = data.lc.key(k)
raise exceptions.MobanfileGrammarException(
constants.ERROR_MALFORMED_YAML
% (moban_file, loc[0] + 1) # line number starts from 0
)
elif isinstance(data, list):
for i, x in enumerate(data):
if check_none(x, moban_file) is None:
loc = data.lc.item(i)
raise exceptions.MobanfileGrammarException(
constants.ERROR_MALFORMED_YAML % (moban_file, loc[0] + 1)
)
return data


def handle_command_line(options):
"""
act upon command options
Expand Down
4 changes: 3 additions & 1 deletion moban/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import stat
import errno

import yaml
from ruamel.yaml import YAML

import moban.reporter as reporter
import moban.constants as constants
import moban.exceptions as exceptions
Expand Down Expand Up @@ -37,6 +38,7 @@ def open_yaml(base_dir, file_name):
"""
the_yaml_file = search_file(base_dir, file_name)
with open(the_yaml_file, "r") as data_yaml:
yaml = YAML(typ="rt")
data = yaml.load(data_yaml)
if data is not None:
parent_data = None
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pyyaml>=3.11
ruamel.yaml
jinja2>=2.7.1
lml>=0.0.7
crayons
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

NAME = 'moban'
AUTHOR = 'C. W.'
VERSION = '0.3.4.1'
VERSION = '0.3.5'
EMAIL = 'wangc_2011@hotmail.com'
LICENSE = 'MIT'
ENTRY_POINTS = {
Expand All @@ -25,7 +25,7 @@
'Yet another jinja2 cli command for static text generation'
)
URL = 'https://github.com/moremoban/moban'
DOWNLOAD_URL = '%s/archive/0.3.4.1.tar.gz' % URL
DOWNLOAD_URL = '%s/archive/0.3.5.tar.gz' % URL
FILES = ['README.rst', 'CONTRIBUTORS.rst', 'CHANGELOG.rst']
KEYWORDS = [
'python',
Expand All @@ -46,7 +46,7 @@
]

INSTALL_REQUIRES = [
'pyyaml>=3.11',
'ruamel.yaml',
'jinja2>=2.7.1',
'lml>=0.0.7',
'crayons',
Expand All @@ -60,8 +60,8 @@
# 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.3.4.1 ' +
"Find 0.3.4.1 in changelog for more details")
GS_COMMAND = ('gs moban v0.3.5 ' +
"Find 0.3.5 in changelog for more details")
NO_GS_MESSAGE = ('Automatic github release is disabled. ' +
'Please install gease to enable it.')
UPLOAD_FAILED_MSG = (
Expand Down
37 changes: 36 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import moban.exceptions as exceptions
from mock import patch
from nose.tools import raises
from nose.tools import raises, assert_raises


class TestException:
Expand All @@ -30,6 +30,41 @@ def test_handle_moban_file(self):

main.handle_moban_file(self.moban_file, {})

def test_check_none(self):
import moban.main as main
from ruamel.yaml import YAML

yaml = YAML()

invalid_data = [
"""targets:
- output:""",
"""configuration:
template_dir:
- cool-templates
-""",
]

valid_data = [
"""targets:
- output: template""",
"""configuration:
template_dir:
- cool-templates
- custom-templates""",
]

for data in (yaml.load(d) for d in invalid_data):
assert_raises(
exceptions.MobanfileGrammarException,
main.check_none,
data,
".moban.yaml",
)

for data in (yaml.load(d) for d in valid_data):
main.check_none(data, ".moban.yaml")

@raises(exceptions.MobanfileGrammarException)
def test_version_1_is_recognized(self):
copyfile(
Expand Down