Commit 6025fdea authored by Klaus Zimmermann's avatar Klaus Zimmermann
Browse files

Link master table (closes #169)

This makes it easier to update the metadata with the newest version of the master table and also establishes a closer link with the master table by writing version information in the auto-generated metadata files.
parent 1e50fe1d
[submodule "cf-index-meta"]
path = cf-index-meta
url = https://bitbucket.org/cf-index-meta/cf-index-meta.git
cf-index-meta @ dd711a08
Subproject commit dd711a0899cbab93eb3dbf1537681211fcb1b4e4
......@@ -36,6 +36,7 @@ def parse_args():
description=(f'An editor for a climate index thing, '
f'version {climix.__version__}.'))
parser.add_argument('-f', '--force', action='store_true')
parser.add_argument('-t', '--table-version', default='<unknown>')
parser.add_argument('document')
return parser.parse_args()
......@@ -62,11 +63,13 @@ def main():
env = prepare_environment(args)
var_definition_template = env.get_template('variables.yml')
var_definitions = build_variables(args.document)
var_output = var_definition_template.render(variables=var_definitions)
var_output = var_definition_template.render(variables=var_definitions,
version=args.table_version)
idx_definition_template = env.get_template('index_definitions.yml')
idx_definitions = build_index_definitions(args.document)
idx_output = idx_definition_template.render(indices=idx_definitions)
idx_output = idx_definition_template.render(indices=idx_definitions,
version=args.table_version)
with opened_w_force('variables.yml', args.force) as outfile:
outfile.write(var_output)
......
# These index definitions are auto-generated from the master table at
# https://bitbucket.org/cf-index-meta/cf-index-meta
# This is based on version {{ version }}.
---
indices:
{% for idx in indices %}
{{ idx.var_name }}:
......
# These variables are auto-generated from the master table at
# https://bitbucket.org/cf-index-meta/cf-index-meta
# This is based on version {{ version }}.
---
variables:
{% for var in variables %}
{{ var.var_name }}:
......
......@@ -44,7 +44,7 @@ setuptools.setup(
'scitools-iris>=2.2.0',
],
extras_require={
'editor': ['pyexcel', 'pyexcel-odsr', 'jinja2']
'editor': ['pyexcel', 'pyexcel-xls', 'jinja2']
},
entry_points={
'console_scripts': [
......
#!/bin/bash
SCRIPT_DIR="$(dirname $(readlink -f "$0"))"
BASE_DIR="$SCRIPT_DIR/.."
TABLE_DIR="$BASE_DIR/cf-index-meta"
OUTPUT_DIR="$BASE_DIR/climix/etc"
(cd $BASE_DIR && git submodule update --remote)
TABLE_VERSION=$(cd $TABLE_DIR && git describe --dirty)
(cd $OUTPUT_DIR &&
climix-editor -t "$TABLE_VERSION" -f $TABLE_DIR/master_table.xls)
Supports Markdown
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