| ... |
... |
@@ -52,17 +52,17 @@ TYPE_DATA |
|
52
|
52
|
# just leave it as is. Since these paths are meant to be internal to Gajim and
|
|
53
|
53
|
# not displayed to the user, Unicode is not really necessary here.
|
|
54
|
54
|
|
|
55
|
|
-def fse(s):
|
|
56
|
|
- """
|
|
57
|
|
- Convert from filesystem encoding if not already Unicode
|
|
58
|
|
- """
|
|
59
|
|
- return s
|
|
60
|
55
|
|
|
61
|
56
|
def windowsify(s):
|
|
62
|
57
|
if os.name == 'nt':
|
|
63
|
58
|
return s.capitalize()
|
|
64
|
59
|
return s
|
|
65
|
60
|
|
|
|
61
|
+
|
|
|
62
|
+def get(key):
|
|
|
63
|
+ return gajimpaths[key]
|
|
|
64
|
+
|
|
|
65
|
+
|
|
66
|
66
|
class ConfigPaths:
|
|
67
|
67
|
def __init__(self):
|
|
68
|
68
|
# {'name': (type, path), } type can be TYPE_CONFIG, TYPE_CACHE, TYPE_DATA
|
| ... |
... |
@@ -77,7 +77,7 @@ class ConfigPaths: |
|
77
|
77
|
# variable 'appdata' is in? Assuming it to be in filesystem
|
|
78
|
78
|
# encoding.
|
|
79
|
79
|
self.config_root = self.cache_root = self.data_root = \
|
|
80
|
|
- os.path.join(fse(os.environ['appdata']), 'Gajim')
|
|
|
80
|
+ os.path.join(os.environ['appdata'], 'Gajim')
|
|
81
|
81
|
except KeyError:
|
|
82
|
82
|
# win9x, in cwd
|
|
83
|
83
|
self.config_root = self.cache_root = self.data_root = '.'
|
| ... |
... |
@@ -97,6 +97,13 @@ class ConfigPaths: |
|
97
|
97
|
base = expand('~/.local/share')
|
|
98
|
98
|
self.data_root = os.path.join(base, 'gajim')
|
|
99
|
99
|
|
|
|
100
|
+ basedir = os.environ.get('GAJIM_BASEDIR', defs.basedir)
|
|
|
101
|
+ self.add('DATA', None, os.path.join(basedir, 'data'))
|
|
|
102
|
+ self.add('GUI', None, os.path.join(basedir, 'data', 'gui'))
|
|
|
103
|
+ self.add('ICONS', None, os.path.join(basedir, 'icons'))
|
|
|
104
|
+ self.add('HOME', None, os.path.expanduser('~'))
|
|
|
105
|
+ self.add('PLUGINS_BASE', None, os.path.join(basedir, 'plugins'))
|
|
|
106
|
+
|
|
100
|
107
|
def add(self, name, type_, path):
|
|
101
|
108
|
self.paths[name] = (type_, path)
|
|
102
|
109
|
|
| ... |
... |
@@ -125,12 +132,12 @@ class ConfigPaths: |
|
125
|
132
|
self.config_root = self.cache_root = self.data_root = root
|
|
126
|
133
|
|
|
127
|
134
|
self.init_profile(profile)
|
|
128
|
|
-
|
|
|
135
|
+
|
|
129
|
136
|
if len(profile) > 0 and profile_separation:
|
|
130
|
137
|
profile = u'.' + profile
|
|
131
|
138
|
else:
|
|
132
|
139
|
profile = ''
|
|
133
|
|
-
|
|
|
140
|
+
|
|
134
|
141
|
d = {'LOG_DB': 'logs.db', 'MY_CACERTS': 'cacerts.pem',
|
|
135
|
142
|
'MY_EMOTS': 'emoticons', 'MY_ICONSETS': 'iconsets',
|
|
136
|
143
|
'MY_MOOD_ICONSETS': 'moods', 'MY_ACTIVITY_ICONSETS': 'activities',
|
| ... |
... |
@@ -159,24 +166,12 @@ class ConfigPaths: |
|
159
|
166
|
else:
|
|
160
|
167
|
self.add('MY_CONFIG', TYPE_CONFIG, '')
|
|
161
|
168
|
|
|
162
|
|
- basedir = fse(os.environ.get('GAJIM_BASEDIR', defs.basedir))
|
|
163
|
|
- self.add('DATA', None, os.path.join(basedir, windowsify('data')))
|
|
164
|
|
- self.add('ICONS', None, os.path.join(basedir, windowsify('icons')))
|
|
165
|
|
- self.add('HOME', None, fse(os.path.expanduser('~')))
|
|
166
|
|
- self.add('PLUGINS_BASE', None, os.path.join(basedir,
|
|
167
|
|
- windowsify('plugins')))
|
|
168
|
169
|
try:
|
|
169
|
|
- self.add('TMP', None, fse(tempfile.gettempdir()))
|
|
|
170
|
+ self.add('TMP', None, tempfile.gettempdir())
|
|
170
|
171
|
except IOError as e:
|
|
171
|
172
|
print('Error opening tmp folder: %s\nUsing %s' % (str(e),
|
|
172
|
173
|
os.path.expanduser('~')), file=sys.stderr)
|
|
173
|
|
- self.add('TMP', None, fse(os.path.expanduser('~')))
|
|
174
|
|
-
|
|
175
|
|
- try:
|
|
176
|
|
- import svn_config
|
|
177
|
|
- svn_config.configure(self)
|
|
178
|
|
- except (ImportError, AttributeError):
|
|
179
|
|
- pass
|
|
|
174
|
+ self.add('TMP', None, os.path.expanduser('~'))
|
|
180
|
175
|
|
|
181
|
176
|
def init_profile(self, profile):
|
|
182
|
177
|
conffile = windowsify('config')
|