Commit 8c03c027 authored by M. Huang's avatar M. Huang
Browse files

auto update to yaml schemav1.6 with yamel2python

parent a0134629
...@@ -344,29 +344,35 @@ def output(nm, d, fins, version, verbose): ...@@ -344,29 +344,35 @@ def output(nm, d, fins, version, verbose):
def yamlupgrade(descriptors, fins, ypath, version, verbose): def yamlupgrade(descriptors, fins, ypath, version, verbose):
if float(version) > 1.0: if float(version) == 1.6:
for nm, daf in descriptors.items(): for nm, daf in descriptors.items():
d, attrs, datasets, fin = daf d, attrs, datasets, fin = daf
if float(d['schema']) >= float(version): if float(d['schema']) >= float(version):
print('No need to upgrade '+d['schema']) print('No need to upgrade '+d['schema'])
continue continue
d['schema'] = version d['schema'] = version
level = d.pop('level')
md = OrderedDict()
for pname, w in d['metadata'].items(): for pname, w in d['metadata'].items():
dt = w['data_type'] #dt = w['data_type']
# no dataset yet # no dataset yet
if dt in ['boolean', 'string', 'finetime']: if pname == 'type':
del w['unit'] v = w['default']
if dt == 'finetime': w.clear()
w['default'] = 0 w['default'] = v
if 'typecode' not in w: md[pname] = w
w['typecode'] = 'B' if dt == 'string' else None md['level'] = {'default': 'C' + level.upper()}
if pname == 'version': elif pname == 'FORMATV':
v = w['default'].replace('v', '') v = w['default'].split('.')
w['default'] = str(float(v) + 0.1) w.clear()
output(nm, d, fins, version, verbose) w['default'] = version + '.' + \
elif float(version) > 0.6: v[2] + '.' + str(int(v[3])+1)
# in:v0.6 and below out:v1.0 md[pname] = w
for nm, d in descriptors.items(): else:
md[pname] = w
d['metadata'] = md
if 'datasets' not in d:
d['datasets'] = {}
output(nm, d, fins, version, verbose) output(nm, d, fins, version, verbose)
...@@ -455,7 +461,7 @@ if __name__ == '__main__': ...@@ -455,7 +461,7 @@ if __name__ == '__main__':
print('product class generatiom') print('product class generatiom')
# schema version # schema version
version = '1.1' version = '1.6'
# Get input file name etc. from command line. defaut 'Product.yml' # Get input file name etc. from command line. defaut 'Product.yml'
cwd = os.path.abspath(os.getcwd()) cwd = os.path.abspath(os.getcwd())
......
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