Merge branch 'dev' into 'master'
Improvements for Configpaths See merge request !22
This commit is contained in:
commit
e967d4ed77
|
@ -130,9 +130,7 @@ def split_db():
|
|||
print('spliting database')
|
||||
if os.name == 'nt':
|
||||
try:
|
||||
import configpaths
|
||||
OLD_LOG_DB_FOLDER = os.path.join(configpaths.fse(
|
||||
os.environ['appdata']), 'Gajim')
|
||||
OLD_LOG_DB_FOLDER = os.path.join(os.environ['appdata'], 'Gajim')
|
||||
except KeyError:
|
||||
OLD_LOG_DB_FOLDER = '.'
|
||||
else:
|
||||
|
@ -187,8 +185,7 @@ def check_and_possibly_move_config():
|
|||
|
||||
if os.name == 'nt':
|
||||
try:
|
||||
OLD_LOG_DB_FOLDER = os.path.join(configpaths.fse(
|
||||
os.environ['appdata']), 'Gajim')
|
||||
OLD_LOG_DB_FOLDER = os.path.join(os.environ['appdata'], 'Gajim')
|
||||
except KeyError:
|
||||
OLD_LOG_DB_FOLDER = '.'
|
||||
else:
|
||||
|
|
|
@ -52,17 +52,17 @@ TYPE_DATA
|
|||
# just leave it as is. Since these paths are meant to be internal to Gajim and
|
||||
# not displayed to the user, Unicode is not really necessary here.
|
||||
|
||||
def fse(s):
|
||||
"""
|
||||
Convert from filesystem encoding if not already Unicode
|
||||
"""
|
||||
return s
|
||||
|
||||
def windowsify(s):
|
||||
if os.name == 'nt':
|
||||
return s.capitalize()
|
||||
return s
|
||||
|
||||
|
||||
def get(key):
|
||||
return gajimpaths[key]
|
||||
|
||||
|
||||
class ConfigPaths:
|
||||
def __init__(self):
|
||||
# {'name': (type, path), } type can be TYPE_CONFIG, TYPE_CACHE, TYPE_DATA
|
||||
|
@ -77,7 +77,7 @@ class ConfigPaths:
|
|||
# variable 'appdata' is in? Assuming it to be in filesystem
|
||||
# encoding.
|
||||
self.config_root = self.cache_root = self.data_root = \
|
||||
os.path.join(fse(os.environ['appdata']), 'Gajim')
|
||||
os.path.join(os.environ['appdata'], 'Gajim')
|
||||
except KeyError:
|
||||
# win9x, in cwd
|
||||
self.config_root = self.cache_root = self.data_root = '.'
|
||||
|
@ -97,6 +97,13 @@ class ConfigPaths:
|
|||
base = expand('~/.local/share')
|
||||
self.data_root = os.path.join(base, 'gajim')
|
||||
|
||||
basedir = os.environ.get('GAJIM_BASEDIR', defs.basedir)
|
||||
self.add('DATA', None, os.path.join(basedir, 'data'))
|
||||
self.add('GUI', None, os.path.join(basedir, 'data', 'gui'))
|
||||
self.add('ICONS', None, os.path.join(basedir, 'icons'))
|
||||
self.add('HOME', None, os.path.expanduser('~'))
|
||||
self.add('PLUGINS_BASE', None, os.path.join(basedir, 'plugins'))
|
||||
|
||||
def add(self, name, type_, path):
|
||||
self.paths[name] = (type_, path)
|
||||
|
||||
|
@ -125,12 +132,12 @@ class ConfigPaths:
|
|||
self.config_root = self.cache_root = self.data_root = root
|
||||
|
||||
self.init_profile(profile)
|
||||
|
||||
|
||||
if len(profile) > 0 and profile_separation:
|
||||
profile = u'.' + profile
|
||||
else:
|
||||
profile = ''
|
||||
|
||||
|
||||
d = {'LOG_DB': 'logs.db', 'MY_CACERTS': 'cacerts.pem',
|
||||
'MY_EMOTS': 'emoticons', 'MY_ICONSETS': 'iconsets',
|
||||
'MY_MOOD_ICONSETS': 'moods', 'MY_ACTIVITY_ICONSETS': 'activities',
|
||||
|
@ -159,24 +166,12 @@ class ConfigPaths:
|
|||
else:
|
||||
self.add('MY_CONFIG', TYPE_CONFIG, '')
|
||||
|
||||
basedir = fse(os.environ.get('GAJIM_BASEDIR', defs.basedir))
|
||||
self.add('DATA', None, os.path.join(basedir, windowsify('data')))
|
||||
self.add('ICONS', None, os.path.join(basedir, windowsify('icons')))
|
||||
self.add('HOME', None, fse(os.path.expanduser('~')))
|
||||
self.add('PLUGINS_BASE', None, os.path.join(basedir,
|
||||
windowsify('plugins')))
|
||||
try:
|
||||
self.add('TMP', None, fse(tempfile.gettempdir()))
|
||||
self.add('TMP', None, tempfile.gettempdir())
|
||||
except IOError as e:
|
||||
print('Error opening tmp folder: %s\nUsing %s' % (str(e),
|
||||
os.path.expanduser('~')), file=sys.stderr)
|
||||
self.add('TMP', None, fse(os.path.expanduser('~')))
|
||||
|
||||
try:
|
||||
import svn_config
|
||||
svn_config.configure(self)
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
self.add('TMP', None, os.path.expanduser('~'))
|
||||
|
||||
def init_profile(self, profile):
|
||||
conffile = windowsify('config')
|
||||
|
|
Loading…
Reference in New Issue