Add Turkish docs
[wammu.git] / Wammu / Paths.py
bloba949429d906db2fe3df46d0be8536b54744be499
1 # -*- coding: UTF-8 -*-
2 # vim: expandtab sw=4 ts=4 sts=4:
3 '''
4 Wammu - Phone manager
5 Data path definition and misc path functions
6 '''
7 __author__ = 'Michal Čihař'
8 __email__ = 'michal@cihar.com'
9 __license__ = '''
10 Copyright © 2003 - 2010 Michal Čihař
12 This program is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License version 2 as published by
14 the Free Software Foundation.
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 more details.
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 '''
26 import os
27 import os.path
28 import sys
30 POSSIBLE_PATHS = [
31 os.path.join(sys.exec_prefix, 'share', 'Wammu'), # systemwide
32 os.path.join(sys.exec_prefix, 'local', 'share', 'Wammu'), # systemwide, default distutils
33 os.path.join(os.path.dirname(__file__), '..'), # Local directory
36 def CheckImagesPath(path):
37 return os.path.exists(os.path.join(path, 'images'))
39 for DATAPATH in POSSIBLE_PATHS:
40 if CheckImagesPath(DATAPATH):
41 break
43 if not CheckImagesPath(DATAPATH):
44 print 'Could not find images, you will not see them, check your installation!'
46 def AppIconPath(*args):
47 if sys.platform == 'win32':
48 ext = 'ico'
49 else:
50 ext = 'png'
51 p = os.path.join(*args) + os.extsep + ext
52 if os.path.exists(os.path.join(sys.exec_prefix, 'share', 'pixmaps', p)):
53 return os.path.join(sys.exec_prefix, 'share', 'pixmaps', p)
54 elif os.path.exists(os.path.join(DATAPATH, '..', 'pixmaps', p)):
55 return os.path.join(DATAPATH, '..', 'pixmaps', p)
56 elif os.path.exists(os.path.join('usr', 'share', 'pixmaps', p)):
57 return os.path.join('usr', 'share', 'pixmaps', p)
58 else:
59 return os.path.join('.', 'icon', p)
61 def IconPath(*args):
62 return ImagePath('icons', *args)
64 def MiscPath(*args):
65 return ImagePath('misc', *args)
67 def ImagePath(*args):
68 return os.path.join(DATAPATH, 'images', *args) + os.extsep + 'png'