diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2020-03-05 15:18:18 +0000 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2020-03-05 15:18:19 +0000 |
| commit | af4378c39e54705d9b585089de80aae9526ac7e7 (patch) | |
| tree | 18c532a6f6dfb1de4ddfa0ee1300ff5ce8c5e44c /scripts/qapi/gen.py | |
| parent | e64a62df378a746c0b257105959613c9f8122e59 (diff) | |
| parent | 8ec0e1a4e68781f1e512af47fd6ab46ec76326e8 (diff) | |
| download | focaccia-qemu-af4378c39e54705d9b585089de80aae9526ac7e7.tar.gz focaccia-qemu-af4378c39e54705d9b585089de80aae9526ac7e7.zip | |
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2020-03-05' into staging
QAPI patches for 2020-03-05 # gpg: Signature made Thu 05 Mar 2020 12:42:15 GMT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2020-03-05: qapi: Brush off some (py)lint qapi: Use super() now we have Python 3 qapi: Drop conditionals for Python 2 qapi: Inheriting from object is pointless with Python 3, drop Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/qapi/gen.py')
| -rw-r--r-- | scripts/qapi/gen.py | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 95afae0615..33690bfa3b 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -15,14 +15,13 @@ import errno import os import re -import sys from contextlib import contextmanager from qapi.common import * from qapi.schema import QAPISchemaVisitor -class QAPIGen(object): +class QAPIGen: def __init__(self, fname): self.fname = fname @@ -46,18 +45,15 @@ class QAPIGen(object): def write(self, output_dir): pathname = os.path.join(output_dir, self.fname) - dir = os.path.dirname(pathname) - if dir: + odir = os.path.dirname(pathname) + if odir: try: - os.makedirs(dir) + os.makedirs(odir) except os.error as e: if e.errno != errno.EEXIST: raise fd = os.open(pathname, os.O_RDWR | os.O_CREAT, 0o666) - if sys.version_info[0] >= 3: - f = open(fd, 'r+', encoding='utf-8') - else: - f = os.fdopen(fd, 'r+') + f = open(fd, 'r+', encoding='utf-8') text = self.get_content() oldtext = f.read(len(text) + 1) if text != oldtext: @@ -86,7 +82,7 @@ def _wrap_ifcond(ifcond, before, after): class QAPIGenCCode(QAPIGen): def __init__(self, fname): - QAPIGen.__init__(self, fname) + super().__init__(fname) self._start_if = None def start_if(self, ifcond): @@ -106,13 +102,13 @@ class QAPIGenCCode(QAPIGen): def get_content(self): assert self._start_if is None - return QAPIGen.get_content(self) + return super().get_content() class QAPIGenC(QAPIGenCCode): def __init__(self, fname, blurb, pydoc): - QAPIGenCCode.__init__(self, fname) + super().__init__(fname) self._blurb = blurb self._copyright = '\n * '.join(re.findall(r'^Copyright .*', pydoc, re.MULTILINE)) @@ -145,7 +141,7 @@ char qapi_dummy_%(name)s; class QAPIGenH(QAPIGenC): def _top(self): - return QAPIGenC._top(self) + guardstart(self.fname) + return super()._top() + guardstart(self.fname) def _bottom(self): return guardend(self.fname) @@ -180,7 +176,7 @@ def ifcontext(ifcond, *args): class QAPIGenDoc(QAPIGen): def _top(self): - return (QAPIGen._top(self) + return (super()._top() + '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n\n') @@ -265,6 +261,9 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor): genc.write(output_dir) genh.write(output_dir) + def _begin_system_module(self, name): + pass + def _begin_user_module(self, name): pass |