summaryrefslogtreecommitdiffstats
path: root/scripts/qapi/parser.py
diff options
context:
space:
mode:
authorPeter Maydell2020-03-05 16:18:18 +0100
committerPeter Maydell2020-03-05 16:18:19 +0100
commitaf4378c39e54705d9b585089de80aae9526ac7e7 (patch)
tree18c532a6f6dfb1de4ddfa0ee1300ff5ce8c5e44c /scripts/qapi/parser.py
parentMerge remote-tracking branch 'remotes/stsquad/tags/pull-testing-040320-1' int... (diff)
parentqapi: Brush off some (py)lint (diff)
downloadqemu-af4378c39e54705d9b585089de80aae9526ac7e7.tar.gz
qemu-af4378c39e54705d9b585089de80aae9526ac7e7.tar.xz
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/parser.py')
-rw-r--r--scripts/qapi/parser.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index 342792e410..abadacbb0e 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -16,24 +16,20 @@
import os
import re
-import sys
from collections import OrderedDict
from qapi.error import QAPIParseError, QAPISemError
from qapi.source import QAPISourceInfo
-class QAPISchemaParser(object):
+class QAPISchemaParser:
def __init__(self, fname, previously_included=None, incl_info=None):
previously_included = previously_included or set()
previously_included.add(os.path.abspath(fname))
try:
- if sys.version_info[0] >= 3:
- fp = open(fname, 'r', encoding='utf-8')
- else:
- fp = open(fname, 'r')
+ fp = open(fname, 'r', encoding='utf-8')
self.src = fp.read()
except IOError as e:
raise QAPISemError(incl_info or QAPISourceInfo(None, None, None),
@@ -286,14 +282,13 @@ class QAPISchemaParser(object):
doc.end_comment()
self.accept()
return doc
- else:
- doc.append(self.val)
+ doc.append(self.val)
self.accept(False)
raise QAPIParseError(self, "documentation comment must end with '##'")
-class QAPIDoc(object):
+class QAPIDoc:
"""
A documentation comment block, either definition or free-form
@@ -312,7 +307,7 @@ class QAPIDoc(object):
Free-form documentation blocks consist only of a body section.
"""
- class Section(object):
+ class Section:
def __init__(self, name=None):
# optional section name (argument/member or section name)
self.name = name
@@ -324,7 +319,7 @@ class QAPIDoc(object):
class ArgSection(Section):
def __init__(self, name):
- QAPIDoc.Section.__init__(self, name)
+ super().__init__(name)
self.member = None
def connect(self, member):
@@ -496,7 +491,7 @@ class QAPIDoc(object):
raise QAPIParseError(self._parser,
"'%s' can't follow '%s' section"
% (name, self.sections[0].name))
- elif self._is_section_tag(name):
+ if self._is_section_tag(name):
line = line[len(name)+1:]
self._start_section(name[:-1])
@@ -560,7 +555,6 @@ class QAPIDoc(object):
raise QAPISemError(feature.info,
"feature '%s' lacks documentation"
% feature.name)
- self.features[feature.name] = QAPIDoc.ArgSection(feature.name)
self.features[feature.name].connect(feature)
def check_expr(self, expr):