diff options
| author | jvoisin | 2015-03-31 00:24:37 +0200 |
|---|---|---|
| committer | jvoisin | 2015-03-31 00:24:37 +0200 |
| commit | 46c77ed2f40998c32587479b4754009cbc5efa67 (patch) | |
| tree | 6d22bdcbcb7ad5a7e3d29e6567f6172004b624ce /libmat/mat.py | |
| parent | 79ce29a7d5e41bb3bb2499bc7eb99164c423aa1d (diff) | |
Fix issue #7858
GUI fails to start if run from a directory that contains a "data"
sub-directory <- This is now fixed.
Diffstat (limited to 'libmat/mat.py')
| -rw-r--r-- | libmat/mat.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/libmat/mat.py b/libmat/mat.py index 70e9d75..257a18e 100644 --- a/libmat/mat.py +++ b/libmat/mat.py | |||
| @@ -36,23 +36,23 @@ import strippers # this is loaded here because we need LOGGING_LEVEL | |||
| 36 | def get_logo(): | 36 | def get_logo(): |
| 37 | ''' Return the path to the logo | 37 | ''' Return the path to the logo |
| 38 | ''' | 38 | ''' |
| 39 | if os.path.isfile('./data/mat.png'): | 39 | if os.path.isfile(os.path.join(os.path.curdir, 'data/mat.png')): |
| 40 | return './data/mat.png' | 40 | return os.path.join(os.path.curdir,'data/mat.png') |
| 41 | elif os.path.isfile('/usr/share/pixmaps/mat.png'): | 41 | elif os.path.isfile('/usr/share/pixmaps/mat.png'): |
| 42 | return '/usr/share/pixmaps/mat.png' | 42 | return '/usr/share/pixmaps/mat.png' |
| 43 | elif os.path.isfile('/usr/local/share/pixmaps/mat.png'): | 43 | elif os.path.isfile('/usr/local/share/pixmaps/mat.png'): |
| 44 | return '/usr/local/share/pixmaps/mat.png' | 44 | return '/usr/local/share/pixmaps/mat.png' |
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | def get_datadir(): | 47 | def get_datafile_path(filename): |
| 48 | ''' Return the path to the data directory | 48 | ''' Return the path to the given ressource |
| 49 | ''' | 49 | ''' |
| 50 | if os.path.isdir('./data/'): | 50 | if os.path.isfile(os.path.join(os.path.curdir, 'data', filename)): |
| 51 | return './data/' | 51 | return os.path.join(os.path.curdir, 'data', filename) |
| 52 | elif os.path.isdir('/usr/local/share/mat/'): | 52 | elif os.path.isfile(os.path.join('/usr/local/share/mat/', filename)): |
| 53 | return '/usr/local/share/mat/' | 53 | return os.path.join('/usr/local/share/mat/', filename) |
| 54 | elif os.path.isdir('/usr/share/mat/'): | 54 | elif os.path.isfile(os.path.join('/usr/share/mat/', filename)): |
| 55 | return '/usr/share/mat/' | 55 | return os.path.join('/usr/share/mat/', filename) |
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | def list_supported_formats(): | 58 | def list_supported_formats(): |
| @@ -63,7 +63,7 @@ def list_supported_formats(): | |||
| 63 | handler = XMLParser() | 63 | handler = XMLParser() |
| 64 | parser = xml.sax.make_parser() | 64 | parser = xml.sax.make_parser() |
| 65 | parser.setContentHandler(handler) | 65 | parser.setContentHandler(handler) |
| 66 | path = os.path.join(get_datadir(), 'FORMATS') | 66 | path = get_datafile_path('FORMATS') |
| 67 | with open(path, 'r') as xmlfile: | 67 | with open(path, 'r') as xmlfile: |
| 68 | parser.parse(xmlfile) | 68 | parser.parse(xmlfile) |
| 69 | 69 | ||
