mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
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 <bochecha@daitauha.fr> Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
This commit is contained in:
parent
9bd8b0f700
commit
12eb5b496b
1 changed files with 2 additions and 2 deletions
|
|
@ -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};')
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue