Philipp Hörist pushed to branch master at gajim / gajim
Commits: c4e41d69 by Philipp Hörist at 2017-01-06T20:01:13+01:00 Make some paths available before profile init
- - - - - 5af42e47 by Philipp Hörist at 2017-01-06T20:01:14+01:00 Remove old svn code
- - - - - 52657e7f by Philipp Hörist at 2017-01-06T20:03:43+01:00 Remove unicode conversion method for paths
its not needed in python3 - tempfile.gettempdir() returns always unicode - os.environ.get() returns always unicode
we get what we put into: - os.path.expanduser()
- - - - - 8079930d by Philipp Hörist at 2017-01-06T20:04:22+01:00 Add get() function to configpaths
- - - - - 6d26553b by Philipp Hörist at 2017-01-06T20:04:23+01:00 Dont windowsify non-config directorys
- - - - - 8c01d4d4 by Philipp Hörist at 2017-01-06T20:04:23+01:00 Add GUI folder to configpaths
- - - - - e967d4ed by Philipp Hörist at 2017-01-07T19:36:13+01:00 Merge branch 'dev' into 'master'
Improvements for Configpaths
See merge request !22 - - - - -
2 changed files:
- src/common/check_paths.py - src/common/configpaths.py
Changes:
===================================== src/common/check_paths.py ===================================== --- a/src/common/check_paths.py +++ b/src/common/check_paths.py @@ -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:
===================================== src/common/configpaths.py ===================================== --- a/src/common/configpaths.py +++ b/src/common/configpaths.py @@ -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')
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/996bb2abca9844d54f1d33141a727c8e7f...