diff options
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 |