aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-25 20:09:48 -0500
committermat <github@matdoes.dev>2022-05-25 20:09:48 -0500
commitc851204dd0c4b9eee8acc12c4de56b90e1bf041b (patch)
treec1cb22d0e510593a678ce59ebd177f66c1ffa851
parentd69f4445f31b0093d233fc052735c772bdab16b1 (diff)
downloadazalea-drasl-c851204dd0c4b9eee8acc12c4de56b90e1bf041b.tar.xz
Fix detecting changed packet ids
-rw-r--r--codegen/lib/download.py8
-rw-r--r--codegen/migrate.py16
2 files changed, 14 insertions, 10 deletions
diff --git a/codegen/lib/download.py b/codegen/lib/download.py
index 284591ab..5030f8f3 100644
--- a/codegen/lib/download.py
+++ b/codegen/lib/download.py
@@ -41,8 +41,12 @@ def get_version_data(version_id: str):
print(
f'\033[92mGetting data for \033[1m{version_id}..\033[m')
- package_url = next(
- filter(lambda v: v['id'] == version_id, version_manifest_data['versions']))['url']
+ try:
+ package_url = next(
+ filter(lambda v: v['id'] == version_id, version_manifest_data['versions']))['url']
+ except StopIteration:
+ raise ValueError(
+ f'No version with id {version_id} found. Maybe delete downloads/version_manifest.json and try again?')
package_data = requests.get(package_url).json()
with open(f'downloads/{version_id}.json', 'w') as f:
json.dump(package_data, f)
diff --git a/codegen/migrate.py b/codegen/migrate.py
index 304351d3..c623fd58 100644
--- a/codegen/migrate.py
+++ b/codegen/migrate.py
@@ -38,8 +38,8 @@ for packet, packet_name in old_packets.items():
if packet_name not in old_packets.values():
removed_packets.append(packet)
print('Removed packet:', packet)
-for (direction, state), packets in group_packets(removed_packets).items():
- lib.code.packet.remove_packet_ids(packets, direction, state)
+# for (direction, state), packets in group_packets(removed_packets).items():
+# lib.code.packet.remove_packet_ids(packets, direction, state)
print()
@@ -47,13 +47,13 @@ print()
changed_packets: dict[PacketIdentifier, int] = {}
for old_packet, old_packet_name in old_packets.items():
for new_packet, new_packet_name in new_packets.items():
- if old_packet.direction == new_packet.direction and old_packet.state == new_packet.state and old_packet.packet_id != new_packet.packet_id:
+ if old_packet_name == new_packet_name and old_packet.direction == new_packet.direction and old_packet.state == new_packet.state and old_packet.packet_id != new_packet.packet_id:
changed_packets[old_packet] = new_packet.packet_id
print('Changed packet id:', old_packet, '->',
new_packet, f'({new_packet_name})')
break
-for (direction, state), packets in group_packets(list(changed_packets.keys())).items():
- lib.code.packet.remove_packet_ids(packets, direction, state)
+# for (direction, state), packets in group_packets(list(changed_packets.keys())).items():
+# lib.code.packet.remove_packet_ids(packets, direction, state)
print()
@@ -64,9 +64,9 @@ for packet, packet_name in new_packets.items():
if packet_name not in old_packets.values():
added_packets.append(packet)
print('Added packet:', packet)
-for packet in added_packets:
- lib.code.packet.generate_packet(
- new_burger_data[0]['packets']['packet'], new_mappings, packet.packet_id, packet.direction, packet.state)
+# for packet in added_packets:
+# lib.code.packet.generate_packet(
+# new_burger_data[0]['packets']['packet'], new_mappings, packet.packet_id, packet.direction, packet.state)
lib.code.utils.fmt()
print('Done!')