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 e223052 was
6d48919,
checked in by Gervaise Alina <gervyh@…>, 14 years ago
|
working on pylint warnings
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[427fa87] | 1 | PLUGIN_ID = "Calculator plug-in 1.0" |
---|
[698a734] | 2 | from calculator import * |
---|
| 3 | |
---|
| 4 | import os |
---|
| 5 | from distutils.filelist import findall |
---|
| 6 | |
---|
[6d48919] | 7 | N_DIR = 12 |
---|
[698a734] | 8 | def get_data_path(media): |
---|
| 9 | """ |
---|
| 10 | """ |
---|
| 11 | # Check for data path in the package |
---|
| 12 | path = os.path.join(os.path.dirname(__file__), media) |
---|
| 13 | if os.path.isdir(path): |
---|
| 14 | return path |
---|
| 15 | # Check for data path next to exe/zip file. |
---|
| 16 | # If we are inside a py2exe zip file, we need to go up |
---|
| 17 | # two levels to get to the directory containing the exe |
---|
| 18 | # We will check if the exe and the xsf are in the same |
---|
| 19 | # directory. |
---|
[85a24d9] | 20 | path = os.path.dirname(__file__) |
---|
| 21 | #Look for maximum n_dir up of the current dir to find media |
---|
[6d48919] | 22 | |
---|
| 23 | #for i in range(n_dir): |
---|
| 24 | i = 0 |
---|
| 25 | while(i < N_DIR): |
---|
[85a24d9] | 26 | path, _ = os.path.split(path) |
---|
| 27 | media_path = os.path.join(path, media) |
---|
| 28 | if os.path.isdir(media_path): |
---|
| 29 | module_media_path = os.path.join(media_path,'calculator_media') |
---|
| 30 | if os.path.isdir(module_media_path): |
---|
| 31 | return module_media_path |
---|
| 32 | return media_path |
---|
[6d48919] | 33 | i += 1 |
---|
[85a24d9] | 34 | |
---|
[698a734] | 35 | raise RuntimeError('Could not find calculator media files') |
---|
| 36 | |
---|
| 37 | def data_files(): |
---|
| 38 | """ |
---|
| 39 | Return the data files associated with media calculator. |
---|
| 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 | """ |
---|
[6d48919] | 45 | data_files = [] |
---|
[698a734] | 46 | path = get_data_path(media="media") |
---|
| 47 | for f in findall(path): |
---|
| 48 | data_files.append(('media/calculator_media', [f])) |
---|
| 49 | return data_files |
---|
Note: See
TracBrowser
for help on using the repository browser.