[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v12 4/4] qapi: Add a primitive to include other
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH v12 4/4] qapi: Add a primitive to include other files from a QAPI schema file |
Date: |
Sun, 18 May 2014 12:44:24 +0100 |
On 7 May 2014 19:46, Lluís Vilanova <address@hidden> wrote:
> The primitive uses JSON syntax, and include paths are relative to the file
> using the directive:
>
> { 'include': 'path/to/file.json' }
>
> Signed-off-by: Lluís Vilanova <address@hidden>
> Reviewed-by: Eric Blake <address@hidden>
> Reviewed-by: Markus Armbruster <address@hidden>
> @@ -74,10 +91,33 @@ class QAPISchema:
> self.accept()
>
> while self.tok != None:
> - expr_info = {'fp': fp, 'line': self.line}
> - expr_elem = {'expr': self.get_expr(False),
> - 'info': expr_info}
> - self.exprs.append(expr_elem)
> + expr_info = {'file': input_relname, 'line': self.line, 'parent':
> self.parent_info}
> + expr = self.get_expr(False)
> + if isinstance(expr, dict) and "include" in expr:
> + if len(expr) != 1:
> + raise QAPIExprError(expr_info, "Invalid 'include'
> directive")
> + include = expr["include"]
> + if not isinstance(include, str):
> + raise QAPIExprError(expr_info,
> + 'Expected a file name (string), got:
> %s'
> + % include)
> + include_path = os.path.join(self.input_dir, include)
> + if any(include_path == elem[1]
> + for elem in self.include_hist):
> + raise QAPIExprError(expr_info, "Inclusion loop for %s"
> + % include)
> + try:
> + fobj = open(include_path, 'r')
> + except IOError as e:
Hi. I'm afraid "except ... as" is only supported in Python 2.6,
and we have to support Python 2.4 still (as Andreas mentioned
in another thread this breaks compilation on MacOSX 10.5).
Please can you fix this to use the older syntax (cf also commit
21e0043bad which fixed an earlier instance of this problem)?
thanks
-- PMM
- [Qemu-devel] [PATCH v12 0/4] qapi: Allow modularization of QAPI schema files, Lluís Vilanova, 2014/05/02
- [Qemu-devel] [PATCH v12 1/4] qapi: [trivial] Break long command lines, Lluís Vilanova, 2014/05/02
- [Qemu-devel] [PATCH v12 2/4] qapi: [trivial] Do not catch unknown exceptions in "test-qapi.py", Lluís Vilanova, 2014/05/02
- [Qemu-devel] [PATCH v12 3/4] qapi: Use an explicit input file, Lluís Vilanova, 2014/05/02
- [Qemu-devel] [PATCH v12 4/4] qapi: Add a primitive to include other files from a QAPI schema file, Lluís Vilanova, 2014/05/02
- Re: [Qemu-devel] [PATCH v12 0/4] qapi: Allow modularization of QAPI schema files, Luiz Capitulino, 2014/05/05
Re: [Qemu-devel] [PATCH v12 0/4] qapi: Allow modularization of QAPI schema files, Benoît Canet, 2014/05/06