Fix error with Sonarr profiles without tags

If a tag was not specified in the YAML configuration, an exception would
occur. Logic has been added to properly check for (and allow) empty tags
elements.
pull/5/head
Robert Dailey 3 years ago
parent 93ffbdbbc1
commit 2485a587b0

@ -25,6 +25,14 @@ def load_config(args, logger, default_load_path: Path):
else:
logger.debug('Config file could not be loaded because it does not exist')
# --------------------------------------------------------------------------------------------------
def _config_has_tags(profile):
if profile is None or 'tags' not in profile:
return False;
tags = profile['tags']
return tags is not None and len(tags) > 0
# --------------------------------------------------------------------------------------------------
def load_config_string(args, logger, config_yaml):
config = yaml.load(config_yaml, Loader=yaml.Loader)
@ -42,7 +50,7 @@ def load_config_string(args, logger, config_yaml):
if args.subcommand == 'profile':
profile = find_profile_by_name(server_config, type_name)
if profile:
if _config_has_tags(profile):
if args.tags is None:
args.tags = []
args.tags.extend(t for t in profile['tags'] if t not in args.tags)

Loading…
Cancel
Save