aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2021-10-01 19:27:00 -0400
committerKevin O'Connor <kevin@koconnor.net>2021-10-01 19:28:27 -0400
commit1717263b5a55d55b0b8dbbffbd3ce45c8d512660 (patch)
tree57a11f868b14598afa20290bc4ed31c2a52d94be /scripts
parent8714282570b14bd7fa403fa58cc2fe81b8ab0053 (diff)
downloadkutter-1717263b5a55d55b0b8dbbffbd3ce45c8d512660.tar.gz
kutter-1717263b5a55d55b0b8dbbffbd3ce45c8d512660.tar.xz
kutter-1717263b5a55d55b0b8dbbffbd3ce45c8d512660.zip
buildcommands: Convert to Python3 string encoding
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/buildcommands.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/scripts/buildcommands.py b/scripts/buildcommands.py
index 5cd2f9d3..37e47f85 100644
--- a/scripts/buildcommands.py
+++ b/scripts/buildcommands.py
@@ -283,7 +283,8 @@ class HandleCommandGeneration:
def create_message_ids(self):
# Create unique ids for each message type
msgid = max(self.msg_to_id.values())
- for msgname in self.commands.keys() + [m for n, m in self.encoders]:
+ mlist = list(self.commands.keys()) + [m for n, m in self.encoders]
+ for msgname in mlist:
msg = self.messages_by_name.get(msgname, msgname)
if msg not in self.msg_to_id:
msgid += 1
@@ -546,17 +547,17 @@ class HandleIdentify:
# Write data dictionary
if options.write_dictionary:
- f = open(options.write_dictionary, 'wb')
+ f = open(options.write_dictionary, 'w')
f.write(datadict)
f.close()
# Format compressed info into C code
- zdatadict = zlib.compress(datadict, 9)
+ zdatadict = bytearray(zlib.compress(datadict.encode(), 9))
out = []
for i in range(len(zdatadict)):
if i % 8 == 0:
out.append('\n ')
- out.append(" 0x%02x," % (ord(zdatadict[i]),))
+ out.append(" 0x%02x," % (zdatadict[i],))
fmt = """
const uint8_t command_identify_data[] PROGMEM = {%s
};
@@ -595,7 +596,7 @@ def main():
# Parse request file
ctr_dispatch = { k: v for h in Handlers for k, v in h.ctr_dispatch.items() }
- f = open(incmdfile, 'rb')
+ f = open(incmdfile, 'r')
data = f.read()
f.close()
for req in data.split('\n'):
@@ -609,7 +610,7 @@ def main():
# Write output
code = "".join([FILEHEADER] + [h.generate_code(options) for h in Handlers])
- f = open(outcfile, 'wb')
+ f = open(outcfile, 'w')
f.write(code)
f.close()