OAuth config file improvements
This commit is contained in:
@@ -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'))
|
||||||
|
|||||||
15
rtv/oauth.py
15
rtv/oauth.py
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user