Changeset c499331 in sasmodels for sasmodels/core.py
- Timestamp:
- Mar 25, 2016 5:45:02 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- d19962c
- Parents:
- 5ff1b03
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/core.py
r5ff1b03 rc499331 29 29 ] 30 30 31 try: 32 # Python 3.5 and up 33 from importlib.util import spec_from_file_location, module_from_spec 34 def load_module(fullname, path): 35 spec = spec_from_file_location(fullname, path) 36 module = module_from_spec(spec) 37 spec.loader.exec_module(module) 38 return module 39 except ImportError: 40 # CRUFT: python 2 41 import imp 42 def load_module(fullname, path): 43 module = imp.load_source(fullname, path) 44 return module 45 31 46 def list_models(): 32 47 """ … … 50 65 Load model info and build model. 51 66 """ 52 return build_model(load_model_info(model_name), **kw) 67 if model_name.endswith('.py'): 68 model_info = load_model_info_from_path(model_name) 69 else: 70 model_info = load_model_info(model_name) 71 return build_model(model_info, **kw) 53 72 54 73 def load_model_info_from_path(path): … … 63 82 # though it doesn't actually exist. imp.load_source doesn't seem 64 83 # to care. 65 kernel_module = imp.load_source('sasmodels.custom.'+name, path) 84 import sasmodels.custom 85 kernel_module = load_module('sasmodels.custom.'+name, path) 66 86 67 87 # Now that we have the module, we can load it as usual
Note: See TracChangeset
for help on using the changeset viewer.