magnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249unittest-saveload
Last change
on this file since db24ec1 was
5a405bd,
checked in by Paul Kienzle <pkienzle@…>, 7 years ago
|
bundle resource files by directory
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[959eb01] | 1 | PLUGIN_ID = "Invariant plug-in 1.0" |
---|
| 2 | import os |
---|
| 3 | |
---|
| 4 | from distutils.filelist import findall |
---|
| 5 | from invariant import * |
---|
| 6 | |
---|
| 7 | def 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 |
---|
[5a405bd] | 17 | # to get to the directory containing |
---|
[959eb01] | 18 | # the media for this module |
---|
| 19 | path = os.path.dirname(__file__) |
---|
| 20 | #Look for maximum n_dir up of the current dir to find media |
---|
| 21 | n_dir = 12 |
---|
| 22 | for i in range(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, 'invariant_media') |
---|
| 27 | if os.path.isdir(module_media_path): |
---|
| 28 | return module_media_path |
---|
| 29 | return media_path |
---|
[5a405bd] | 30 | |
---|
[959eb01] | 31 | raise RuntimeError('Could not find invariant media files') |
---|
| 32 | |
---|
| 33 | def data_files(): |
---|
| 34 | """ |
---|
| 35 | Return the data files associated with media invariant. |
---|
[5a405bd] | 36 | |
---|
[959eb01] | 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 | """ |
---|
| 41 | data_files = [] |
---|
[5a405bd] | 42 | data_files.append(('media/invariant_media', findall(get_data_path("media")))) |
---|
[698a734] | 43 | return data_files |
---|
Note: See
TracBrowser
for help on using the repository browser.