Remove unused xdg code and make it check for absolute paths
The xdg module has never been imported due to a catchall except clause, so we can safely assume it was unused and untested.
This commit is contained in:
parent
85aa5efb12
commit
3c48d59ed5
1 changed files with 13 additions and 27 deletions
|
@ -26,11 +26,6 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
from common import defs
|
from common import defs
|
||||||
HAVE_XDG = True
|
|
||||||
try:
|
|
||||||
__import__(xdg)
|
|
||||||
except:
|
|
||||||
HAVE_XDG = False
|
|
||||||
|
|
||||||
(
|
(
|
||||||
TYPE_CONFIG,
|
TYPE_CONFIG,
|
||||||
|
@ -88,28 +83,19 @@ class ConfigPaths:
|
||||||
self.config_root = self.cache_root = self.data_root = '.'
|
self.config_root = self.cache_root = self.data_root = '.'
|
||||||
else: # Unices
|
else: # Unices
|
||||||
# Pass in an Unicode string, and hopefully get one back.
|
# Pass in an Unicode string, and hopefully get one back.
|
||||||
if HAVE_XDG:
|
expand = os.path.expanduser
|
||||||
self.config_root = xdg.BaseDirectory.load_first_config('gajim')
|
base = os.getenv('XDG_CONFIG_HOME')
|
||||||
if not self.config_root:
|
if base is None or base[0] != '/':
|
||||||
# Folder doesn't exist yet.
|
base = expand('~/.config')
|
||||||
self.config_root = os.path.join(xdg.BaseDirectory.\
|
self.config_root = os.path.join(base, 'gajim')
|
||||||
xdg_config_dirs[0], 'gajim')
|
base = os.getenv('XDG_CACHE_HOME')
|
||||||
|
if base is None or base[0] != '/':
|
||||||
self.cache_root = os.path.join(xdg.BaseDirectory.xdg_cache_home,
|
base = expand('~/.cache')
|
||||||
'gajim')
|
self.cache_root = os.path.join(base, 'gajim')
|
||||||
|
base = os.getenv('XDG_DATA_HOME')
|
||||||
self.data_root = xdg.BaseDirectory.save_data_path('gajim')
|
if base is None or base[0] != '/':
|
||||||
if not self.data_root:
|
base = expand('~/.local/share')
|
||||||
self.data_root = os.path.join(xdg.BaseDirectory.\
|
self.data_root = os.path.join(base, 'gajim')
|
||||||
xdg_data_dirs[0], 'gajim')
|
|
||||||
else:
|
|
||||||
expand = os.path.expanduser
|
|
||||||
base = os.getenv('XDG_CONFIG_HOME') or expand('~/.config')
|
|
||||||
self.config_root = os.path.join(base, 'gajim')
|
|
||||||
base = os.getenv('XDG_CACHE_HOME') or expand('~/.cache')
|
|
||||||
self.cache_root = os.path.join(base, 'gajim')
|
|
||||||
base = os.getenv('XDG_DATA_HOME') or expand('~/.local/share')
|
|
||||||
self.data_root = os.path.join(base, 'gajim')
|
|
||||||
|
|
||||||
def add(self, name, type_, path):
|
def add(self, name, type_, path):
|
||||||
self.paths[name] = (type_, path)
|
self.paths[name] = (type_, path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue