aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/format_srgb.py
diff options
context:
space:
mode:
authorMathieu Bridon <[email protected]>2018-07-05 15:17:32 +0200
committerDylan Baker <[email protected]>2018-07-06 10:04:22 -0700
commit0f7b18fa0d353aab0a44082b1aca8d8c00df71a7 (patch)
treee511fe8f70b48ad5203e3a0e52d0dc1b086bfd91 /src/util/format_srgb.py
parentb3a42fa0667caeeebabd9e6aeb46a9534810c2f3 (diff)
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 <[email protected]> Acked-by: Eric Engestrom <[email protected]> Acked-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/util/format_srgb.py')
-rw-r--r--src/util/format_srgb.py69
1 files changed, 31 insertions, 38 deletions
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()