OAuth config file improvements

This commit is contained in:
Théo Piboubès
2015-08-31 20:37:02 +02:00
parent 3fb4dc66bb
commit 314d2dbf26
2 changed files with 10 additions and 19 deletions

View File

@@ -64,16 +64,12 @@ def load_oauth_config():
XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME',
os.path.join(HOME, '.config')) os.path.join(HOME, '.config'))
config_paths = [ if os.path.exists(os.path.join(XDG_CONFIG_HOME, 'rtv')):
os.path.join(XDG_CONFIG_HOME, 'rtv', 'oauth.cfg'), config_path = os.path.join(XDG_CONFIG_HOME, 'rtv', 'oauth.cfg')
os.path.join(HOME, '.rtv-oauth') else:
] config_path = os.path.join(HOME, '.rtv-oauth')
# get the first existing config file config.read(config_path)
for config_path in config_paths:
if os.path.exists(config_path):
config.read(config_path)
break
if config.has_section('oauth'): if config.has_section('oauth'):
defaults = dict(config.items('oauth')) defaults = dict(config.items('oauth'))

View File

@@ -76,17 +76,12 @@ class OAuthTool(object):
XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME',
os.path.join(HOME, '.config')) os.path.join(HOME, '.config'))
config_paths = [ if os.path.exists(os.path.join(XDG_CONFIG_HOME, 'rtv')):
os.path.join(XDG_CONFIG_HOME, 'rtv', 'oauth.cfg'), file_path = os.path.join(XDG_CONFIG_HOME, 'rtv', 'oauth.cfg')
os.path.join(HOME, '.rtv-oauth') else:
] file_path = os.path.join(HOME, '.rtv-oauth')
# get the first existing config file return file_path
for config_path in config_paths:
if os.path.exists(config_path):
break
return config_path
def open_config(self, update=False): def open_config(self, update=False):
if self.config_fp is None: if self.config_fp is None: