From f9b756e3a5508ef44d3203a8ad4082e9e5fab84a Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 15 Feb 2017 18:13:51 +0000 Subject: Use print_function in python 2 To allow portability with py3 use the print_function. This requires python >= 2.6.0 Signed-off-by: Daniel P. Berrange --- tools/keymap-gen | 59 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'tools') diff --git a/tools/keymap-gen b/tools/keymap-gen index 3ed4b99..b58a235 100755 --- a/tools/keymap-gen +++ b/tools/keymap-gen @@ -9,6 +9,9 @@ # and 3-clause BSD licenses. # +# Requires >= 2.6 +from __future__ import print_function + import csv import argparse import hashlib @@ -383,27 +386,27 @@ class CLanguageGenerator(LanguageGenerator): self.strtypename = strtypename def _boilerplate(self, lines): - print "/*" + print("/*") for line in lines: - print " * %s" % line - print "*/" + print(" * %s" % line) + print("*/") def _array_start_code(self, varname, length): - print "const %s %s[%d] = {" % (self.inttypename, varname, length) + print("const %s %s[%d] = {" % (self.inttypename, varname, length)) def _array_start_name(self, varname, length): - print "const %s %s[%d] = {" % (self.strtypename, varname, length) + print("const %s %s[%d] = {" % (self.strtypename, varname, length)) def _array_end(self): - print "};" + print("};") def _array_entry_code(self, index, value, comment): if value is not None: - print " [0x%x] = 0x%x, /* %s */" % (index, value, comment) + print(" [0x%x] = 0x%x, /* %s */" % (index, value, comment)) def _array_entry_name(self, index, value, comment): if value is not None: - print " [0x%x] = \"%s\", /* %s */" % (index, value, comment) + print(" [0x%x] = \"%s\", /* %s */" % (index, value, comment)) class StdCLanguageGenerator(CLanguageGenerator): @@ -418,60 +421,60 @@ class GLib2LanguageGenerator(CLanguageGenerator): class PythonLanguageGenerator(LanguageGenerator): def _boilerplate(self, lines): - print "#" + print("#") for line in lines: - print "# %s" % line - print "#" + print("# %s" % line) + print("#") def _array_start_code(self, varname, length): - print "%s = [" % varname + print("%s = [" % varname) def _array_start_name(self, varname, length): - print "%s = [" % varname + print("%s = [" % varname) def _array_end(self): - print "]" + print("]") def _array_entry_code(self, index, value, comment): if value is None: - print " None, # %s" % (comment) + print(" None, # %s" % (comment)) else: - print " 0x%x, # %s" % (value, comment) + print(" 0x%x, # %s" % (value, comment)) def _array_entry_name(self, index, value, comment): if value is None: - print " None, # %s" % (comment) + print(" None, # %s" % (comment)) else: - print " \"%s\", # %s" % (value, comment) + print(" \"%s\", # %s" % (value, comment)) class PerlLanguageGenerator(LanguageGenerator): def _boilerplate(self, lines): - print "#" + print("#") for line in lines: - print "# %s" % line - print "#" + print("# %s" % line) + print("#") def _array_start_code(self, varname, length): - print "my @%s = (" % varname + print("my @%s = (" % varname) def _array_start_name(self, varname, length): - print "my @%s = (" % varname + print("my @%s = (" % varname) def _array_end(self): - print ");" + print(");") def _array_entry_code(self, index, value, comment): if value is None: - print " undef, # %s" % (comment) + print(" undef, # %s" % (comment)) else: - print " 0x%x, # %s" % (value, comment) + print(" 0x%x, # %s" % (value, comment)) def _array_entry_name(self, index, value, comment): if value is None: - print " undef, # %s" % (comment) + print(" undef, # %s" % (comment)) else: - print " \"%s\", # %s" % (value, comment) + print(" \"%s\", # %s" % (value, comment)) GENERATORS = { "stdc": StdCLanguageGenerator(), -- cgit v1.1