mirror of https://github.com/xemu-project/xemu.git
qapi: Brush off some (py)lint
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20200304155932.20452-5-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
This commit is contained in:
parent
2cae67bcb5
commit
8ec0e1a4e6
|
@ -274,7 +274,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor):
|
||||||
|
|
||||||
void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
|
void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
|
||||||
''',
|
''',
|
||||||
c_prefix=c_name(self._prefix, protect=False)))
|
c_prefix=c_name(self._prefix, protect=False)))
|
||||||
self._genc.preamble_add(mcgen('''
|
self._genc.preamble_add(mcgen('''
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "%(prefix)sqapi-commands.h"
|
#include "%(prefix)sqapi-commands.h"
|
||||||
|
|
|
@ -35,7 +35,6 @@ def check_name_is_str(name, info, source):
|
||||||
def check_name_str(name, info, source,
|
def check_name_str(name, info, source,
|
||||||
allow_optional=False, enum_member=False,
|
allow_optional=False, enum_member=False,
|
||||||
permit_upper=False):
|
permit_upper=False):
|
||||||
global valid_name
|
|
||||||
membername = name
|
membername = name
|
||||||
|
|
||||||
if allow_optional and name.startswith('*'):
|
if allow_optional and name.startswith('*'):
|
||||||
|
@ -249,7 +248,7 @@ def check_union(expr, info):
|
||||||
def check_alternate(expr, info):
|
def check_alternate(expr, info):
|
||||||
members = expr['data']
|
members = expr['data']
|
||||||
|
|
||||||
if len(members) == 0:
|
if not members:
|
||||||
raise QAPISemError(info, "'data' must not be empty")
|
raise QAPISemError(info, "'data' must not be empty")
|
||||||
for (key, value) in members.items():
|
for (key, value) in members.items():
|
||||||
source = "'data' member '%s'" % key
|
source = "'data' member '%s'" % key
|
||||||
|
|
|
@ -45,10 +45,10 @@ class QAPIGen:
|
||||||
|
|
||||||
def write(self, output_dir):
|
def write(self, output_dir):
|
||||||
pathname = os.path.join(output_dir, self.fname)
|
pathname = os.path.join(output_dir, self.fname)
|
||||||
dir = os.path.dirname(pathname)
|
odir = os.path.dirname(pathname)
|
||||||
if dir:
|
if odir:
|
||||||
try:
|
try:
|
||||||
os.makedirs(dir)
|
os.makedirs(odir)
|
||||||
except os.error as e:
|
except os.error as e:
|
||||||
if e.errno != errno.EEXIST:
|
if e.errno != errno.EEXIST:
|
||||||
raise
|
raise
|
||||||
|
@ -261,6 +261,9 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
|
||||||
genc.write(output_dir)
|
genc.write(output_dir)
|
||||||
genh.write(output_dir)
|
genh.write(output_dir)
|
||||||
|
|
||||||
|
def _begin_system_module(self, name):
|
||||||
|
pass
|
||||||
|
|
||||||
def _begin_user_module(self, name):
|
def _begin_user_module(self, name):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,6 @@ This work is licensed under the terms of the GNU GPL, version 2.
|
||||||
See the COPYING file in the top-level directory.
|
See the COPYING file in the top-level directory.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import string
|
|
||||||
|
|
||||||
from qapi.common import *
|
from qapi.common import *
|
||||||
from qapi.gen import QAPISchemaMonolithicCVisitor
|
from qapi.gen import QAPISchemaMonolithicCVisitor
|
||||||
from qapi.schema import (QAPISchemaArrayType, QAPISchemaBuiltinType,
|
from qapi.schema import (QAPISchemaArrayType, QAPISchemaBuiltinType,
|
||||||
|
|
|
@ -282,8 +282,7 @@ class QAPISchemaParser:
|
||||||
doc.end_comment()
|
doc.end_comment()
|
||||||
self.accept()
|
self.accept()
|
||||||
return doc
|
return doc
|
||||||
else:
|
doc.append(self.val)
|
||||||
doc.append(self.val)
|
|
||||||
self.accept(False)
|
self.accept(False)
|
||||||
|
|
||||||
raise QAPIParseError(self, "documentation comment must end with '##'")
|
raise QAPIParseError(self, "documentation comment must end with '##'")
|
||||||
|
@ -492,7 +491,7 @@ class QAPIDoc:
|
||||||
raise QAPIParseError(self._parser,
|
raise QAPIParseError(self._parser,
|
||||||
"'%s' can't follow '%s' section"
|
"'%s' can't follow '%s' section"
|
||||||
% (name, self.sections[0].name))
|
% (name, self.sections[0].name))
|
||||||
elif self._is_section_tag(name):
|
if self._is_section_tag(name):
|
||||||
line = line[len(name)+1:]
|
line = line[len(name)+1:]
|
||||||
self._start_section(name[:-1])
|
self._start_section(name[:-1])
|
||||||
|
|
||||||
|
@ -556,7 +555,6 @@ class QAPIDoc:
|
||||||
raise QAPISemError(feature.info,
|
raise QAPISemError(feature.info,
|
||||||
"feature '%s' lacks documentation"
|
"feature '%s' lacks documentation"
|
||||||
% feature.name)
|
% feature.name)
|
||||||
self.features[feature.name] = QAPIDoc.ArgSection(feature.name)
|
|
||||||
self.features[feature.name].connect(feature)
|
self.features[feature.name].connect(feature)
|
||||||
|
|
||||||
def check_expr(self, expr):
|
def check_expr(self, expr):
|
||||||
|
|
|
@ -19,7 +19,7 @@ import re
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from qapi.common import c_name, pointer_suffix
|
from qapi.common import c_name, pointer_suffix
|
||||||
from qapi.error import QAPIError, QAPIParseError, QAPISemError
|
from qapi.error import QAPIError, QAPISemError
|
||||||
from qapi.expr import check_exprs
|
from qapi.expr import check_exprs
|
||||||
from qapi.parser import QAPISchemaParser
|
from qapi.parser import QAPISchemaParser
|
||||||
|
|
||||||
|
@ -96,14 +96,14 @@ class QAPISchemaVisitor:
|
||||||
def visit_end(self):
|
def visit_end(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_module(self, fname):
|
def visit_module(self, name):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_needed(self, entity):
|
def visit_needed(self, entity):
|
||||||
# Default to visiting everything
|
# Default to visiting everything
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def visit_include(self, fname, info):
|
def visit_include(self, name, info):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_builtin_type(self, name, info, json_type):
|
def visit_builtin_type(self, name, info, json_type):
|
||||||
|
@ -576,7 +576,7 @@ class QAPISchemaObjectTypeVariants:
|
||||||
assert self.tag_member.ifcond == []
|
assert self.tag_member.ifcond == []
|
||||||
if self._tag_name: # flat union
|
if self._tag_name: # flat union
|
||||||
# branches that are not explicitly covered get an empty type
|
# branches that are not explicitly covered get an empty type
|
||||||
cases = set([v.name for v in self.variants])
|
cases = {v.name for v in self.variants}
|
||||||
for m in self.tag_member.type.members:
|
for m in self.tag_member.type.members:
|
||||||
if m.name not in cases:
|
if m.name not in cases:
|
||||||
v = QAPISchemaObjectTypeVariant(m.name, self.info,
|
v = QAPISchemaObjectTypeVariant(m.name, self.info,
|
||||||
|
@ -848,7 +848,7 @@ class QAPISchema:
|
||||||
|
|
||||||
def _make_module(self, fname):
|
def _make_module(self, fname):
|
||||||
name = self._module_name(fname)
|
name = self._module_name(fname)
|
||||||
if not name in self._module_dict:
|
if name not in self._module_dict:
|
||||||
self._module_dict[name] = QAPISchemaModule(name)
|
self._module_dict[name] = QAPISchemaModule(name)
|
||||||
return self._module_dict[name]
|
return self._module_dict[name]
|
||||||
|
|
||||||
|
@ -1097,7 +1097,6 @@ class QAPISchema:
|
||||||
|
|
||||||
def visit(self, visitor):
|
def visit(self, visitor):
|
||||||
visitor.visit_begin(self)
|
visitor.visit_begin(self)
|
||||||
module = None
|
|
||||||
for mod in self._module_dict.values():
|
for mod in self._module_dict.values():
|
||||||
mod.visit(visitor)
|
mod.visit(visitor)
|
||||||
visitor.visit_end()
|
visitor.visit_end()
|
||||||
|
|
Loading…
Reference in New Issue