paths.py 1.82 KB
Newer Older
Stephen Kennedy's avatar
Stephen Kennedy committed
1
### Copyright (C) 2002-2006 Stephen Kennedy <stevek@gnome.org>
steve9000's avatar
steve9000 committed
2 3 4 5 6 7 8 9 10 11 12 13 14

### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.

### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
### GNU General Public License for more details.

### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
15 16
### Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
### USA.
steve9000's avatar
steve9000 committed
17

18 19
import os

steve9000's avatar
steve9000 committed
20 21
_locale_dir = ( #LOCALEDIR#
)
22
_help_dir = ( #HELPDIR#
steve9000's avatar
steve9000 committed
23 24 25
)
_share_dir = ( #SHAREDIR#
)
26

27
appdir = os.path.dirname(os.path.dirname(__file__))
28

steve9000's avatar
steve9000 committed
29
if not _locale_dir: _locale_dir = os.path.join(appdir,"po")
30
if not _help_dir:    _help_dir  = os.path.join(appdir,"help")
steve9000's avatar
steve9000 committed
31
if not _share_dir:  _share_dir  = appdir
32

steve9000's avatar
steve9000 committed
33 34
def locale_dir(*args): # i18n files
    return os.path.join(_locale_dir, *args)
35

36 37
def help_dir(*args): # help
    return os.path.join(_help_dir, *args)
38

39 40 41 42 43 44
def share_dir(*args):
    if os.path.exists(os.path.join(_share_dir, "data")):
        return os.path.join(_share_dir, "data", *args)
    else:
        return os.path.join(_share_dir, *args)

45
def ui_dir(*args):
46 47 48 49
    if os.path.exists(os.path.join(_share_dir, "data")):
        return os.path.join(_share_dir, "data", "ui", *args)
    else:
        return os.path.join(_share_dir, "ui", *args)
50 51

def icon_dir(*args):
52 53 54 55
    if os.path.exists(os.path.join(_share_dir, "data")):
        return os.path.join(_share_dir, "data", "icons", *args)
    else:
        return os.path.join(_share_dir, "icons", *args)
steve9000's avatar
steve9000 committed
56