From 0f7b18fa0d353aab0a44082b1aca8d8c00df71a7 Mon Sep 17 00:00:00 2001 From: Mathieu Bridon Date: Thu, 5 Jul 2018 15:17:32 +0200 Subject: python: Use the print function In Python 2, `print` was a statement, but it became a function in Python 3. Using print functions everywhere makes the script compatible with Python versions >= 2.6, including Python 3. Signed-off-by: Mathieu Bridon Acked-by: Eric Engestrom Acked-by: Dylan Baker --- src/util/format_srgb.py | 69 ++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 38 deletions(-) (limited to 'src/util/format_srgb.py') diff --git a/src/util/format_srgb.py b/src/util/format_srgb.py index 44b35a061d6..0b3b5611fc9 100644 --- a/src/util/format_srgb.py +++ b/src/util/format_srgb.py @@ -1,3 +1,4 @@ +from __future__ import print_function CopyRight = ''' /************************************************************************** @@ -57,33 +58,27 @@ def linear_to_srgb(x): def generate_srgb_tables(): - print 'const float' - print 'util_format_srgb_8unorm_to_linear_float_table[256] = {' + print('const float') + print('util_format_srgb_8unorm_to_linear_float_table[256] = {') for j in range(0, 256, 4): - print ' ', - for i in range(j, j + 4): - print '%.7e,' % (srgb_to_linear(i / 255.0),), - print - print '};' - print - print 'const uint8_t' - print 'util_format_srgb_to_linear_8unorm_table[256] = {' + print(' ', end=' ') + print(' '.join(['%.7e,' % srgb_to_linear(i / 255.0) for i in range(j, j + 4)])) + print('};') + print() + print('const uint8_t') + print('util_format_srgb_to_linear_8unorm_table[256] = {') for j in range(0, 256, 16): - print ' ', - for i in range(j, j + 16): - print '%3u,' % (int(srgb_to_linear(i / 255.0) * 255.0 + 0.5),), - print - print '};' - print - print 'const uint8_t' - print 'util_format_linear_to_srgb_8unorm_table[256] = {' + print(' ', end=' ') + print(' '.join(['%3u,' % int(srgb_to_linear(i / 255.0) * 255.0 + 0.5) for i in range(j, j + 16)])) + print('};') + print() + print('const uint8_t') + print('util_format_linear_to_srgb_8unorm_table[256] = {') for j in range(0, 256, 16): - print ' ', - for i in range(j, j + 16): - print '%3u,' % (int(linear_to_srgb(i / 255.0) * 255.0 + 0.5),), - print - print '};' - print + print(' ', end=' ') + print(' '.join(['%3u,' % int(linear_to_srgb(i / 255.0) * 255.0 + 0.5) for i in range(j, j + 16)])) + print('};') + print() # calculate the table interpolation values used in float linear to unorm8 srgb numexp = 13 @@ -128,25 +123,23 @@ def generate_srgb_tables(): valtable.append((int_a << 16) + int_b) - print 'const unsigned' - print 'util_format_linear_to_srgb_helper_table[104] = {' + print('const unsigned') + print('util_format_linear_to_srgb_helper_table[104] = {') for j in range(0, nbuckets, 4): - print ' ', - for i in range(j, j + 4): - print '0x%08x,' % (valtable[i],), - print - print '};' - print + print(' ', end=' ') + print(' '.join(['0x%08x,' % valtable[i] for i in range(j, j + 4)])) + print('};') + print() def main(): - print '/* This file is autogenerated by u_format_srgb.py. Do not edit directly. */' - print + print('/* This file is autogenerated by u_format_srgb.py. Do not edit directly. */') + print() # This will print the copyright message on the top of this file - print CopyRight.strip() - print - print '#include "format_srgb.h"' - print + print(CopyRight.strip()) + print() + print('#include "format_srgb.h"') + print() generate_srgb_tables() -- cgit v1.2.3