1
# -*- coding: utf-8 -*-
3
# Copyright 2012 Canonical Ltd.
5
# This program is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 3, as published
7
# by the Free Software Foundation.
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License along
15
# with this program. If not, see <http://www.gnu.org/licenses/>.
17
"""Miscelaneous functions and constants for linux."""
22
from dirspec.basedir import xdg_config_home
23
from ubuntuone.controlpanel.logger import setup_logging
26
logger = setup_logging('utils.linux')
29
def default_folders(user_home='', dirs_path=None):
30
"""Return a list of the folders to add by default."""
34
dirs_path = os.path.join(xdg_config_home, u'user-dirs.dirs')
36
if not os.path.exists(dirs_path):
37
logger.warning('default_folders: dirs_path %r does not exist.',
41
# pylint: disable=W0702
44
with codecs.open(dirs_path, encoding='utf-8') as f:
46
if line.startswith(u'#'):
50
_, value = line.strip().split(u'=')
51
value = value.strip(u'"').replace(u'$HOME', user_home)
53
logger.exception('default_folders: can not row %r:', line)
57
logger.exception('default_folders: can not load file %r:', dirs_path)