mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-05 04:41:20 +00:00
python3: Use the print() function
It has replaced the 'print' statement. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
1a55c77ae9
commit
b207817b49
@ -7,6 +7,9 @@
|
|||||||
#
|
#
|
||||||
# daniel@veillard.com
|
# daniel@veillard.com
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os, sys
|
import os, sys
|
||||||
import string
|
import string
|
||||||
import glob
|
import glob
|
||||||
@ -150,8 +153,8 @@ class identifier:
|
|||||||
else:
|
else:
|
||||||
self.conditionals = conditionals[:]
|
self.conditionals = conditionals[:]
|
||||||
if self.name == debugsym and not quiet:
|
if self.name == debugsym and not quiet:
|
||||||
print "=> define %s : %s" % (debugsym, (module, type, info,
|
print("=> define %s : %s" % (debugsym, (module, type, info,
|
||||||
extra, conditionals))
|
extra, conditionals)))
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
r = "%s %s:" % (self.type, self.name)
|
r = "%s %s:" % (self.type, self.name)
|
||||||
@ -210,8 +213,8 @@ class identifier:
|
|||||||
def update(self, header, module, type = None, info = None, extra=None,
|
def update(self, header, module, type = None, info = None, extra=None,
|
||||||
conditionals=None):
|
conditionals=None):
|
||||||
if self.name == debugsym and not quiet:
|
if self.name == debugsym and not quiet:
|
||||||
print "=> update %s : %s" % (debugsym, (module, type, info,
|
print("=> update %s : %s" % (debugsym, (module, type, info,
|
||||||
extra, conditionals))
|
extra, conditionals)))
|
||||||
if header is not None and self.header is None:
|
if header is not None and self.header is None:
|
||||||
self.set_header(module)
|
self.set_header(module)
|
||||||
if module is not None and (self.module is None or self.header == self.module):
|
if module is not None and (self.module is None or self.header == self.module):
|
||||||
@ -243,7 +246,7 @@ class index:
|
|||||||
def warning(self, msg):
|
def warning(self, msg):
|
||||||
global warnings
|
global warnings
|
||||||
warnings = warnings + 1
|
warnings = warnings + 1
|
||||||
print msg
|
print(msg)
|
||||||
|
|
||||||
def add_ref(self, name, header, module, static, type, lineno, info=None, extra=None, conditionals = None):
|
def add_ref(self, name, header, module, static, type, lineno, info=None, extra=None, conditionals = None):
|
||||||
if name[0:2] == '__':
|
if name[0:2] == '__':
|
||||||
@ -263,7 +266,7 @@ class index:
|
|||||||
self.references[name] = d
|
self.references[name] = d
|
||||||
|
|
||||||
if name == debugsym and not quiet:
|
if name == debugsym and not quiet:
|
||||||
print "New ref: %s" % (d)
|
print("New ref: %s" % (d))
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@ -304,7 +307,7 @@ class index:
|
|||||||
self.warning("Unable to register type ", type)
|
self.warning("Unable to register type ", type)
|
||||||
|
|
||||||
if name == debugsym and not quiet:
|
if name == debugsym and not quiet:
|
||||||
print "New symbol: %s" % (d)
|
print("New symbol: %s" % (d))
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@ -344,8 +347,8 @@ class index:
|
|||||||
self.identifiers[id] = idx.structs[id]
|
self.identifiers[id] = idx.structs[id]
|
||||||
for id in idx.unions.keys():
|
for id in idx.unions.keys():
|
||||||
if self.unions.has_key(id):
|
if self.unions.has_key(id):
|
||||||
print "union %s from %s redeclared in %s" % (
|
print("union %s from %s redeclared in %s" % (
|
||||||
id, self.unions[id].header, idx.unions[id].header)
|
id, self.unions[id].header, idx.unions[id].header))
|
||||||
else:
|
else:
|
||||||
self.unions[id] = idx.unions[id]
|
self.unions[id] = idx.unions[id]
|
||||||
self.identifiers[id] = idx.unions[id]
|
self.identifiers[id] = idx.unions[id]
|
||||||
@ -394,8 +397,8 @@ class index:
|
|||||||
up = idx.functions[id]
|
up = idx.functions[id]
|
||||||
self.functions[id].update(None, up.module, up.type, up.info, up.extra)
|
self.functions[id].update(None, up.module, up.type, up.info, up.extra)
|
||||||
# else:
|
# else:
|
||||||
# print "Function %s from %s is not declared in headers" % (
|
# print("Function %s from %s is not declared in headers" % (
|
||||||
# id, idx.functions[id].module)
|
# id, idx.functions[id].module))
|
||||||
# TODO: do the same for variables.
|
# TODO: do the same for variables.
|
||||||
|
|
||||||
def analyze_dict(self, type, dict):
|
def analyze_dict(self, type, dict):
|
||||||
@ -407,9 +410,9 @@ class index:
|
|||||||
if id.static == 0:
|
if id.static == 0:
|
||||||
public = public + 1
|
public = public + 1
|
||||||
if count != public:
|
if count != public:
|
||||||
print " %d %s , %d public" % (count, type, public)
|
print(" %d %s , %d public" % (count, type, public))
|
||||||
elif count != 0:
|
elif count != 0:
|
||||||
print " %d public %s" % (count, type)
|
print(" %d public %s" % (count, type))
|
||||||
|
|
||||||
|
|
||||||
def analyze(self):
|
def analyze(self):
|
||||||
@ -460,9 +463,9 @@ class CLexer:
|
|||||||
self.tokens.insert(0, token)
|
self.tokens.insert(0, token)
|
||||||
|
|
||||||
def debug(self):
|
def debug(self):
|
||||||
print "Last token: ", self.last
|
print("Last token: ", self.last)
|
||||||
print "Token queue: ", self.tokens
|
print("Token queue: ", self.tokens)
|
||||||
print "Line %d end: " % (self.lineno), self.line
|
print("Line %d end: " % (self.lineno), self.line)
|
||||||
|
|
||||||
def token(self):
|
def token(self):
|
||||||
while self.tokens == []:
|
while self.tokens == []:
|
||||||
@ -691,22 +694,22 @@ class CParser:
|
|||||||
warnings = warnings + 1
|
warnings = warnings + 1
|
||||||
if self.no_error:
|
if self.no_error:
|
||||||
return
|
return
|
||||||
print msg
|
print(msg)
|
||||||
|
|
||||||
def error(self, msg, token=-1):
|
def error(self, msg, token=-1):
|
||||||
if self.no_error:
|
if self.no_error:
|
||||||
return
|
return
|
||||||
|
|
||||||
print "Parse Error: " + msg
|
print("Parse Error: " + msg)
|
||||||
if token != -1:
|
if token != -1:
|
||||||
print "Got token ", token
|
print("Got token ", token)
|
||||||
self.lexer.debug()
|
self.lexer.debug()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def debug(self, msg, token=-1):
|
def debug(self, msg, token=-1):
|
||||||
print "Debug: " + msg
|
print("Debug: " + msg)
|
||||||
if token != -1:
|
if token != -1:
|
||||||
print "Got token ", token
|
print("Got token ", token)
|
||||||
self.lexer.debug()
|
self.lexer.debug()
|
||||||
|
|
||||||
def parseTopComment(self, comment):
|
def parseTopComment(self, comment):
|
||||||
@ -1018,7 +1021,7 @@ class CParser:
|
|||||||
|
|
||||||
def parsePreproc(self, token):
|
def parsePreproc(self, token):
|
||||||
if debug:
|
if debug:
|
||||||
print "=> preproc ", token, self.lexer.tokens
|
print("=> preproc ", token, self.lexer.tokens)
|
||||||
name = token[1]
|
name = token[1]
|
||||||
if name == "#include":
|
if name == "#include":
|
||||||
token = self.lexer.token()
|
token = self.lexer.token()
|
||||||
@ -1156,7 +1159,7 @@ class CParser:
|
|||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if debug:
|
if debug:
|
||||||
print "=> ", token
|
print("=> ", token)
|
||||||
return token
|
return token
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -1267,7 +1270,7 @@ class CParser:
|
|||||||
elif token[0] == "sep" and token[1] == "}":
|
elif token[0] == "sep" and token[1] == "}":
|
||||||
self.struct_fields = fields
|
self.struct_fields = fields
|
||||||
#self.debug("end parseStruct", token)
|
#self.debug("end parseStruct", token)
|
||||||
#print fields
|
#print(fields)
|
||||||
token = self.token()
|
token = self.token()
|
||||||
return token
|
return token
|
||||||
else:
|
else:
|
||||||
@ -1306,7 +1309,7 @@ class CParser:
|
|||||||
self.type = base_type
|
self.type = base_type
|
||||||
self.struct_fields = fields
|
self.struct_fields = fields
|
||||||
#self.debug("end parseStruct", token)
|
#self.debug("end parseStruct", token)
|
||||||
#print fields
|
#print(fields)
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -1322,7 +1325,7 @@ class CParser:
|
|||||||
elif token[0] == "sep" and token[1] == "}":
|
elif token[0] == "sep" and token[1] == "}":
|
||||||
self.union_fields = fields
|
self.union_fields = fields
|
||||||
# self.debug("end parseUnion", token)
|
# self.debug("end parseUnion", token)
|
||||||
# print fields
|
# print(fields)
|
||||||
token = self.token()
|
token = self.token()
|
||||||
return token
|
return token
|
||||||
else:
|
else:
|
||||||
@ -1356,7 +1359,7 @@ class CParser:
|
|||||||
self.type = base_type
|
self.type = base_type
|
||||||
self.union_fields = fields
|
self.union_fields = fields
|
||||||
# self.debug("end parseUnion", token)
|
# self.debug("end parseUnion", token)
|
||||||
# print fields
|
# print(fields)
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -1914,7 +1917,7 @@ class CParser:
|
|||||||
return token
|
return token
|
||||||
if token[0] == 'sep' and token[1] == "{":
|
if token[0] == 'sep' and token[1] == "{":
|
||||||
token = self.token()
|
token = self.token()
|
||||||
# print 'Entering extern "C line ', self.lineno()
|
# print('Entering extern "C line ', self.lineno())
|
||||||
while token is not None and (token[0] != 'sep' or
|
while token is not None and (token[0] != 'sep' or
|
||||||
token[1] != "}"):
|
token[1] != "}"):
|
||||||
if token[0] == 'name':
|
if token[0] == 'name':
|
||||||
@ -1924,7 +1927,7 @@ class CParser:
|
|||||||
"token %s %s unexpected at the top level" % (
|
"token %s %s unexpected at the top level" % (
|
||||||
token[0], token[1]))
|
token[0], token[1]))
|
||||||
token = self.parseGlobal(token)
|
token = self.parseGlobal(token)
|
||||||
# print 'Exiting extern "C" line', self.lineno()
|
# print('Exiting extern "C" line', self.lineno())
|
||||||
token = self.token()
|
token = self.token()
|
||||||
return token
|
return token
|
||||||
else:
|
else:
|
||||||
@ -2025,7 +2028,7 @@ class CParser:
|
|||||||
|
|
||||||
def parse(self):
|
def parse(self):
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print "Parsing %s" % (self.filename)
|
print("Parsing %s" % (self.filename))
|
||||||
token = self.token()
|
token = self.token()
|
||||||
while token is not None:
|
while token is not None:
|
||||||
if token[0] == 'name':
|
if token[0] == 'name':
|
||||||
@ -2064,11 +2067,11 @@ class docBuilder:
|
|||||||
def warning(self, msg):
|
def warning(self, msg):
|
||||||
global warnings
|
global warnings
|
||||||
warnings = warnings + 1
|
warnings = warnings + 1
|
||||||
print msg
|
print(msg)
|
||||||
|
|
||||||
def error(self, msg):
|
def error(self, msg):
|
||||||
self.errors += 1
|
self.errors += 1
|
||||||
print >>sys.stderr, "Error:", msg
|
print("Error:", msg, file=sys.stderr)
|
||||||
|
|
||||||
def indexString(self, id, str):
|
def indexString(self, id, str):
|
||||||
if str is None:
|
if str is None:
|
||||||
@ -2110,7 +2113,7 @@ class docBuilder:
|
|||||||
|
|
||||||
def analyze(self):
|
def analyze(self):
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print "Project %s : %d headers, %d modules" % (self.name, len(self.headers.keys()), len(self.modules.keys()))
|
print("Project %s : %d headers, %d modules" % (self.name, len(self.headers.keys()), len(self.modules.keys())))
|
||||||
self.idx.analyze()
|
self.idx.analyze()
|
||||||
|
|
||||||
def scanHeaders(self):
|
def scanHeaders(self):
|
||||||
@ -2271,7 +2274,7 @@ class docBuilder:
|
|||||||
def serialize_function(self, output, name):
|
def serialize_function(self, output, name):
|
||||||
id = self.idx.functions[name]
|
id = self.idx.functions[name]
|
||||||
if name == debugsym and not quiet:
|
if name == debugsym and not quiet:
|
||||||
print "=>", id
|
print("=>", id)
|
||||||
|
|
||||||
# NB: this is consumed by a regex in 'getAPIFilenames' in hvsupport.pl
|
# NB: this is consumed by a regex in 'getAPIFilenames' in hvsupport.pl
|
||||||
output.write(" <%s name='%s' file='%s' module='%s'>\n" % (id.type,
|
output.write(" <%s name='%s' file='%s' module='%s'>\n" % (id.type,
|
||||||
@ -2312,7 +2315,7 @@ class docBuilder:
|
|||||||
output.write(" <arg name='%s' type='%s' info='%s'/>\n" % (param[1], param[0], escape(param[2])))
|
output.write(" <arg name='%s' type='%s' info='%s'/>\n" % (param[1], param[0], escape(param[2])))
|
||||||
self.indexString(name, param[2])
|
self.indexString(name, param[2])
|
||||||
except:
|
except:
|
||||||
print >>sys.stderr, "Exception:", sys.exc_info()[1]
|
print("Exception:", sys.exc_info()[1], file=sys.stderr)
|
||||||
self.warning("Failed to save function %s info: %s" % (name, `id.info`))
|
self.warning("Failed to save function %s info: %s" % (name, `id.info`))
|
||||||
output.write(" </%s>\n" % (id.type))
|
output.write(" </%s>\n" % (id.type))
|
||||||
|
|
||||||
@ -2542,7 +2545,7 @@ class docBuilder:
|
|||||||
def serialize(self):
|
def serialize(self):
|
||||||
filename = "%s/%s-api.xml" % (self.path, self.name)
|
filename = "%s/%s-api.xml" % (self.path, self.name)
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print "Saving XML description %s" % (filename)
|
print("Saving XML description %s" % (filename))
|
||||||
output = open(filename, "w")
|
output = open(filename, "w")
|
||||||
output.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
|
output.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
|
||||||
output.write("<api name='%s'>\n" % self.name)
|
output.write("<api name='%s'>\n" % self.name)
|
||||||
@ -2578,12 +2581,12 @@ class docBuilder:
|
|||||||
output.close()
|
output.close()
|
||||||
|
|
||||||
if self.errors > 0:
|
if self.errors > 0:
|
||||||
print >>sys.stderr, "apibuild.py: %d error(s) encountered during generation" % self.errors
|
print("apibuild.py: %d error(s) encountered during generation" % self.errors, file=sys.stderr)
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
filename = "%s/%s-refs.xml" % (self.path, self.name)
|
filename = "%s/%s-refs.xml" % (self.path, self.name)
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print "Saving XML Cross References %s" % (filename)
|
print("Saving XML Cross References %s" % (filename))
|
||||||
output = open(filename, "w")
|
output = open(filename, "w")
|
||||||
output.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
|
output.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
|
||||||
output.write("<apirefs name='%s'>\n" % self.name)
|
output.write("<apirefs name='%s'>\n" % self.name)
|
||||||
@ -2596,7 +2599,7 @@ class app:
|
|||||||
def warning(self, msg):
|
def warning(self, msg):
|
||||||
global warnings
|
global warnings
|
||||||
warnings = warnings + 1
|
warnings = warnings + 1
|
||||||
print msg
|
print(msg)
|
||||||
|
|
||||||
def rebuild(self, name):
|
def rebuild(self, name):
|
||||||
if name not in ["libvirt", "libvirt-qemu", "libvirt-lxc", "libvirt-admin"]:
|
if name not in ["libvirt", "libvirt-qemu", "libvirt-lxc", "libvirt-admin"]:
|
||||||
@ -2609,7 +2612,7 @@ class app:
|
|||||||
builddir = None
|
builddir = None
|
||||||
if glob.glob(srcdir + "/../src/libvirt.c") != [] :
|
if glob.glob(srcdir + "/../src/libvirt.c") != [] :
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print "Rebuilding API description for %s" % name
|
print("Rebuilding API description for %s" % name)
|
||||||
dirs = [srcdir + "/../src",
|
dirs = [srcdir + "/../src",
|
||||||
srcdir + "/../src/util",
|
srcdir + "/../src/util",
|
||||||
srcdir + "/../include/libvirt"]
|
srcdir + "/../include/libvirt"]
|
||||||
@ -2619,7 +2622,7 @@ class app:
|
|||||||
builder = docBuilder(name, srcdir, dirs, [])
|
builder = docBuilder(name, srcdir, dirs, [])
|
||||||
elif glob.glob("src/libvirt.c") != [] :
|
elif glob.glob("src/libvirt.c") != [] :
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print "Rebuilding API description for %s" % name
|
print("Rebuilding API description for %s" % name)
|
||||||
builder = docBuilder(name, srcdir,
|
builder = docBuilder(name, srcdir,
|
||||||
["src", "src/util", "include/libvirt"],
|
["src", "src/util", "include/libvirt"],
|
||||||
[])
|
[])
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
# <http://www.gnu.org/licenses/>.
|
# <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
@ -1196,7 +1198,7 @@ class Enum(Type):
|
|||||||
|
|
||||||
|
|
||||||
def report_error(message):
|
def report_error(message):
|
||||||
print "error: " + message
|
print("error: " + message)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
@ -1321,9 +1323,9 @@ def is_known_type(type):
|
|||||||
|
|
||||||
def open_and_print(filename):
|
def open_and_print(filename):
|
||||||
if filename.startswith("./"):
|
if filename.startswith("./"):
|
||||||
print " GEN " + filename[2:]
|
print(" GEN " + filename[2:])
|
||||||
else:
|
else:
|
||||||
print " GEN " + filename
|
print(" GEN " + filename)
|
||||||
|
|
||||||
return open(filename, "wb")
|
return open(filename, "wb")
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
# <http://www.gnu.org/licenses/>.
|
# <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
@ -390,16 +392,16 @@ class Property:
|
|||||||
|
|
||||||
def open_and_print(filename):
|
def open_and_print(filename):
|
||||||
if filename.startswith("./"):
|
if filename.startswith("./"):
|
||||||
print " GEN " + filename[2:]
|
print(" GEN " + filename[2:])
|
||||||
else:
|
else:
|
||||||
print " GEN " + filename
|
print(" GEN " + filename)
|
||||||
|
|
||||||
return open(filename, "wb")
|
return open(filename, "wb")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def report_error(message):
|
def report_error(message):
|
||||||
print "error: " + message
|
print("error: " + message)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user