Changeset da7af35 in sasmodels


Ignore:
Timestamp:
May 10, 2016 9:02:27 AM (9 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
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:
848193e, 4e00c13
Parents:
dc1e729
Message:

On windows, query content of the library.zip file for models.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/core.py

    r7bf4757 rda7af35  
    5656    """ 
    5757    root = dirname(__file__) 
     58    available_models = [] 
    5859    files = sorted(glob(joinpath(root, 'models', "[a-zA-Z]*.py"))) 
    59     available_models = [basename(f)[:-3] for f in files] 
     60    if not files and os.name=='nt': 
     61        # Look inside library.zip on windows, 
     62        # being careful as the library stores only .pyc. 
     63        import zipfile 
     64        location = root[:root.find('.zip')+4] 
     65        zf = zipfile.ZipFile(location,'r') 
     66        for filepath in zf.namelist(): 
     67            # directory structure in library.zip uses "/" 
     68            models_loc = "sasmodels/models" 
     69            if models_loc in filepath: 
     70                base = basename(filepath)[:-4] 
     71                # Careful with non-models. 
     72                if base[0] != "_": 
     73                    available_models.append(base) 
     74    else: 
     75        available_models = [basename(f)[:-3] for f in files] 
    6076    return available_models 
    6177 
Note: See TracChangeset for help on using the changeset viewer.