mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 20:33:54 -06:00
qapi: Drop conditionals for Python 2
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20200304155932.20452-3-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
This commit is contained in:
parent
baa310f1bb
commit
ed39c03e2f
4 changed files with 4 additions and 20 deletions
|
@ -12,7 +12,6 @@
|
||||||
# See the COPYING file in the top-level directory.
|
# See the COPYING file in the top-level directory.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import string
|
|
||||||
|
|
||||||
|
|
||||||
# ENUMName -> ENUM_NAME, EnumName1 -> ENUM_NAME1
|
# ENUMName -> ENUM_NAME, EnumName1 -> ENUM_NAME1
|
||||||
|
@ -43,10 +42,7 @@ def c_enum_const(type_name, const_name, prefix=None):
|
||||||
return camel_to_upper(type_name) + '_' + c_name(const_name, False).upper()
|
return camel_to_upper(type_name) + '_' + c_name(const_name, False).upper()
|
||||||
|
|
||||||
|
|
||||||
if hasattr(str, 'maketrans'):
|
c_name_trans = str.maketrans('.-', '__')
|
||||||
c_name_trans = str.maketrans('.-', '__')
|
|
||||||
else:
|
|
||||||
c_name_trans = string.maketrans('.-', '__')
|
|
||||||
|
|
||||||
|
|
||||||
# Map @name to a valid C identifier.
|
# Map @name to a valid C identifier.
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
import errno
|
import errno
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
from qapi.common import *
|
from qapi.common import *
|
||||||
|
@ -54,10 +53,7 @@ class QAPIGen:
|
||||||
if e.errno != errno.EEXIST:
|
if e.errno != errno.EEXIST:
|
||||||
raise
|
raise
|
||||||
fd = os.open(pathname, os.O_RDWR | os.O_CREAT, 0o666)
|
fd = os.open(pathname, os.O_RDWR | os.O_CREAT, 0o666)
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
f = open(fd, 'r+', encoding='utf-8')
|
f = open(fd, 'r+', encoding='utf-8')
|
||||||
else:
|
|
||||||
f = os.fdopen(fd, 'r+')
|
|
||||||
text = self.get_content()
|
text = self.get_content()
|
||||||
oldtext = f.read(len(text) + 1)
|
oldtext = f.read(len(text) + 1)
|
||||||
if text != oldtext:
|
if text != oldtext:
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from qapi.error import QAPIParseError, QAPISemError
|
from qapi.error import QAPIParseError, QAPISemError
|
||||||
|
@ -30,10 +29,7 @@ class QAPISchemaParser:
|
||||||
previously_included.add(os.path.abspath(fname))
|
previously_included.add(os.path.abspath(fname))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
fp = open(fname, 'r', encoding='utf-8')
|
fp = open(fname, 'r', encoding='utf-8')
|
||||||
else:
|
|
||||||
fp = open(fname, 'r')
|
|
||||||
self.src = fp.read()
|
self.src = fp.read()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise QAPISemError(incl_info or QAPISourceInfo(None, None, None),
|
raise QAPISemError(incl_info or QAPISourceInfo(None, None, None),
|
||||||
|
|
|
@ -16,15 +16,11 @@ import argparse
|
||||||
import difflib
|
import difflib
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
from qapi.error import QAPIError
|
from qapi.error import QAPIError
|
||||||
from qapi.schema import QAPISchema, QAPISchemaVisitor
|
from qapi.schema import QAPISchema, QAPISchemaVisitor
|
||||||
|
|
||||||
if sys.version_info[0] < 3:
|
|
||||||
from cStringIO import StringIO
|
|
||||||
else:
|
|
||||||
from io import StringIO
|
|
||||||
|
|
||||||
|
|
||||||
class QAPISchemaTestVisitor(QAPISchemaVisitor):
|
class QAPISchemaTestVisitor(QAPISchemaVisitor):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue