Changeset 306e354 in sasmodels


Ignore:
Timestamp:
May 6, 2016 3:06:54 AM (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:
7bf4757
Parents:
c2c51a2
Message:

get_data_files moved to sasmodels package

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/__init__.py

    r9ccf580 r306e354  
    11""" 
    2     1D Modeling for SAS 
     21D Modeling for SAS 
    33""" 
    4 #from sas.models import * 
    54 
    6 import os 
    7 from distutils.filelist import findall 
    8  
    9 __version__ = "2.1.0" 
    10  
    11 def get_data_path(media): 
    12     """ 
    13     """ 
    14     # Check for data path in the package 
    15     path = os.path.join(os.path.dirname(__file__), media) 
    16     if os.path.isdir(path): 
    17         return path 
    18  
    19     # Check for data path next to exe/zip file. 
    20     # If we are inside a py2exe zip file, we need to go up 
    21     # to get to the directory containing  
    22     # the media for this module 
    23     path = os.path.dirname(__file__) 
    24     #Look for maximum n_dir up of the current dir to find media 
    25     n_dir = 12 
    26     for i in range(n_dir): 
    27         path, _ = os.path.split(path) 
    28         media_path = os.path.join(path, media) 
    29         if os.path.isdir(media_path): 
    30             module_media_path = os.path.join(media_path, 'models_media') 
    31             if os.path.isdir(module_media_path): 
    32                 return module_media_path 
    33             return media_path 
    34     
    35     raise RuntimeError('Could not find models media files') 
    36  
    37 def data_files(): 
    38     """ 
    39     Return the data files associated with media. 
    40      
    41     The format is a list of (directory, [files...]) pairs which can be 
    42     used directly in setup(...,data_files=...) for setup.py. 
    43  
    44     """ 
    45     data_files = [] 
    46     path_img = get_data_path(media=os.path.join("sasmodels","sasmodels","models","img")) 
    47     #path_img = get_data_path(media="img") 
    48     im_list = findall(path_img) 
    49     #for f in findall(path): 
    50     #    if os.path.isfile(f) and f not in im_list: 
    51     #        data_files.append(('media/models_media', [f])) 
    52      
    53     for f in im_list: 
    54         data_files.append(('media/models_media/img', [f])) 
    55  
    56     # Add precompiled models dlls to the top level directory "models" 
    57     path_img = get_data_path(media=os.path.join("..", "..", "models")) 
    58     is_list = findall(path_img) 
    59     for f in is_list: 
    60         if os.path.splitext(f)[1] == ".so": 
    61             data_files.append(('models', [f])) 
    62  
    63     return data_files 
    64  
Note: See TracChangeset for help on using the changeset viewer.