diff options
author | Philipp Hörist <forenjunkie@chello.at> | 2017-01-06 20:08:52 +0300 |
---|---|---|
committer | Philipp Hörist <forenjunkie@chello.at> | 2017-01-06 22:03:43 +0300 |
commit | 52657e7f1895a777c589bad49c0961a4468a3e73 (patch) | |
tree | 6364a2e66a2658fbdefdf2d2acc474d8ba1b262f | |
parent | 5af42e470775d8b6516fa80414fd1deedc5e5449 (diff) |
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()
-rw-r--r-- | src/common/check_paths.py | 7 | ||||
-rw-r--r-- | src/common/configpaths.py | 16 |
2 files changed, 8 insertions, 15 deletions
diff --git a/src/common/check_paths.py b/src/common/check_paths.py index 5e92c324a..71dcf2f4d 100644 --- 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: diff --git a/src/common/configpaths.py b/src/common/configpaths.py index 6a998b979..29f1b0fa5 100644 --- a/src/common/configpaths.py +++ b/src/common/configpaths.py @@ -52,17 +52,13 @@ 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 + class ConfigPaths: def __init__(self): # {'name': (type, path), } type can be TYPE_CONFIG, TYPE_CACHE, TYPE_DATA @@ -77,7 +73,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,10 +93,10 @@ class ConfigPaths: base = expand('~/.local/share') self.data_root = os.path.join(base, 'gajim') - basedir = fse(os.environ.get('GAJIM_BASEDIR', defs.basedir)) + basedir = 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('HOME', None, os.path.expanduser('~')) self.add('PLUGINS_BASE', None, os.path.join(basedir, windowsify('plugins'))) @@ -167,11 +163,11 @@ class ConfigPaths: self.add('MY_CONFIG', TYPE_CONFIG, '') 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('~'))) + self.add('TMP', None, os.path.expanduser('~')) def init_profile(self, profile): conffile = windowsify('config') |