From 9c61d9951e000a22d0fb6c782a98c33ab32488ed Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Fri, 15 May 2020 17:10:21 +0530 Subject: [PATCH] Config dir must exist before creating config file --- .travis.yml | 2 -- setup.py | 2 -- spotdl/__init__.py | 1 - spotdl/config.py | 29 +++++++++++++++-------------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9418449..9471ef0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: python python: - - "3.4" - - "3.5" - "3.6" - "3.7" - "3.8" diff --git a/setup.py b/setup.py index 58649c8..917b20a 100644 --- a/setup.py +++ b/setup.py @@ -64,8 +64,6 @@ setup( "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", diff --git a/spotdl/__init__.py b/spotdl/__init__.py index 1cac6f3..0902f3e 100644 --- a/spotdl/__init__.py +++ b/spotdl/__init__.py @@ -2,5 +2,4 @@ from spotdl.command_line.__main__ import main from spotdl.version import __version__ from spotdl.command_line.lib import Spotdl -from spotdl.track import Track diff --git a/spotdl/config.py b/spotdl/config.py index 8d5871d..a434dd8 100644 --- a/spotdl/config.py +++ b/spotdl/config.py @@ -54,21 +54,22 @@ def dump_config(config_file, config=DEFAULT_CONFIGURATION): def get_config(config_file): if os.path.isfile(config_file): config = read_config(config_file) - else: - config = DEFAULT_CONFIGURATION - dump_config(config_file, config=DEFAULT_CONFIGURATION) + return config - logger.info("Writing default configuration to {0}.".format(config_file)) + config_dir = os.path.dirname(config_file) + os.makedirs(config_dir, exist_ok=True) + dump_config(config_file, config=DEFAULT_CONFIGURATION) - for line in yaml.dump( - DEFAULT_CONFIGURATION["spotify-downloader"], default_flow_style=False - ).split("\n"): - if line.strip(): - logger.info(line.strip()) - logger.info( - "Please note that command line arguments have higher priority " - "than their equivalents in the configuration file." - ) + logger.info("Writing default configuration to {0}.".format(config_file)) - return config + for line in yaml.dump( + DEFAULT_CONFIGURATION["spotify-downloader"], default_flow_style=False + ).split("\n"): + if line.strip(): + logger.info(line.strip()) + logger.info( + "Please note that command line arguments have higher priority " + "than their equivalents in the configuration file." + ) + return DEFAULT_CONFIGURATION