How can I get the module object/namespace for an already-loaded script datablock, given only the name/ID/path of the text datablock?
.as_module()
doesn't do this, because D.texts[0].as_module() is D.texts[0].as_module() == False
— as_module()
returns a new object and namespace, so it can't be used to alter or unregister the already-imported definitions. It also doesn't set __file__
correctly.
Basically, I'm looking for something like addon_utils.modules()
, except with no fake modules, and if it also included all user scripts from which a type has been registered.