Changeset a5da1f2 in sasmodels
- Timestamp:
- May 10, 2016 4:36:09 PM (9 years ago)
- 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:
- bd4ed1b
- Parents:
- 848193e
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/__init__.py
rdc1e729 ra5da1f2 24 24 """ 25 25 from os.path import join as joinpath 26 from .generate import SIBLING_DIR, DATA_PATH 26 import glob 27 28 from .generate import EXTERNAL_DIR, DATA_PATH 29 27 30 data_files = {} 28 31 def add_patterns(path, patterns): 29 data_files[joinpath( SIBLING_DIR, *path)] \32 data_files[joinpath(EXTERNAL_DIR, *path)] \ 30 33 = [joinpath(DATA_PATH, *(path+[p])) for p in patterns] 31 34 add_patterns([], ['*.c', '*.cl', 'convert.json']) … … 34 37 35 38 # Fish out full paths for all files. 36 import glob37 39 return_list=[] 38 for key, values in data_files.iteritems():40 for path, patterns in data_files.items(): 39 41 files_data=[] 40 for value in values:41 files_data += [file for file in glob.glob(value)]42 return_list.append([ key, files_data])42 for pattern in patterns: 43 files_data.extend(glob.glob(pattern)) 44 return_list.append([path, files_data]) 43 45 return return_list 44 46 -
sasmodels/generate.py
rc2c51a2 ra5da1f2 224 224 Parameter = namedtuple('Parameter', PARAMETER_FIELDS) 225 225 226 SIBLING_DIR = 'sasmodels-data' 227 PACKAGE_PATH = abspath(dirname(__file__)) 228 SIBLING_PATH = abspath(joinpath(PACKAGE_PATH, '..', 'sasmodels-data')) 229 DATA_PATH = SIBLING_PATH if isdir(SIBLING_PATH) else PACKAGE_PATH 226 def get_data_path(external_dir, target_file): 227 path = abspath(dirname(__file__)) 228 if exists(joinpath(path, target_file)): 229 return path 230 231 # check next to exe/zip file 232 exepath = dirname(sys.executable) 233 path = joinpath(exepath, external_dir) 234 if exists(joinpath(path, target_file)): 235 return path 236 237 # check in py2app Contents/Resources 238 path = joinpath(exepath, '..', 'Resources', external_dir) 239 if exists(joinpath(path, target_file)): 240 return abspath(path) 241 242 raise RuntimeError('Could not find '+joinpath(external_dir, target_file)) 243 244 EXTERNAL_DIR = 'sasmodels-data' 245 DATA_PATH = get_data_path(EXTERNAL_DIR, 'kernel_template.c') 230 246 MODEL_PATH = joinpath(DATA_PATH, 'models') 231 247 C_KERNEL_TEMPLATE_FILE = joinpath(DATA_PATH, 'kernel_template.c')
Note: See TracChangeset
for help on using the changeset viewer.