Skip to content

Commit 0ffa828

Browse files
committed
Added travis support.
1 parent c6ed595 commit 0ffa828

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

.travis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: python
2+
python:
3+
- 3.4
4+
install:
5+
- make setup
6+
script:
7+
- make validate
8+
notifications:
9+
email: false

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ setup:
22
pip install --quiet -r scripts/requirements-test.txt
33

44
validate: setup ## Validate data
5-
python scripts/jsonvalidate.py
5+
python scripts/validate_yaml.py
66

77
json: setup ## Generate JSON from YAML
88
python scripts/yaml2json.py < data/committees.yml > outputs/committees.json

scripts/validate_yaml.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from jsonschema import validate
2+
import jsonschema
3+
import json
4+
import yaml
5+
import os
6+
7+
schema_relpath = 'scripts/jsonschema/schemas/popolo/organization.json'
8+
schema_abspath = 'file://' + os.path.abspath(schema_relpath)
9+
10+
org_schema = json.load(open(schema_relpath, 'r'))
11+
12+
organizations = yaml.load(open('data/committees.yml', 'r'))
13+
14+
class patchedResolver(jsonschema.RefResolver):
15+
def __init__(self):
16+
jsonschema.RefResolver.__init__(self,
17+
base_uri = schema_abspath,
18+
referrer = None)
19+
self.store[schema_abspath] = org_schema
20+
21+
newResolver = patchedResolver()
22+
23+
for org in organizations:
24+
validate(org, org_schema, resolver=newResolver)

0 commit comments

Comments
 (0)