Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _parse_directory(self):
"""
Parse the storage directory in the config.
Returns:
str
"""
if self._parser.has_option("storage", "directory"):
directory = self._parser.get("storage", "directory")
# Don't allow CUSTOM_APPS_DIR as a storage directory
if directory == CUSTOM_APPS_DIR:
raise ConfigError(
"{} cannot be used as a storage directory.".format(CUSTOM_APPS_DIR)
)
else:
directory = MACKUP_BACKUP_PATH
return str(directory)
"""
Return the application configuration files.
Return a list of configuration files describing the apps supported by
Mackup. The files returned are absolute full path to those files.
e.g. /usr/lib/mackup/applications/bash.cfg
Only one config file per application should be returned, custom config
having a priority over stock config.
Returns:
set of strings.
"""
# Configure the config parser
apps_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), APPS_DIR)
custom_apps_dir = os.path.join(os.environ["HOME"], CUSTOM_APPS_DIR)
# List of stock application config files
config_files = set()
# Temp list of user added app config file names
custom_files = set()
# Get the list of custom application config files first
if os.path.isdir(custom_apps_dir):
for filename in os.listdir(custom_apps_dir):
if filename.endswith(".cfg"):
config_files.add(os.path.join(custom_apps_dir, filename))
# Also add it to the set of custom apps, so that we don't
# add the stock config for the same app too
custom_files.add(filename)
def _parse_directory(self):
"""
Parse the storage directory in the config.
Returns:
str
"""
if self._parser.has_option("storage", "directory"):
directory = self._parser.get("storage", "directory")
# Don't allow CUSTOM_APPS_DIR as a storage directory
if directory == CUSTOM_APPS_DIR:
raise ConfigError(
"{} cannot be used as a storage directory.".format(CUSTOM_APPS_DIR)
)
else:
directory = MACKUP_BACKUP_PATH
return str(directory)