Inheritance diagram for nipy.utils.data:
Utilities to find files from NIPY data packages
Bases: object
Simple class to add base path to relative path
Methods
| get_filename | |
| list_files |
Initialize datasource
| Parameters: | base_path : str
|
|---|
Examples
>>> from os.path import join as pjoin
>>> repo = Datasource(pjoin('a', 'path'))
>>> fname = repo.get_filename('somedir', 'afile.txt')
>>> fname == pjoin('a', 'path', 'somedir', 'afile.txt')
True
Prepend base path to *path_parts
We make no check whether the returned path exists.
| Parameters: | *path_parts : sequence of strings |
|---|---|
| Returns: | fname : str
|
Recursively list the files in the data source directory.
| Parameters: | relative: bool, optional :
|
|---|---|
| Returns: | file_list: list of strings :
|
Bases: nipy.utils.data.Datasource
Datasource with version information in config file
Methods
| get_filename | |
| list_files |
Initialize versioned datasource
We assume that there is a configuration file with version information in datasource directory tree.
The configuration file contains an entry like:
[DEFAULT]
version = 0.3
The version should have at least a major and a minor version number in the form above.
| Parameters: | base_path : str
config_filaname : None or str
|
|---|
Prepend base path to *path_parts
We make no check whether the returned path exists.
| Parameters: | *path_parts : sequence of strings |
|---|---|
| Returns: | fname : str
|
Recursively list the files in the data source directory.
| Parameters: | relative: bool, optional :
|
|---|---|
| Returns: | file_list: list of strings :
|
Find relative path given path prefixes to search
We raise a DataError if we can’t find the relative path
| Parameters: | root_dirs : sequence of strings
*names : sequence of strings
|
|---|---|
| Returns: | data_dir : str
|
Return specified or guessed locations of NIPY data files
The algorithm is to return paths, extracted from strings, where strings are found in the following order:
Therefore, any paths found in NIPY_DATA_PATH will be searched before paths found in the user directory config.ini
| Parameters: | None : |
|---|---|
| Returns: | paths : sequence of paths |
Notes
We have to add /usr/local/share/nipy if sys.prefix is /usr, because Debian has patched distutils in Python 2.6 to do default distutils installs there:
Examples
>>> pth = get_data_path()
Return datasource *names as found in data_path
data_path is the only allowed keyword argument.
The relative path of the directory we are looking for is given by os.path.join(*names). We search for this path in the list of paths given by data_path. By default data_path is given by get_data_path() in this module.
If we can’t find the relative path, raise a DataError
| Parameters: | *names : sequence of strings
data_path : sequence of strings or None, optional
|
|---|---|
| Returns: | datasource : VersionedDatasource
|