User:InfoboxBot/wikipedia edit pages clean.py

The following code was developed for Python 3.6. It may or may not work on previous versions of Python (untested), and I have not tested to see if it works correctly on other operating systems. It is designed to work in conjunction with a pre-existing MySQL database containing scraped infobox data from enwiki within a single discrete table per infobox parent template (which I may sometimes refer to as a infobox "category" even though it's not quite accurate terminology — the reason for this is because I match multiple older infobox template names that are now merged into and redirect to the parent infobox template), and those tables are populated by several other entirely different scripts that I've written, all of which are not currently open source or available for public viewing (I may eventually make the whole project properly & fully open source, but for now I'm keeping it closed-source outside of the core page editing code).

The following is a static snapshot in time of the bot's core page editing code, which is continually evolving and changes to at least a limited extent with every individual specific task executed. This is complete in that this was the entirety of the program at one point in time for one specific series of edits, but it will never be perfectly current — I will only periodically update this page with new versions of the code, not every single time it changes!

NOTE: As of v1.2b the bot now supports seeing & editing multiple infoboxes of the specified category on a single page. Previously it was unable to see or edit anything but the first infobox of the specified category on a single page. The bot is currently still limited to only modifying one infobox per page edit even if multiple infoboxes on the page need to be changed. I am currently uncertain if I will be implementing the ability for the bot to make changes to more than one infobox on a page in a single page edit, as this functionality appears to be fairly complicated to implement and doesn't really seem to provide benefits proportional to the amount of dev time that it'd take. Another bit of somewhat-related functionality that I am uncertain if I will be able to implement is the ability to specify & handle multiple requested changes to infobox values in such a way that any articles that meet the criteria for more than one of the set of requested changes to be made (for a single one of the infoboxes on said article) can have all of the requested changes that it meets the criteria for made in a single page edit. This particular functionality could be implemented as a full shared-priority set of changes to be made to all pages matching the criteria, as a set of conditional additional lower-priority changes to be made when possible in addition to the (single) main change, or as some sort of blend of both of those potential implementations. Neither of these two potential future features are particularly urgent or important — the first one is just something that'd be nice to have but definitely isn't required, while the second one is something that I would really like to implement but can do without if I need to.