summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Bridon <[email protected]>2018-06-17 14:44:46 +0200
committerEric Engestrom <[email protected]>2018-08-01 14:26:19 +0100
commit12eb5b496bc311ebfd1e68921ec7429e709daaca (patch)
tree120e5818e1a9bd6f48b4ec98710d8bb01de2584d
parent9bd8b0f700255611e3eadf91a0f7bb037b6a2e64 (diff)
python: Better get character ordinals
In Python 2, iterating over a byte-string yields single-byte strings, and we can pass them to ord() to get the corresponding integer. In Python 3, iterating over a byte-string directly yields those integers. Transforming the byte string into a bytearray gives us a list of the integers corresponding to each byte in the string, removing the need to call ord(). This makes the script compatible with both Python 2 and 3. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
-rw-r--r--src/intel/genxml/gen_zipped_file.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/intel/genxml/gen_zipped_file.py b/src/intel/genxml/gen_zipped_file.py
index af2008bea03..1d6bd568246 100644
--- a/src/intel/genxml/gen_zipped_file.py
+++ b/src/intel/genxml/gen_zipped_file.py
@@ -62,8 +62,8 @@ def main():
print("")
print("static const uint8_t compress_genxmls[] = {")
print(" ", end='')
- for i, c in enumerate(compressed_data, start=1):
- print("0x%.2x, " % ord(c), end='\n ' if not i % 12 else '')
+ for i, c in enumerate(bytearray(compressed_data), start=1):
+ print("0x%.2x, " % c, end='\n ' if not i % 12 else '')
print('\n};')