Skip to content

Commit

Permalink
Merge branch 'master' of github.com:piranha/nomad
Browse files Browse the repository at this point in the history
  • Loading branch information
piranha committed Sep 10, 2013
2 parents 62adcbb + 768536b commit e7c011f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ python:
- "2.6" - "2.6"
- "2.7" - "2.7"
- "3.3" - "3.3"
install: "python setup.py install && pip install sqlalchemy cram" install: "python setup.py install && pip install sqlalchemy cram pyyaml"
script: "make test" script: "make test"
12 changes: 12 additions & 0 deletions nomad/utils.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ def get_ini(path):
raise KeyError('%s not found in %s' % (path, fn)) raise KeyError('%s not found in %s' % (path, fn))




def get_yaml(path):
try:
import yaml
except ImportError:
abort('Please, install PyYAML to parse YAML config.')
fn, path = path.split(':')
obj = yaml.load(open(fn))
path = map(lambda x: int(x) if x.isdigit() else x, path.split('.'))
return reduce(lambda x, y: x[y], path, obj)


URLTYPES = { URLTYPES = {
'python': get_python, 'python': get_python,
'py': get_python, 'py': get_python,
Expand All @@ -140,6 +151,7 @@ def get_ini(path):
'cmd': get_command, 'cmd': get_command,
'json': get_json, 'json': get_json,
'ini': get_ini, 'ini': get_ini,
'yaml': get_yaml,
} }




Expand Down
13 changes: 13 additions & 0 deletions tests/urls.t
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ URL from INI file::
<SAEngine: sqlite:///test-ini.db> <SAEngine: sqlite:///test-ini.db>
Uninitialized repository Uninitialized repository


URL from YAML file::

$ echo 'db:\n - url: sqlite:///test-yaml.db' > url.yaml
$ cat > nomad.ini <<EOF
> [nomad]
> engine = sqla
> url = yaml:url.yaml:db.0.url
> EOF
$ $NOMAD info
<Repository: .>:
<SAEngine: sqlite:///test-yaml.db>
Uninitialized repository

Nothing defined:: Nothing defined::


$ echo '[nomad]\nengine=sqla' > nomad.ini $ echo '[nomad]\nengine=sqla' > nomad.ini
Expand Down

0 comments on commit e7c011f

Please sign in to comment.