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
2 changes: 1 addition & 1 deletion .moban.cd/moban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ contact: wangc_2011@hotmail.com
license: MIT
version: 0.6.6
current_version: 0.6.6
release: 0.6.5
release: 0.6.6
branch: master
master: index
command_line_interface: "moban"
Expand Down
3 changes: 0 additions & 3 deletions .moban.d/custom_conf.py.jj2
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
{% include "conf.py.jj2" %}

master_doc = "index"
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# The short X.Y version
version = '0.6.6'
# The full version, including alpha/beta/rc tags
release = '0.6.5'
release = '0.6.6'

# -- General configuration ---------------------------------------------------

Expand Down Expand Up @@ -82,5 +82,4 @@
]
intersphinx_mapping.update({
})

master_doc = "index"
14 changes: 13 additions & 1 deletion moban/core/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def get_data(self, file_name):


def load_data(base_dir, file_name):

abs_file_path = search_file(base_dir, file_name)
data = LOADER.get_data(abs_file_path)
if data is not None:
Expand All @@ -38,7 +39,10 @@ def load_data(base_dir, file_name):
overrides = [overrides]
for parent_file in overrides:
file_name, key = parent_file, None
if ":" in parent_file:
results = match_fs_url(parent_file)
if results:
file_name, key = results
elif ":" in parent_file and "://" not in parent_file:
file_name, key = parent_file.split(":")
child_data = load_data(base_dir, file_name)
if data:
Expand Down Expand Up @@ -93,3 +97,11 @@ def search_file(base_dir, file_name):
else:
raise IOError(constants.ERROR_DATA_FILE_ABSENT % the_file)
return the_file


def match_fs_url(file_name):
import re

results = re.match("(.*://.*):(.*)", file_name)
if results:
return (results.group(1), results.group(2))
11 changes: 11 additions & 0 deletions moban/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@
import logging.config
from collections import defaultdict

from ruamel.yaml import YAML

from moban import constants, exceptions
from moban.core import ENGINES, plugins, hashstore, mobanfile, data_loader
from moban._version import __version__
from moban.externals import reporter, file_system
from moban.program_options import OPTIONS

try:
from cStringIO import StringIO
except ImportError:
from io import StringIO

LOG = logging.getLogger()
LOG_LEVEL = [logging.WARNING, logging.INFO, logging.DEBUG]

Expand Down Expand Up @@ -173,6 +180,10 @@ def handle_moban_file(moban_file, options):
act upon default moban file
"""
moban_file_configurations = data_loader.load_data(None, moban_file)
yaml = YAML(typ="rt")
dumped_yaml = StringIO()
yaml.dump(moban_file_configurations, dumped_yaml)
LOG.info(dumped_yaml.getvalue())
if moban_file_configurations is None:
raise exceptions.MobanfileGrammarException(
constants.ERROR_INVALID_MOBAN_FILE % moban_file
Expand Down
2 changes: 1 addition & 1 deletion mobanfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ targets:
- setup.py: moban_setup.py.jj2
- moban/__init__.py: __init__.py.jj2
- moban/_version.py: _version.py.jj2
- docs/conf.py: custom_conf.py.jj2
- docs/conf.py: conf.py.jj2
- .travis.yml: moban_travis.yml.jj2
- requirements.txt: requirements.txt.jj2
- .gitignore: moban_gitignore.jj2
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"Yet another jinja2 cli command for static text generation"
)
URL = "https://github.com/moremoban/moban"
DOWNLOAD_URL = "%s/archive/0.6.5.tar.gz" % URL
DOWNLOAD_URL = "%s/archive/0.6.6.tar.gz" % URL
FILES = ["README.rst", "CONTRIBUTORS.rst", "CHANGELOG.rst"]
KEYWORDS = [
"python",
Expand Down Expand Up @@ -97,8 +97,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.6.5 " +
"Find 0.6.5 in changelog for more details")
GS_COMMAND = ("gs moban v0.6.6 " +
"Find 0.6.6 in changelog for more details")
NO_GS_MESSAGE = ("Automatic github release is disabled. " +
"Please install gease to enable it.")
UPLOAD_FAILED_MSG = (
Expand Down
Empty file added tests/data_loaders/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion tests/data_loaders/test_json_loader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs.path
from nose.tools import eq_

from moban.data_loaders.json_loader import open_json
from moban.plugins.json_loader import open_json


def test_open_json():
Expand Down
10 changes: 9 additions & 1 deletion tests/data_loaders/test_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from nose.tools import eq_

from moban.data_loaders.manager import load_data
from moban.main import load_engine_factory_and_engines
from moban.core.data_loader import load_data


def test_overrides_a_list_of_config_files():
Expand Down Expand Up @@ -79,3 +80,10 @@ def test_overrides_nested_keys():
}

eq_(dict(actual), expected)


def test_overrides_fs_url():
load_engine_factory_and_engines()
base_dir = os.path.join("tests", "fixtures")
actual = load_data(None, os.path.join(base_dir, "override_fs_url.yaml"))
assert "requires" in actual
4 changes: 2 additions & 2 deletions tests/data_loaders/test_yaml_loader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs.path
from nose.tools import eq_, raises

from moban.data_loaders.yaml import open_yaml
from moban.data_loaders.manager import load_data
from moban.core.data_loader import load_data
from moban.plugins.yaml_loader import open_yaml


def test_simple_yaml():
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/override_fs_url.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
overrides: "git://github.com/moremoban/moban!/tests/fixtures/.moban.yml"
targets:
- my: test