# See the COPYING file in the top-level directory.
import re
-import string
# ENUMName -> ENUM_NAME, EnumName1 -> ENUM_NAME1
return camel_to_upper(type_name) + '_' + c_name(const_name, False).upper()
-if hasattr(str, 'maketrans'):
- c_name_trans = str.maketrans('.-', '__')
-else:
- c_name_trans = string.maketrans('.-', '__')
+c_name_trans = str.maketrans('.-', '__')
# Map @name to a valid C identifier.
import errno
import os
import re
-import sys
from contextlib import contextmanager
from qapi.common import *
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:
import os
import re
-import sys
from collections import OrderedDict
from qapi.error import QAPIParseError, QAPISemError
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),
import difflib
import os
import sys
+from io import StringIO
from qapi.error import QAPIError
from qapi.schema import QAPISchema, QAPISchemaVisitor
-if sys.version_info[0] < 3:
- from cStringIO import StringIO
-else:
- from io import StringIO
-
class QAPISchemaTestVisitor(QAPISchemaVisitor):