Changeset 68e7f9d in sasmodels for sasmodels/core.py


Ignore:
Timestamp:
Apr 4, 2016 12:18:02 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
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
Message:

remove pyc file after loading custom model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/core.py

    r5b0335b r68e7f9d  
    99from os.path import basename, dirname, join as joinpath, splitext 
    1010from glob import glob 
    11 import imp 
    1211 
    1312import numpy as np 
     
    2928 
    3029try: 
    31     # Python 3.5 and up 
    32     from importlib.util import spec_from_file_location, module_from_spec 
    33     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 module 
    38 except ImportError: 
    39     # CRUFT: python 2 
    40     import imp 
    41     def load_module(fullname, path): 
    42         module = imp.load_source(fullname, path) 
    43         return module 
    44  
    45 try: 
    4630    np.meshgrid([]) 
    4731    meshgrid = np.meshgrid 
     
    9882        return product.make_product_info(P_info, Q_info) 
    9983 
    100     kernel_module = load_kernel_module(model_name) 
     84    kernel_module = generate.load_kernel_module(model_name) 
    10185    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_name 
    107         # Pull off the last .ext if it exists; there may be others 
    108         name = basename(splitext(path)[0]) 
    109         # Placing the model in the 'sasmodels.custom' name space. 
    110         from sasmodels import custom 
    111         kernel_module = load_module('sasmodels.custom.'+name, path) 
    112     else: 
    113         from sasmodels import models 
    114         __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_module 
    12086 
    12187 
Note: See TracChangeset for help on using the changeset viewer.