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()
This commit is contained in:
parent
5af42e4707
commit
52657e7f18
|
@ -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,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')
|
||||
|
|
Loading…
Reference in New Issue