PDA

View Full Version : Helper script to update zoneopcodes.xml



cn187
04-26-2020, 07:53 PM
It might just be me, but I find it a bit annoying to hunt through zoneopcodes.xml to find each opcode and update it. Especially since the order I find them in is never the order that they're in the file. Even using find/replace is more hassle than I like, to be honest.

So I wrote a simple python script to take a list of opcode/opname pairs (in any order) and the current zoneopcodes.xml, and spit out a new copy of zoneopcodes.xml with the opcode id's and update dates replaced (based on date of run). This means as you find opcodes, you can just write them down in the list as you find them, then run the script to put them in the correct place in zoneopcodes.xml without needing to hunt for each one. It has simplified and sped up my workflow, so I figured I'd share in case anyone else wants to use it.

Note - this isn't a full xml parse, but a simple regex replace. As long as zoneopcodes.xml stays formatted roughly the same way it is now, then the script should continue working. But if someone reformats the whole file, then all bets are off. It should probably be updated to actually parse the XML so it can be more robust against formatting changes. But I wasn't happy with the XML libs I tried, so I decided to just regex it instead.

I've committed it to both trunk and the beta6 branch under the "scripts" directory, along with a sample of the opcodes file I use for input (sorted alphabetically, so it's easier to find items to reorder them however you want).

If anyone has suggestions for improvement/enhancement, feel free to let me know or take a stab at updating it yourself.