[docs]classMyImport(MetaPathFinder):""" Support alias of depreciated sub-modules * model_execution -> execution * model_preparation -> preparation * api -> platform Example: `from oasislmf.model_execution.bash import genbash` is the same as calling the new name `from oasislmf.execution.bash import genbash` https://docs.python.org/3/library/importlib.html#importlib.machinery.PathFinder """def__init__(self):
[docs]deffind_spec(self,fullname,path=None,target=None):import_path=fullname.split(".",1)iffullname.startswith("oasislmf")andlen(import_path)>1:import_path=import_path[1]fordeprecatedinself.depricated_modules:ifdeprecated==import_pathorimport_path.startswith(deprecated+'.'):withwarnings.catch_warnings():warnings.simplefilter("always")warnings.warn(f"imports from 'oasislmf.{deprecated}' are deprecated. Import by using 'oasislmf.{self.depricated_modules[deprecated]}' instead.")import_path=import_path.replace(deprecated,self.depricated_modules[deprecated])returnspec_from_loader(fullname,MyLoader(import_path))