Changes in sasmodels/generate.py [6cbdcd4:d86f0fc] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/generate.py
r6cbdcd4 rd86f0fc 169 169 170 170 import sys 171 from os.path import abspath, dirname, join as joinpath, exists, getmtime 171 from os import environ 172 from os.path import abspath, dirname, join as joinpath, exists, getmtime, sep 172 173 import re 173 174 import string … … 289 290 import loops. 290 291 """ 291 if (info.source and any(lib.startswith('lib/gauss') for lib in info.source)): 292 import os.path 292 if info.source and any(lib.startswith('lib/gauss') for lib in info.source): 293 293 from .gengauss import gengauss 294 path = os.path.join(MODEL_PATH, "lib", "gauss%d.c"%n)295 if not os.path.exists(path):294 path = joinpath(MODEL_PATH, "lib", "gauss%d.c"%n) 295 if not exists(path): 296 296 gengauss(n, path) 297 297 info.source = ["lib/gauss%d.c"%n if lib.startswith('lib/gauss') 298 298 else lib for lib in info.source] 299 299 300 300 def format_units(units): … … 320 320 for w, h in zip(column_widths, PARTABLE_HEADERS)] 321 321 322 sep= " ".join("="*w for w in column_widths)322 underbar = " ".join("="*w for w in column_widths) 323 323 lines = [ 324 sep,324 underbar, 325 325 " ".join("%-*s" % (w, h) 326 326 for w, h in zip(column_widths, PARTABLE_HEADERS)), 327 sep,327 underbar, 328 328 ] 329 329 for p in pars: … … 334 334 "%*g" % (column_widths[3], p.default), 335 335 ])) 336 lines.append( sep)336 lines.append(underbar) 337 337 return "\n".join(lines) 338 338 … … 612 612 """ 613 613 spaces = " "*depth 614 sep= "\n" + spaces615 return spaces + sep.join(s.split("\n"))614 interline_separator = "\n" + spaces 615 return spaces + interline_separator.join(s.split("\n")) 616 616 617 617 … … 619 619 def load_template(filename): 620 620 # type: (str) -> str 621 """ 622 Load template file from sasmodels resource directory. 623 """ 621 624 path = joinpath(DATA_PATH, filename) 622 625 mtime = getmtime(path) … … 900 903 kernel_module = load_custom_kernel_module(model_name) 901 904 else: 902 from sasmodels import models 903 __import__('sasmodels.models.'+model_name) 904 kernel_module = getattr(models, model_name, None) 905 try: 906 from sasmodels import models 907 __import__('sasmodels.models.'+model_name) 908 kernel_module = getattr(models, model_name, None) 909 except ImportError: 910 # If the model isn't a built in model, try the plugin directory 911 plugin_path = environ.get('SAS_MODELPATH', None) 912 if plugin_path is not None: 913 file_name = model_name.split(sep)[-1] 914 model_name = plugin_path + sep + file_name + ".py" 915 kernel_module = load_custom_kernel_module(model_name) 916 else: 917 raise 905 918 return kernel_module 906 919
Note: See TracChangeset
for help on using the changeset viewer.