qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

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>

+4 -20
+1 -5
scripts/qapi/common.py
··· 12 12 # See the COPYING file in the top-level directory. 13 13 14 14 import re 15 - import string 16 15 17 16 18 17 # ENUMName -> ENUM_NAME, EnumName1 -> ENUM_NAME1 ··· 43 42 return camel_to_upper(type_name) + '_' + c_name(const_name, False).upper() 44 43 45 44 46 - if hasattr(str, 'maketrans'): 47 - c_name_trans = str.maketrans('.-', '__') 48 - else: 49 - c_name_trans = string.maketrans('.-', '__') 45 + c_name_trans = str.maketrans('.-', '__') 50 46 51 47 52 48 # Map @name to a valid C identifier.
+1 -5
scripts/qapi/gen.py
··· 15 15 import errno 16 16 import os 17 17 import re 18 - import sys 19 18 from contextlib import contextmanager 20 19 21 20 from qapi.common import * ··· 54 53 if e.errno != errno.EEXIST: 55 54 raise 56 55 fd = os.open(pathname, os.O_RDWR | os.O_CREAT, 0o666) 57 - if sys.version_info[0] >= 3: 58 - f = open(fd, 'r+', encoding='utf-8') 59 - else: 60 - f = os.fdopen(fd, 'r+') 56 + f = open(fd, 'r+', encoding='utf-8') 61 57 text = self.get_content() 62 58 oldtext = f.read(len(text) + 1) 63 59 if text != oldtext:
+1 -5
scripts/qapi/parser.py
··· 16 16 17 17 import os 18 18 import re 19 - import sys 20 19 from collections import OrderedDict 21 20 22 21 from qapi.error import QAPIParseError, QAPISemError ··· 30 29 previously_included.add(os.path.abspath(fname)) 31 30 32 31 try: 33 - if sys.version_info[0] >= 3: 34 - fp = open(fname, 'r', encoding='utf-8') 35 - else: 36 - fp = open(fname, 'r') 32 + fp = open(fname, 'r', encoding='utf-8') 37 33 self.src = fp.read() 38 34 except IOError as e: 39 35 raise QAPISemError(incl_info or QAPISourceInfo(None, None, None),
+1 -5
tests/qapi-schema/test-qapi.py
··· 16 16 import difflib 17 17 import os 18 18 import sys 19 + from io import StringIO 19 20 20 21 from qapi.error import QAPIError 21 22 from qapi.schema import QAPISchema, QAPISchemaVisitor 22 - 23 - if sys.version_info[0] < 3: 24 - from cStringIO import StringIO 25 - else: 26 - from io import StringIO 27 23 28 24 29 25 class QAPISchemaTestVisitor(QAPISchemaVisitor):