Access project’s data and documentation files.
All access to data and documentation files MUST be made through the functions of this modules to ensure access across different distribution schemes:
Installing from source or from wheel
Installing package as a zip (through the use of pkg_resources)
Linux packaging willing to install data files (and doc files) in alternative folders. In this case, this file must be patched.
Frozen fat binary application using silx (frozen with cx_Freeze or py2app). This needs special care for the resource files in the setup:
With cx_Freeze, add silx/resources to include_files:
import silx.resources
silx_include_files = (os.path.dirname(silx.resources.__file__),
os.path.join('silx', 'resources'))
setup(...
options={'build_exe': {'include_files': [silx_include_files]}}
)
With py2app, add silx in the packages list of the py2app options:
setup(...
options={'py2app': {'packages': ['silx']}}
)
Register another resource directory to the available list.
By default only the directory “silx” is available.
New in version 0.6.
Parameters: |
|
---|---|
Raises ValueError: | |
If the resource directory name already exists. |
List the content of a resource directory.
Result are not prefixed by the resource name.
The resource name can be prefixed by the name of a resource directory. For example “silx:foo.png” identify the resource “foo.png” from the resource directory “silx”. See also register_resource_directory().
Parameters: | resource (str) – Name of the resource directory to list |
---|---|
Returns: | list of name contained in the directory |
Return type: | list |
True is the resource is a resource directory.
The resource name can be prefixed by the name of a resource directory. For example “silx:foo.png” identify the resource “foo.png” from the resource directory “silx”. See also register_resource_directory().
Parameters: | resource (str) – Name of the resource |
---|---|
Return type: | bool |
Return filename corresponding to resource.
The existence of the resource is not checked.
The resource name can be prefixed by the name of a resource directory. For example “silx:foo.png” identify the resource “foo.png” from the resource directory “silx”. See also register_resource_directory().
Parameters: | resource (str) – Resource path relative to resource directory using ‘/’ path separator. It can be either a file or a directory. |
---|---|
Raises ValueError: | |
If the resource name uses an unregistred resource directory name | |
Returns: | Absolute resource path in the file system |
Return type: | str |
Utility class which allows to download test-data from www.silx.org and manage the temporary data during the tests.
Downloads the requested file from web-server available at https://www.silx.org/pub/silx/
Param: | relative name of the image. |
---|---|
Returns: | full path of the locally saved file. |
Downloads the requested tarball from the server https://www.silx.org/pub/silx/ and unzips it into the data directory
Param: | relative name of the image. |
---|---|
Returns: | list of files with their full path. |