aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorZoran BoĆĄnjak <zoran.bosnjak@sloveniacontrol.si>2023-03-06 12:26:43 +0100
committerJaap Keuter <jaap.keuter@xs4all.nl>2023-03-10 17:03:45 +0000
commit3cbb56010270e210f3021be11c1f5b519c6911ae (patch)
treef6e7d9a33694170b0a86dfcc6d61763b9ddcd02c /tools
parent1e5514061d3f6caf8c375d59ebeb33e6551d63c4 (diff)
specs conversion minor update
Update for structure change introduced in revision #007b214 of asterix-specs.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/asterix/update-specs.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/asterix/update-specs.py b/tools/asterix/update-specs.py
index 62ea8445b6..6b235b02f5 100755
--- a/tools/asterix/update-specs.py
+++ b/tools/asterix/update-specs.py
@@ -683,6 +683,36 @@ class Output(object):
else:
self.f.write(line+'\n')
+def is_valid(spec):
+ """Check spec"""
+ def check_item(item):
+ if item['spare']:
+ return True
+ return check_variation(item['variation'])
+ def check_variation(variation):
+ t = variation['type']
+ if t == 'Element':
+ return True
+ elif t == 'Group':
+ return all([check_item(i) for i in variation['items']])
+ elif t == 'Extended':
+ n1 = variation['first']
+ n2 = variation['extents']
+ fx = variation['fx']
+ if fx != 'regular':
+ return False # 'iregular extended item'
+ return all([check_item(i) for i in variation['items']])
+ elif t == 'Repetitive':
+ return check_variation(variation['variation'])
+ elif t == 'Explicit':
+ return True
+ elif t == 'Compound':
+ items = [i for i in variation['items'] if i is not None]
+ return all([check_item(i) for i in items])
+ else:
+ raise Exception('unexpected variation type {}'.format(t))
+ return all([check_item(i) for i in spec['catalogue']])
+
def main():
parser = argparse.ArgumentParser(description='Process asterix specs files.')
parser.add_argument('paths', metavar='PATH', nargs='*',
@@ -703,6 +733,7 @@ def main():
jsons = [json.loads(i) for i in jsons]
jsons = sorted(jsons, key = lambda x: (x['number'], x['edition']['major'], x['edition']['minor']))
jsons = [spec for spec in jsons if spec['type'] == 'Basic']
+ jsons = [spec for spec in jsons if is_valid(spec)]
cats = list(set([x['number'] for x in jsons]))
latest_editions = {cat: sorted(