diff options
| author | jvoisin | 2015-11-03 14:35:46 +0100 |
|---|---|---|
| committer | jvoisin | 2015-11-03 14:35:46 +0100 |
| commit | bbdaaeaba42a4cf6ed61fed424e253aeb9b29a6a (patch) | |
| tree | 18d95ce4d202992e860fec7dba3e1865468f7ace | |
| parent | d87711e172d215198f1831cad85e7bbdae727093 (diff) | |
Minor refactorisation of `get_datafile_path()`
Diffstat (limited to '')
| -rw-r--r-- | libmat/mat.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/libmat/mat.py b/libmat/mat.py index 3947606..decbbed 100644 --- a/libmat/mat.py +++ b/libmat/mat.py | |||
| @@ -48,12 +48,11 @@ def get_datafile_path(filename): | |||
| 48 | """ Return the path to $filename | 48 | """ Return the path to $filename |
| 49 | :param string filename: | 49 | :param string filename: |
| 50 | """ | 50 | """ |
| 51 | if os.path.isfile(os.path.join(os.path.curdir, 'data', filename)): | 51 | paths = ['data', '/usr/local/share/mat/', '/usr/share/mat/'] |
| 52 | return os.path.join(os.path.curdir, 'data', filename) | 52 | for path in paths: |
| 53 | elif os.path.isfile(os.path.join('/usr/local/share/mat/', filename)): | 53 | filepath = os.path.join(os.path.curdir, path, filename) |
| 54 | return os.path.join('/usr/local/share/mat/', filename) | 54 | if os.path.isfile(filepath): |
| 55 | elif os.path.isfile(os.path.join('/usr/share/mat/', filename)): | 55 | return filepath |
| 56 | return os.path.join('/usr/share/mat/', filename) | ||
| 57 | 56 | ||
| 58 | 57 | ||
| 59 | def list_supported_formats(): | 58 | def list_supported_formats(): |
