Changeset 68e7f9d in sasmodels for sasmodels/core.py
- Timestamp:
- Apr 4, 2016 12:18: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:
- 9d96649
- Parents:
- 5b0335b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/core.py
r5b0335b r68e7f9d 9 9 from os.path import basename, dirname, join as joinpath, splitext 10 10 from glob import glob 11 import imp12 11 13 12 import numpy as np … … 29 28 30 29 try: 31 # Python 3.5 and up32 from importlib.util import spec_from_file_location, module_from_spec33 def load_module(fullname, path):34 spec = spec_from_file_location(fullname, path)35 module = module_from_spec(spec)36 spec.loader.exec_module(module)37 return module38 except ImportError:39 # CRUFT: python 240 import imp41 def load_module(fullname, path):42 module = imp.load_source(fullname, path)43 return module44 45 try:46 30 np.meshgrid([]) 47 31 meshgrid = np.meshgrid … … 98 82 return product.make_product_info(P_info, Q_info) 99 83 100 kernel_module = load_kernel_module(model_name)84 kernel_module = generate.load_kernel_module(model_name) 101 85 return generate.make_model_info(kernel_module) 102 103 104 def load_kernel_module(model_name):105 if model_name.endswith('.py'):106 path = model_name107 # Pull off the last .ext if it exists; there may be others108 name = basename(splitext(path)[0])109 # Placing the model in the 'sasmodels.custom' name space.110 from sasmodels import custom111 kernel_module = load_module('sasmodels.custom.'+name, path)112 else:113 from sasmodels import models114 __import__('sasmodels.models.'+model_name)115 kernel_module = getattr(models, model_name, None)116 #import sys; print "\n".join(sys.path)117 __import__('sasmodels.models.'+model_name)118 kernel_module = getattr(models, model_name, None)119 return kernel_module120 86 121 87
Note: See TracChangeset
for help on using the changeset viewer.