Commit 0f4c6f2f authored by Christophe Benz's avatar Christophe Benz

Follow dbnomics-converters renames

management#93
parent 5c7a4b27
Pipeline #950 passed with stage
in 2 minutes and 54 seconds
......@@ -43,9 +43,8 @@ from dbnomics_converters.series import validate_series
provider = dict(
name='AMECO',
long_name="Annual macro-economic database of the European Commission's "
"Directorate General for Economic and Financial Affairs",
code='AMECO',
name="Annual macro-economic database of the European Commission",
region='World',
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'
......@@ -214,7 +213,7 @@ def main():
assert not args.full
subprocess.check_call(
['git', 'clone', source_repository_url, args.source_dir],
)
)
if not os.path.exists(args.target_dir):
if args.full:
......@@ -303,18 +302,18 @@ def main():
dataset_code = test_dataset_code
datasets_code.add(dataset_code)
dataset = dict(
codelists=dict(
dimensions_values_labels=dict(
freq={'a': 'Annually'},
geo={},
unit={},
),
concepts=dict(
dimensions_labels=dict(
freq='Frequency',
geo='Country',
unit='Unit',
),
dataset_code=dataset_code,
dimension_keys=['freq', 'unit', 'geo'],
dataset_code=dataset_code, # Will be renamed to `code` in `save_node`.
dimensions_codes_order=['freq', 'unit', 'geo'],
name=entry['TITLE'],
series=[],
)
......@@ -329,12 +328,12 @@ def main():
re.match('{}-\d+$'.format(re.escape(dataset_code)), dataset['dataset_code']), \
'Dataset code {} differs from {} but titles are the same'.format(
dataset_code, dataset['dataset_code'])
codelists = dataset['codelists']
dimensions_values_labels = dataset['dimensions_values_labels']
country_code = slugify(entry['CODE'].split('.', 1)[0])
codelists['geo'][country_code] = entry['COUNTRY'] # The country label
dimensions_values_labels['geo'][country_code] = entry['COUNTRY'] # The country label
unit_label = entry['UNIT'] or '-'
unit_code = slugify(unit_label) or '-'
codelists['unit'][unit_code] = unit_label
dimensions_values_labels['unit'][unit_code] = unit_label
# Save single series.
series = dict(
......@@ -344,7 +343,7 @@ def main():
unit=unit_code,
),
frequency='A',
key=entry['CODE'],
key=entry['CODE'], # Will be renamed to `code` in `save_node`.
name=entry['COUNTRY'], # TODO
)
series_values = [
......@@ -403,19 +402,25 @@ def save_node(dir, node):
elif node.get('category_code') is not None:
assert node.get('dataset_code') is None
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))
filename = 'category.json'
title = 'Category {} {}'.format(node['category_code'], node['name'])
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'))
filename = 'dataset.json'
title = 'Dataset {} {}'.format(node['dataset_code'], node['name'])
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'))
filename = 'series.json'
title = 'Series {} {}'.format(node['key'], node['name'])
title = 'Series {} {}'.format(node['code'], node['name'])
with open(os.path.join(dir, filename), 'w') as node_file:
json.dump(node, node_file, ensure_ascii=False, indent=2, sort_keys=True)
......
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