Changeset bd4ed1b in sasmodels


Ignore:
Timestamp:
May 10, 2016 4:46:06 PM (9 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:
558d3b3
Parents:
a5da1f2
Message:

cleaner version of file gathering code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/__init__.py

    ra5da1f2 rbd4ed1b  
    2828    from .generate import EXTERNAL_DIR, DATA_PATH 
    2929 
    30     data_files = {} 
    31     def add_patterns(path, patterns): 
    32         data_files[joinpath(EXTERNAL_DIR, *path)] \ 
    33             = [joinpath(DATA_PATH, *(path+[p])) for p in patterns] 
    34     add_patterns([], ['*.c', '*.cl', 'convert.json']) 
    35     add_patterns(['models'], ['*.c']) 
    36     add_patterns(['models', 'lib'], ['*.c']) 
     30    def expand_patterns(path, patterns): 
     31        target_path = joinpath(EXTERNAL_DIR, *path) 
     32        source_path = joinpath(DATA_PATH, *path) 
     33        files = [] 
     34        for p in patterns: 
     35            files.extend(glob.glob(joinpath(source_path, p))) 
     36        return target_path, files 
    3737 
    38     # Fish out full paths for all files. 
    39     return_list=[] 
    40     for path, patterns in data_files.items(): 
    41         files_data=[] 
    42         for pattern in patterns: 
    43             files_data.extend(glob.glob(pattern)) 
    44         return_list.append([path, files_data]) 
     38    return_list = [ 
     39        expand_patterns([], ['*.c', '*.cl', 'convert.json']), 
     40        expand_patterns(['models'], ['*.c']), 
     41        expand_patterns(['models', 'lib'], ['*.c']), 
     42        ] 
    4543    return return_list 
    4644 
Note: See TracChangeset for help on using the changeset viewer.