Changeset 424fe00 in sasmodels for sasmodels/compare_many.py


Ignore:
Timestamp:
Sep 11, 2016 11:17:05 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:
2a0c7a6
Parents:
52ec91e
Message:

send sys.argv to main()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare_many.py

    r40a87fa r424fe00  
    229229    print_models() 
    230230 
    231 def main(): 
     231def main(argv): 
    232232    """ 
    233233    Main program. 
    234234    """ 
    235     if len(sys.argv) not in (6, 7): 
     235    if len(argv) not in (5, 6): 
    236236        print_help() 
    237         sys.exit(1) 
    238  
    239     model = sys.argv[1] 
     237        return 
     238 
     239    model = argv[0] 
    240240    if not (model in MODELS) and (model != "all"): 
    241241        print('Bad model %s.  Use "all" or one of:'%model) 
    242242        print_models() 
    243         sys.exit(1) 
     243        return 
    244244    try: 
    245         count = int(sys.argv[2]) 
    246         is2D = sys.argv[3].startswith('2d') 
    247         assert sys.argv[3][1] == 'd' 
    248         Nq = int(sys.argv[3][2:]) 
    249         mono = sys.argv[4] == 'mono' 
    250         cutoff = float(sys.argv[4]) if not mono else 0 
    251         base = sys.argv[5] 
    252         comp = sys.argv[6] if len(sys.argv) > 6 else "sasview" 
     245        count = int(argv[1]) 
     246        is2D = argv[2].startswith('2d') 
     247        assert argv[2][1] == 'd' 
     248        Nq = int(argv[2][2:]) 
     249        mono = argv[3] == 'mono' 
     250        cutoff = float(argv[3]) if not mono else 0 
     251        base = argv[4] 
     252        comp = argv[5] if len(argv) > 5 else "sasview" 
    253253    except Exception: 
    254254        traceback.print_exc() 
    255255        print_usage() 
    256         sys.exit(1) 
     256        return 
    257257 
    258258    data, index = make_data({'qmax':1.0, 'is2d':is2D, 'nq':Nq, 'res':0., 
     
    265265if __name__ == "__main__": 
    266266    #from .compare import push_seed 
    267     #with push_seed(1): main() 
    268     main() 
     267    #with push_seed(1): main(sys.argv[1:]) 
     268    main(sys.argv[1:]) 
Note: See TracChangeset for help on using the changeset viewer.