1
# ubuntuone.oauthdesktop.config - Configuration for OAuthDesktop
3
# Author: Stuart Langridge <stuart.langridge@canonical.com>
5
# Copyright 2009 Canonical Ltd.
7
# This program is free software: you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License version 3, as published
9
# by the Free Software Foundation.
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranties of
13
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
# PURPOSE. See the GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License along
17
# with this program. If not, see <http://www.gnu.org/licenses/>.
18
"Find the config file for ubuntuone-oauth-config"
19
import os, ConfigParser
20
from xdg.BaseDirectory import load_first_config
22
def get_config(use_tmpconfig=True):
23
"""Return a ConfigParser object from a config file.
24
Config file is looked for in the source tree first and then in the
25
FreeDesktop BaseDirectory folders.
27
# if tmpconfig exists, then we are running out of the source tree
28
tmpconfig = os.path.realpath(os.path.join(
29
__file__, "../../../data/oauth_urls"
31
if os.path.isfile(tmpconfig) and use_tmpconfig:
32
config_file = tmpconfig
34
config_file = load_first_config('ubuntuone','oauth_urls')
36
cfp = ConfigParser.ConfigParser()
38
if config_file is not None:
41
cfp.FILENAME = config_file
42
except ConfigParser.Error:
43
cfp = ConfigParser.ConfigParser()