ShaoHe Feng has uploaded a new change for review.
Change subject: check the syntaxs of optional parameters in json schema
......................................................................
check the syntaxs of optional parameters in json schema
There are so many syntaxs error of optional parameters define in
json schema
This patch can both check the descrption errors of optional parameters
missing #optional and the define error of optional parameters missing *
Change-Id: I94f92459ee8787780a54a510b6f8cc074fb2a235
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
M vdsm_api/process-schema.py
1 file changed, 17 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/46/10446/1
diff --git a/vdsm_api/process-schema.py b/vdsm_api/process-schema.py
index 8244995..5db6966 100755
--- a/vdsm_api/process-schema.py
+++ b/vdsm_api/process-schema.py
@@ -22,6 +22,11 @@
import sys
import re
import vdsmapi
+try:
+ from collections import OrderedDict
+ OrderedDict # make pyflakes happy
+except ImportError:
+ from ordereddict import OrderedDict
html_escape_table = {
"&": "&",
@@ -143,6 +148,18 @@
symbol[mode][name] = desc
# Track the name in case there is are multiple lines to append
last_arg = name
+ # check optional parameters
+ if desc.startswith('#optional '):
+ assert ('*' + name in symbol['data'].keys()), \
+ ('Define of %s optional parameter error:\n\t%s should '
+ 'start with *' % (symbol['name'], name))
+ if isinstance(symbol['data'], OrderedDict):
+ if '*' + name in symbol['data'].keys():
+ assert desc.startswith('#optional '), \
+ ('Description of %s optional parameter error:\n\t'
+ 'The description of optional parameter "%s"
'
+ 'should start with "#optional"' %
+ (symbol['name'], name))
else:
# Just append it to the last one we added
symbol[mode][last_arg] += ' ' + line
--
To view, visit
http://gerrit.ovirt.org/10446
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I94f92459ee8787780a54a510b6f8cc074fb2a235
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>