mirror of https://github.com/xqemu/xqemu.git
qapi: Lift error reporting from QAPISchema.__init__() to callers
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20180211093607.27351-14-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
71a7510baf
commit
181feaf355
|
@ -8,7 +8,7 @@ from __future__ import print_function
|
||||||
import argparse
|
import argparse
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from qapi.common import QAPISchema
|
from qapi.common import QAPIError, QAPISchema
|
||||||
from qapi.types import gen_types
|
from qapi.types import gen_types
|
||||||
from qapi.visit import gen_visit
|
from qapi.visit import gen_visit
|
||||||
from qapi.commands import gen_commands
|
from qapi.commands import gen_commands
|
||||||
|
@ -39,7 +39,11 @@ def main(argv):
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
schema = QAPISchema(args.schema)
|
schema = QAPISchema(args.schema)
|
||||||
|
except QAPIError as err:
|
||||||
|
print(err, file=sys.stderr)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
gen_types(schema, args.output_dir, args.prefix, args.builtins)
|
gen_types(schema, args.output_dir, args.prefix, args.builtins)
|
||||||
gen_visit(schema, args.output_dir, args.prefix, args.builtins)
|
gen_visit(schema, args.output_dir, args.prefix, args.builtins)
|
||||||
|
|
|
@ -16,7 +16,6 @@ import errno
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
import sys
|
|
||||||
try:
|
try:
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
except:
|
except:
|
||||||
|
@ -1459,7 +1458,6 @@ class QAPISchemaEvent(QAPISchemaEntity):
|
||||||
|
|
||||||
class QAPISchema(object):
|
class QAPISchema(object):
|
||||||
def __init__(self, fname):
|
def __init__(self, fname):
|
||||||
try:
|
|
||||||
parser = QAPISchemaParser(open(fname, 'r'))
|
parser = QAPISchemaParser(open(fname, 'r'))
|
||||||
exprs = check_exprs(parser.exprs)
|
exprs = check_exprs(parser.exprs)
|
||||||
self.docs = parser.docs
|
self.docs = parser.docs
|
||||||
|
@ -1469,9 +1467,6 @@ class QAPISchema(object):
|
||||||
self._predefining = False
|
self._predefining = False
|
||||||
self._def_exprs(exprs)
|
self._def_exprs(exprs)
|
||||||
self.check()
|
self.check()
|
||||||
except QAPIError as err:
|
|
||||||
print(err, file=sys.stderr)
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
def _def_entity(self, ent):
|
def _def_entity(self, ent):
|
||||||
# Only the predefined types are allowed to not have info
|
# Only the predefined types are allowed to not have info
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
from qapi.common import QAPISchema, QAPISchemaVisitor
|
from qapi.common import QAPIError, QAPISchema, QAPISchemaVisitor
|
||||||
|
|
||||||
|
|
||||||
class QAPISchemaTestVisitor(QAPISchemaVisitor):
|
class QAPISchemaTestVisitor(QAPISchemaVisitor):
|
||||||
|
@ -52,7 +52,13 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
|
||||||
for v in variants.variants:
|
for v in variants.variants:
|
||||||
print(' case %s: %s' % (v.name, v.type.name))
|
print(' case %s: %s' % (v.name, v.type.name))
|
||||||
|
|
||||||
schema = QAPISchema(sys.argv[1])
|
|
||||||
|
try:
|
||||||
|
schema = QAPISchema(sys.argv[1])
|
||||||
|
except QAPIError as err:
|
||||||
|
print(err, file=sys.stderr)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
schema.visit(QAPISchemaTestVisitor())
|
schema.visit(QAPISchemaTestVisitor())
|
||||||
|
|
||||||
for doc in schema.docs:
|
for doc in schema.docs:
|
||||||
|
|
Loading…
Reference in New Issue