def _register_old_models(): # type: () -> None """ Place the new models into sasview under the old names. Monkey patch sas.sascalc.fit as sas.models so that sas.models.pluginmodel is available to the plugin modules. """ import sys import sas # needed in order to set sas.models import sas.sascalc.fit sys.modules['sas.models'] = sas.sascalc.fit sas.models = sas.sascalc.fit import sas.models from sasmodels.conversion_table import CONVERSION_TABLE for new_name, conversion in CONVERSION_TABLE.get((3, 1, 2), {}).items(): # CoreShellEllipsoidModel => core_shell_ellipsoid:1 new_name = new_name.split(':')[0] old_name = conversion[0] if len(conversion) < 3 else conversion[2] module_attrs = {old_name: find_model(new_name)} ConstructedModule = type(old_name, (), module_attrs) old_path = 'sas.models.' + old_name setattr(sas.models, old_path, ConstructedModule) sys.modules[old_path] = ConstructedModule
def _register_old_models(): # type: () -> None """ Place the new models into sasview under the old names. Monkey patch sas.sascalc.fit as sas.models so that sas.models.pluginmodel is available to the plugin modules. """ import sys import sas import sas.sascalc.fit sys.modules['sas.models'] = sas.sascalc.fit sas.models = sas.sascalc.fit import sas.models from sasmodels.conversion_table import CONVERSION_TABLE for new_name, conversion in CONVERSION_TABLE.items(): old_name = conversion[0] module_attrs = {old_name: find_model(new_name)} ConstructedModule = type(old_name, (), module_attrs) old_path = 'sas.models.' + old_name setattr(sas.models, old_path, ConstructedModule) sys.modules[old_path] = ConstructedModule