Skip to content
Snippets Groups Projects
Commit 346e89b3 authored by Virgile Gerecke's avatar Virgile Gerecke 🤘
Browse files

Added verification file

parent 673a08b5
1 merge request!5Verify
import json
content = json.loads(open('help.json').read())
d = {}
for key in content:
if key in d:
raise ValueError('Duplicated key {}'.format(key))
else:
d[key]=''
item=content[key]
if 'title' not in item:
raise ValueError('Missing key : title in {}'.format(key))
if 'description' not in item:
raise ValueError('Missing key : description in {}'.format(key))
if 'options' in item:
if len(item['options']) < 1:
raise ValueError('Empty options in {}'.format(key))
for option in item['options']:
if option not in content:
raise ValueError('Missing item {} in {}'.format(option, key))
elif 'action' not in item:
raise ValueError('Missing action in {}'.format(key))
# Check cycle
def run(key, content, path):
if key in path:
raise ValueError('Cycling path {}'.format(path))
path.append(key)
item=content[key]
if 'action' in item:
path.append(item['action'])
print(path)
return None
else:
for option in item['options']:
run(option, content, path.copy())
run('root', content, [])
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