aboutsummaryrefslogtreecommitdiff
path: root/codegen/migrate.py
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-24 23:05:44 -0500
committermat <github@matdoes.dev>2022-05-24 23:05:44 -0500
commitfb3b002d94076de463e2af776666387db9e75835 (patch)
treea40cff192e4175babaa842e4b3facd17e97e6806 /codegen/migrate.py
parent0a314bca16f6de199c319ffb0d84a5d5c3a61387 (diff)
downloadazalea-drasl-fb3b002d94076de463e2af776666387db9e75835.tar.xz
start adding migrate
Diffstat (limited to 'codegen/migrate.py')
-rw-r--r--codegen/migrate.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/codegen/migrate.py b/codegen/migrate.py
new file mode 100644
index 00000000..c0748400
--- /dev/null
+++ b/codegen/migrate.py
@@ -0,0 +1,52 @@
+import lib.code.utils
+import lib.code.version
+import lib.download
+import sys
+import os
+
+old_version_id = lib.code.version.get_version_id()
+old_mappings = lib.download.get_mappings_for_version(old_version_id)
+old_burger_data = lib.download.get_burger_data_for_version(old_version_id)
+old_packet_list = list(old_burger_data[0]['packets']['packet'].values())
+
+new_version_id = sys.argv[1]
+new_mappings = lib.download.get_mappings_for_version(new_version_id)
+new_burger_data = lib.download.get_burger_data_for_version(new_version_id)
+new_packet_list = list(new_burger_data[0]['packets']['packet'].values())
+
+old_packet_ids = {}
+new_packet_ids = {}
+
+for packet in old_packet_list:
+ assert packet['class'].endswith('.class')
+ packet_name = old_mappings.get_class(packet['class'][:-6])
+ old_packet_ids[packet_name] = packet['id']
+for packet in new_packet_list:
+ assert packet['class'].endswith('.class')
+ packet_name = new_mappings.get_class(packet['class'][:-6])
+ new_packet_ids[packet_name] = packet['id']
+
+# find packets that changed ids
+for packet_name in old_packet_ids:
+ if packet_name in new_packet_ids:
+ if old_packet_ids[packet_name] != new_packet_ids[packet_name]:
+ print(packet_name, 'id changed from',
+ old_packet_ids[packet_name], 'to', new_packet_ids[packet_name])
+
+print()
+
+# find removed packets
+for packet_name in old_packet_ids:
+ if packet_name not in new_packet_ids:
+ print(packet_name, 'removed')
+
+print()
+
+# find added packets
+for packet_name in new_packet_ids:
+ if packet_name not in old_packet_ids:
+ print(packet_name, 'added')
+
+lib.code.utils.fmt()
+
+print('Done!')