Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def retDefault(keyword):
"""Return the DEFAULT value of keyword."""
if keyword == 'QUALITY':
return DEFAULTS().SONG_QUALITY
elif keyword == 'SONG_DIR':
return DEFAULTS().SONG_DIR
def make_config():
"""Copy the config file to .config folder."""
# Remove the current config from SONG_TEMP_DIR
config_path = os.path.join(DEFAULTS().CONFIG_PATH, 'config')
# Check if the ytmdl folder is present in config
if not os.path.isdir(DEFAULTS().CONFIG_PATH):
# Make the ytmdl folder
os.makedirs(DEFAULTS().CONFIG_PATH)
elif os.path.isfile(config_path):
os.remove(config_path)
# Check if the ytmdl folder is present in Music directory
if not os.path.isdir(DEFAULTS().SONG_TEMP_DIR):
# Make the ytmdl folder
os.makedirs(DEFAULTS().SONG_TEMP_DIR)
# Now write the config text to config file
"""Copy the config file to .config folder."""
# Remove the current config from SONG_TEMP_DIR
config_path = os.path.join(DEFAULTS().CONFIG_PATH, 'config')
# Check if the ytmdl folder is present in config
if not os.path.isdir(DEFAULTS().CONFIG_PATH):
# Make the ytmdl folder
os.makedirs(DEFAULTS().CONFIG_PATH)
elif os.path.isfile(config_path):
os.remove(config_path)
# Check if the ytmdl folder is present in Music directory
if not os.path.isdir(DEFAULTS().SONG_TEMP_DIR):
# Make the ytmdl folder
os.makedirs(DEFAULTS().SONG_TEMP_DIR)
# Now write the config text to config file
with open(config_path, 'w') as write_config:
write_config.write(config_text)
def checkConfig():
"""Need to check the config to see if defaults are changed.
The config will be saved in the .config folder.
"""
# Try to see if the config is present in the SONG_TEMP_DIR
if os.path.isdir(DEFAULTS().CONFIG_PATH):
DIR_CONTENTS = os.listdir(DEFAULTS().CONFIG_PATH)
else:
return False
if 'config' not in DIR_CONTENTS:
make_config()
return True
else:
return True
def retDefault(keyword):
"""Return the DEFAULT value of keyword."""
if keyword == 'QUALITY':
return DEFAULTS().SONG_QUALITY
elif keyword == 'SONG_DIR':
return DEFAULTS().SONG_DIR
def checkConfig():
"""Need to check the config to see if defaults are changed.
The config will be saved in the .config folder.
"""
# Try to see if the config is present in the SONG_TEMP_DIR
if os.path.isdir(DEFAULTS().CONFIG_PATH):
DIR_CONTENTS = os.listdir(DEFAULTS().CONFIG_PATH)
else:
return False
if 'config' not in DIR_CONTENTS:
make_config()
return True
else:
return True
def make_config():
"""Copy the config file to .config folder."""
# Remove the current config from SONG_TEMP_DIR
config_path = os.path.join(DEFAULTS().CONFIG_PATH, 'config')
# Check if the ytmdl folder is present in config
if not os.path.isdir(DEFAULTS().CONFIG_PATH):
# Make the ytmdl folder
os.makedirs(DEFAULTS().CONFIG_PATH)
elif os.path.isfile(config_path):
os.remove(config_path)
# Check if the ytmdl folder is present in Music directory
if not os.path.isdir(DEFAULTS().SONG_TEMP_DIR):
# Make the ytmdl folder
os.makedirs(DEFAULTS().SONG_TEMP_DIR)
# Now write the config text to config file
with open(config_path, 'w') as write_config:
write_config.write(config_text)
def make_config():
"""Copy the config file to .config folder."""
# Remove the current config from SONG_TEMP_DIR
config_path = os.path.join(DEFAULTS().CONFIG_PATH, 'config')
# Check if the ytmdl folder is present in config
if not os.path.isdir(DEFAULTS().CONFIG_PATH):
# Make the ytmdl folder
os.makedirs(DEFAULTS().CONFIG_PATH)
elif os.path.isfile(config_path):
os.remove(config_path)
# Check if the ytmdl folder is present in Music directory
if not os.path.isdir(DEFAULTS().SONG_TEMP_DIR):
# Make the ytmdl folder
os.makedirs(DEFAULTS().SONG_TEMP_DIR)
# Now write the config text to config file
with open(config_path, 'w') as write_config:
write_config.write(config_text)