Changeset a0243f7 in sasmodels for sasmodels/generate.py


Ignore:
Timestamp:
Mar 18, 2018 2:37:27 PM (6 years ago)
Author:
GitHub <noreply@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
e2f1a41
Parents:
bf94e6e (diff), f9c8474 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Paul Butler <butlerpd@…> (03/18/18 14:37:27)
git-committer:
GitHub <noreply@…> (03/18/18 14:37:27)
Message:

Merge pull request #63 from SasView?/ticket-1052

Ticket 1052: Allow custom models to be used in sum|multi models

closes #1052

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/generate.py

    r6cbdcd4 ra0243f7  
    169169 
    170170import sys 
    171 from os.path import abspath, dirname, join as joinpath, exists, getmtime 
     171from os import environ 
     172from os.path import abspath, dirname, join as joinpath, exists, getmtime, sep 
    172173import re 
    173174import string 
     
    900901        kernel_module = load_custom_kernel_module(model_name) 
    901902    else: 
    902         from sasmodels import models 
    903         __import__('sasmodels.models.'+model_name) 
    904         kernel_module = getattr(models, model_name, None) 
     903        try: 
     904            from sasmodels import models 
     905            __import__('sasmodels.models.'+model_name) 
     906            kernel_module = getattr(models, model_name, None) 
     907        except ImportError: 
     908            # If the model isn't a built in model, try the plugin directory 
     909            plugin_path = environ.get('SAS_MODELPATH', None) 
     910            if plugin_path is not None: 
     911                file_name = model_name.split(sep)[-1] 
     912                model_name = plugin_path + sep + file_name + ".py" 
     913                kernel_module = load_custom_kernel_module(model_name) 
     914            else: 
     915                raise 
    905916    return kernel_module 
    906917 
Note: See TracChangeset for help on using the changeset viewer.