Commit e7c83dd7 authored by Christophe Benz's avatar Christophe Benz

Merge branch 'json-schemas'

parents 3dbebe18 210f3fad
Pipeline #1677 failed with stage
in 50 seconds
......@@ -37,8 +37,8 @@ job:
- if [ "${JOB}" == "download" ]; then ./ameco_fetcher.py --push ameco-source-data; fi
- |
if [ "${JOB}" == "convert" ]; then
git clone https://git.nomics.world/dbnomics/dbnomics-converters.git
cd dbnomics-converters
git clone https://git.nomics.world/dbnomics/dbnomics-data-model.git
cd dbnomics-data-model
pip3 install -e .
cd ..
./ameco_to_dbnomics.py --push ameco-source-data ameco-json-data
......
......@@ -35,17 +35,14 @@ import sys
from slugify import slugify
from dbnomics_converters.base import assert_no_error
from dbnomics_converters.categories import validate_category
from dbnomics_converters.datasets import validate_dataset
from dbnomics_converters.providers import validate_provider
from dbnomics_converters.series import validate_series
from dbnomics_data_model import validators
provider_code = 'AMECO'
provider = dict(
code='AMECO',
code=provider_code,
name="Annual macro-economic database of the European Commission",
region='World',
slug=slugify(provider_code),
terms_of_use='https://ec.europa.eu/info/legal-notice_en#copyright-notice',
website='https://ec.europa.eu/info/business-economy-euro/indicators-statistics/economic-databases'
'/macro-economic-database-ameco_en',
......@@ -338,7 +335,6 @@ def main():
geo=country_code,
unit=unit_code,
),
frequency='A',
key=entry['CODE'], # Will be renamed to `code` in `save_node`.
name=entry['COUNTRY'], # TODO
)
......@@ -390,7 +386,7 @@ def main():
def save_node(dir, node):
if node.get('category_code') is None and node.get('dataset_code') is None and node.get('key') is None:
node = assert_no_error(validate_provider(node, format='json'))
validators.validate_provider(node)
filename = 'provider.json'
title = 'Provider {}'.format(node['name'])
elif node.get('category_code') is not None:
......@@ -398,21 +394,21 @@ def save_node(dir, node):
assert node.get('key') is None
node['code'] = node['category_code']
del node['category_code']
node = assert_no_error(validate_category(node, format='json', used_categories_code=used_categories_code))
validators.validate_category(node)
filename = 'category.json'
title = 'Category {} {}'.format(node['code'], node['name'])
elif node.get('dataset_code') is not None:
assert node.get('key') is None
node['code'] = node['dataset_code']
del node['dataset_code']
node = assert_no_error(validate_dataset(node, format='json'))
validators.validate_dataset(node)
filename = 'dataset.json'
title = 'Dataset {} {}'.format(node['code'], node['name'])
else:
assert node.get('key') is not None
node['code'] = node['key']
del node['key']
node = assert_no_error(validate_series(node, format='json'))
validators.validate_series(node)
filename = 'series.json'
title = 'Series {} {}'.format(node['code'], node['name'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment