Some background as to why I want to be able to do this: I've written a script that finds and replaces specific widgets with my own custom made ones (I read the names of existing objects inside the widget collection, and then replace all with a specific prefix by a custom mesh). Every time I want to regenerate my rig, and run the script to replace all the widgets, I also need to delete the original widgets, and purge the orphan data. This is because when you press the rigify "Generate rig" button, it will generate objects with the correct names, but the meshes themselves will be named .002 instead of .001, because all the orphan mesh data means they can't be named the original.
So, instead of manually deleting the widgets, purging the orphan data, selecting the mesh and generating the rig each time... Instead, if I could simply use select_set(True) on my metarig, and activate the "Generate Rig" from a script, then I could let my script handle everything from the the widget deletion, orphan purging, rig generation, and widget replacement, to eye parenting, driver assignment and bone constraints all in one, which would save me heaps of time!
Thanks in advance!