Changeset fc0fcd0 in sasmodels for sasmodels/compare.py


Ignore:
Timestamp:
Mar 11, 2016 7:13:15 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:
fdb1487
Parents:
bea7acb
Message:

remove duplicate code: model list is defined in core

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    ra4a7308 rfc0fcd0  
    9898kerneldll.ALLOW_SINGLE_PRECISION_DLLS = True 
    9999 
    100 # List of available models 
    101 ROOT = dirname(__file__) 
    102 MODELS = [basename(f)[:-3] 
    103           for f in sorted(glob.glob(joinpath(ROOT, "models", "[a-zA-Z]*.py")))] 
     100MODELS = core.list_models() 
    104101 
    105102# CRUFT python 2.6 
     
    671668    Parse command line options. 
    672669    """ 
     670    MODELS = core.list_models() 
    673671    flags = [arg for arg in sys.argv[1:] 
    674672             if arg.startswith('-')] 
     
    683681        print(columnize(MODELS, indent="  ")) 
    684682        sys.exit(1) 
    685     if args[0] not in MODELS: 
    686         print("Model %r not available. Use one of:\n    %s"%(args[0], models)) 
     683 
     684    name = args[0] 
     685    try: 
     686        model_definition = core.load_model_definition(name) 
     687    except ImportError, exc: 
     688        print(str(exc)) 
     689        print("Use one of:\n    " + models) 
    687690        sys.exit(1) 
    688691    if len(args) > 3: 
     
    764767        del engines[2:] 
    765768 
    766     name = args[0] 
    767     model_definition = core.load_model_definition(name) 
    768  
    769769    n1 = int(args[1]) if len(args) > 1 else 1 
    770770    n2 = int(args[2]) if len(args) > 2 else 1 
Note: See TracChangeset for help on using the changeset viewer.