source: sasview/calculatorview/src/sans/perspectives/calculator/__init__.py @ 31f3222b

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 31f3222b was b7cfa8d, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Re #5 fixing installer build on mac

  • Property mode set to 100644
File size: 1.5 KB
Line 
1PLUGIN_ID = "Calculator plug-in 1.0"
2import os
3from distutils.filelist import findall
4N_DIR = 12
5def get_data_path(media):
6    """
7    """
8    # Check for data path in the package
9    path = os.path.join(os.path.dirname(__file__), media)
10    if os.path.isdir(path):
11        return path
12    # Check for data path next to exe/zip file.
13    # If we are inside a py2exe zip file, we need to go up
14    # two levels to get to the directory containing the exe
15    # We will check if the exe and the xsf are in the same
16    # directory.
17    path = os.path.dirname(__file__)
18    #Look for maximum n_dir up of the current dir to find media
19   
20    #for i in range(n_dir):
21    i = 0
22    while(i < N_DIR):
23        path, _ = os.path.split(path)
24        media_path = os.path.join(path, media)
25        if os.path.isdir(media_path):
26             module_media_path = os.path.join(media_path,'calculator_%s'% media)
27             if os.path.isdir(module_media_path):
28                 return module_media_path
29             return media_path
30        i += 1
31   
32    raise RuntimeError('Could not find calculator media files')
33
34def data_files():
35    """
36    Return the data files associated with media calculator.
37   
38    The format is a list of (directory, [files...]) pairs which can be
39    used directly in setup(...,data_files=...) for setup.py.
40
41    """
42    data_files = []
43    path = get_data_path(media="media")
44    for f in findall(path):
45        data_files.append(('media/calculator_media', [f]))
46    return data_files
Note: See TracBrowser for help on using the repository browser.