diff mbox series

[VSP-Tests,v2,1/3] gen-lut: Update for python3

Message ID 20200917140450.12264-2-kieran.bingham@ideasonboard.com (mailing list archive)
State New
Delegated to: Kieran Bingham
Headers show
Series Run as user, and python3 support | expand

Commit Message

Kieran Bingham Sept. 17, 2020, 2:04 p.m. UTC
Python2 has now gone end-of-life and is discontinued.

Update the gen-lut utility to use python3 directly, converting xrange
usages to range, and using bytearray to store the tables and write them
directly removing the discontinued file object.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 data/frames/gen-lut.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/data/frames/gen-lut.py b/data/frames/gen-lut.py
index 07889b11f4ac..335b9f1613bc 100755
--- a/data/frames/gen-lut.py
+++ b/data/frames/gen-lut.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/python
+#!/usr/bin/python3
 # SPDX-License-Identifier: GPL-2.0-or-later
 # SPDX-FileCopyrightText: 2016 Renesas Electronics Corporation
 
@@ -49,26 +49,26 @@  def clu_value(x, y, z, scale, a, freq, weights):
 	return (z, y, x, 0)
 
 def generate_clu(config):
-	clu = []
+	clu = bytearray()
 
-	for z in xrange(17):
-		for y in xrange(17):
-			for x in xrange(17):
+	for z in range(17):
+		for y in range(17):
+			for x in range(17):
 				clu.extend(clu_value(x, y, z, **config[1]))
 
-	file('clu-%s.bin' % config[0], 'wb').write(''.join([chr(c) for c in clu]))
+	open('clu-%s.bin' % config[0], 'wb').write(clu)
 
 
 def gamma(vin, gamma, scale):
 	return int(255 * scale * math.pow(vin / 255., gamma))
 
 def generate_lut(config):
-	lut = []
-	for i in xrange(256):
+	lut = bytearray()
+	for i in range(256):
 		lut.extend([gamma(i, g, config[1]) for g in config[2:]])
 		lut.append(0)
 
-	file('lut-%s.bin' % config[0], 'wb').write(''.join([chr(c) for c in lut]))
+	open('lut-%s.bin' % config[0], 'wb').write(lut)
 
 
 def main(argv):