source: sasview/src/sas/sasgui/perspectives/invariant/__init__.py @ 762ee3e

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 762ee3e was d85c194, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 9 years ago

Remaining modules refactored

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[c128284]1PLUGIN_ID = "Invariant plug-in 1.0"
[698a734]2import os
[b699768]3
[b7cfa8d]4from distutils.filelist import findall
[b699768]5from invariant import *
6
[698a734]7def get_data_path(media):
8    """
9    """
10    # Check for data path in the package
11    path = os.path.join(os.path.dirname(__file__), media)
12    if os.path.isdir(path):
13        return path
14
15    # Check for data path next to exe/zip file.
16    # If we are inside a py2exe zip file, we need to go up
[e56869f]17    # to get to the directory containing
[85a24d9]18    # the media for this module
[e56869f]19    path = os.path.dirname(__file__)
[85a24d9]20    #Look for maximum n_dir up of the current dir to find media
[e56869f]21    n_dir = 12
[698a734]22    for i in range(n_dir):
[e56869f]23        path, _ = os.path.split(path)
24        media_path = os.path.join(path, media)
25        if os.path.isdir(media_path):
[4a2b054]26            module_media_path = os.path.join(media_path, 'invariant_media')
27            if os.path.isdir(module_media_path):
28                return module_media_path
29            return media_path
[e56869f]30   
[698a734]31    raise RuntimeError('Could not find invariant media files')
32
33def data_files():
34    """
35    Return the data files associated with media invariant.
36   
37    The format is a list of (directory, [files...]) pairs which can be
38    used directly in setup(...,data_files=...) for setup.py.
39
40    """
[4a2b054]41    data_files = []
[698a734]42    path = get_data_path(media="media")
[b7cfa8d]43    for f in findall(path):
[698a734]44        data_files.append(('media/invariant_media', [f]))
45    return data_files
Note: See TracBrowser for help on using the repository browser.