diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2017-02-15 18:13:51 +0000 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2017-02-15 18:13:51 +0000 |
commit | f9b756e3a5508ef44d3203a8ad4082e9e5fab84a (patch) | |
tree | 9c1c7b633523b78a59c8b5c979faf6738dad01ad | |
parent | 0d90289be03d82c82f7b313e4b4864d31439bdb2 (diff) | |
download | keycodemapdb-f9b756e3a5508ef44d3203a8ad4082e9e5fab84a.zip keycodemapdb-f9b756e3a5508ef44d3203a8ad4082e9e5fab84a.tar.gz keycodemapdb-f9b756e3a5508ef44d3203a8ad4082e9e5fab84a.tar.bz2 |
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 <berrange@redhat.com>
-rwxr-xr-x | tools/keymap-gen | 59 |
1 files changed, 31 insertions, 28 deletions
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(), |