Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add YAML urls support

  • Loading branch information...
commit fd1a0df983223435c56a9e463b34a3d104e9c7fa 1 parent de08594
@vaxXxa vaxXxa authored
Showing with 26 additions and 1 deletion.
  1. +1 −1  .travis.yml
  2. +12 −0 nomad/utils.py
  3. +13 −0 tests/urls.t
View
2  .travis.yml
@@ -3,5 +3,5 @@ python:
- "2.6"
- "2.7"
- "3.3"
-install: "python setup.py install && pip install sqlalchemy cram"
+install: "python setup.py install && pip install sqlalchemy cram pyyaml"
script: "make test"
View
12 nomad/utils.py
@@ -132,6 +132,17 @@ def get_ini(path):
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 = {
'python': get_python,
'py': get_python,
@@ -140,6 +151,7 @@ def get_ini(path):
'cmd': get_command,
'json': get_json,
'ini': get_ini,
+ 'yaml': get_yaml,
}
View
13 tests/urls.t
@@ -122,6 +122,19 @@ URL from INI file::
<SAEngine: sqlite:///test-ini.db>
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::
$ echo '[nomad]\nengine=sqla' > nomad.ini
Please sign in to comment.
Something went wrong with that request. Please try again.