[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 13/29] qapi: Lift error reporting from QAPISc
From: |
Michael Roth |
Subject: |
Re: [Qemu-devel] [PATCH v2 13/29] qapi: Lift error reporting from QAPISchema.__init__() to callers |
Date: |
Sun, 18 Feb 2018 17:17:05 -0600 |
User-agent: |
alot/0.6 |
Quoting Markus Armbruster (2018-02-11 03:35:51)
> Signed-off-by: Markus Armbruster <address@hidden>
> Reviewed-by: Marc-André Lureau <address@hidden>
Reviewed-by: Michael Roth <address@hidden>
> ---
> scripts/qapi-gen.py | 8 ++++++--
> scripts/qapi/common.py | 23 +++++++++--------------
> tests/qapi-schema/test-qapi.py | 10 ++++++++--
> 3 files changed, 23 insertions(+), 18 deletions(-)
>
> diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py
> index e5be484e3e..fea7d4589b 100755
> --- a/scripts/qapi-gen.py
> +++ b/scripts/qapi-gen.py
> @@ -8,7 +8,7 @@ from __future__ import print_function
> import argparse
> import re
> import sys
> -from qapi.common import QAPISchema
> +from qapi.common import QAPIError, QAPISchema
> from qapi.types import gen_types
> from qapi.visit import gen_visit
> from qapi.commands import gen_commands
> @@ -39,7 +39,11 @@ def main(argv):
> file=sys.stderr)
> sys.exit(1)
>
> - schema = QAPISchema(args.schema)
> + try:
> + 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_visit(schema, args.output_dir, args.prefix, args.builtins)
> diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
> index d72c339ad5..dce289ae21 100644
> --- a/scripts/qapi/common.py
> +++ b/scripts/qapi/common.py
> @@ -16,7 +16,6 @@ import errno
> import os
> import re
> import string
> -import sys
> try:
> from collections import OrderedDict
> except:
> @@ -1459,19 +1458,15 @@ class QAPISchemaEvent(QAPISchemaEntity):
>
> class QAPISchema(object):
> def __init__(self, fname):
> - try:
> - parser = QAPISchemaParser(open(fname, 'r'))
> - exprs = check_exprs(parser.exprs)
> - self.docs = parser.docs
> - self._entity_dict = {}
> - self._predefining = True
> - self._def_predefineds()
> - self._predefining = False
> - self._def_exprs(exprs)
> - self.check()
> - except QAPIError as err:
> - print(err, file=sys.stderr)
> - exit(1)
> + parser = QAPISchemaParser(open(fname, 'r'))
> + exprs = check_exprs(parser.exprs)
> + self.docs = parser.docs
> + self._entity_dict = {}
> + self._predefining = True
> + self._def_predefineds()
> + self._predefining = False
> + self._def_exprs(exprs)
> + self.check()
>
> def _def_entity(self, ent):
> # Only the predefined types are allowed to not have info
> diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
> index bb1b6dd297..4da14b43af 100644
> --- a/tests/qapi-schema/test-qapi.py
> +++ b/tests/qapi-schema/test-qapi.py
> @@ -12,7 +12,7 @@
>
> from __future__ import print_function
> import sys
> -from qapi.common import QAPISchema, QAPISchemaVisitor
> +from qapi.common import QAPIError, QAPISchema, QAPISchemaVisitor
>
>
> class QAPISchemaTestVisitor(QAPISchemaVisitor):
> @@ -52,7 +52,13 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
> for v in variants.variants:
> 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())
>
> for doc in schema.docs:
> --
> 2.13.6
>
[Qemu-devel] [PATCH v2 22/29] qapi: Generate separate .h, .c for each module, Markus Armbruster, 2018/02/11
[Qemu-devel] [PATCH v2 13/29] qapi: Lift error reporting from QAPISchema.__init__() to callers, Markus Armbruster, 2018/02/11
[Qemu-devel] [PATCH v2 23/29] Include less of the generated modular QAPI headers, Markus Armbruster, 2018/02/11
[Qemu-devel] [PATCH v2 24/29] qapi: Empty out qapi-schema.json, Markus Armbruster, 2018/02/11
Re: [Qemu-devel] [PATCH v2 00/29] Modularize generated QAPI code, no-reply, 2018/02/11
[Qemu-devel] [PATCH v2 23.5/29] watchdog: Consolidate QAPI into single file, Eric Blake, 2018/02/26