[BUGFIX] Only apply --dl-override to subscriptions in --match (#890)
As title, to not accidently add breaking changes for subscriptions that are not going to run
This commit is contained in:
parent
3b36ffd050
commit
305d084a6d
2 changed files with 21 additions and 12 deletions
|
|
@ -107,15 +107,10 @@ def _download_subscriptions_from_yaml_files(
|
|||
subscriptions += Subscription.from_file_path(
|
||||
config=config,
|
||||
subscription_path=path,
|
||||
subscription_matches=subscription_matches,
|
||||
subscription_override_dict=subscription_override_dict,
|
||||
)
|
||||
|
||||
if subscriptions and subscription_matches:
|
||||
logger.info("Filtering subscriptions by name based on --match arguments")
|
||||
subscriptions = [
|
||||
sub for sub in subscriptions if any(match in sub.name for match in subscription_matches)
|
||||
]
|
||||
|
||||
for subscription in subscriptions:
|
||||
with subscription.exception_handling():
|
||||
logger.info(
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ class Subscription(SubscriptionDownload):
|
|||
cls,
|
||||
config: ConfigFile,
|
||||
subscription_path: str | Path,
|
||||
subscription_matches: Optional[List[str]] = None,
|
||||
subscription_override_dict: Optional[Dict] = None,
|
||||
) -> List["Subscription"]:
|
||||
"""
|
||||
|
|
@ -86,6 +87,8 @@ class Subscription(SubscriptionDownload):
|
|||
Validated instance of the config
|
||||
subscription_path:
|
||||
File path to the subscription yaml file
|
||||
subscription_matches:
|
||||
Optional list, only output subscriptions that match one or more of these values
|
||||
subscription_override_dict:
|
||||
Optional dict containing overrides to every subscription
|
||||
|
||||
|
|
@ -99,16 +102,16 @@ class Subscription(SubscriptionDownload):
|
|||
If subscription file is misconfigured
|
||||
"""
|
||||
subscriptions: List["Subscription"] = []
|
||||
subscription_dict = load_yaml(file_path=subscription_path)
|
||||
subscription_object = load_yaml(file_path=subscription_path)
|
||||
|
||||
has_file_preset = FILE_PRESET_APPLY_KEY in subscription_dict
|
||||
has_file_preset = FILE_PRESET_APPLY_KEY in subscription_object
|
||||
|
||||
# If a file preset is present...
|
||||
if has_file_preset:
|
||||
# Validate it (make sure it is a dict)
|
||||
file_preset = LiteralDictValidator(
|
||||
name=f"{subscription_path}.{FILE_PRESET_APPLY_KEY}",
|
||||
value=subscription_dict[FILE_PRESET_APPLY_KEY],
|
||||
value=subscription_object[FILE_PRESET_APPLY_KEY],
|
||||
)
|
||||
|
||||
# Deep copy the config and add this file preset to its preset list
|
||||
|
|
@ -116,7 +119,9 @@ class Subscription(SubscriptionDownload):
|
|||
config.presets.dict[FILE_PRESET_APPLY_KEY] = file_preset.dict
|
||||
|
||||
subscriptions_dict: Dict[str, Any] = {
|
||||
key: obj for key, obj in subscription_dict.items() if key not in [FILE_PRESET_APPLY_KEY]
|
||||
key: obj
|
||||
for key, obj in subscription_object.items()
|
||||
if key not in [FILE_PRESET_APPLY_KEY]
|
||||
}
|
||||
|
||||
subscriptions_dicts = SubscriptionValidator(
|
||||
|
|
@ -129,7 +134,16 @@ class Subscription(SubscriptionDownload):
|
|||
global_presets_to_apply=[FILE_PRESET_APPLY_KEY] if has_file_preset else []
|
||||
)
|
||||
|
||||
for subscription_key, subscription_object in subscriptions_dicts.items():
|
||||
if subscriptions_dicts and subscription_matches:
|
||||
logger.info("Filtering subscriptions by name based on --match arguments")
|
||||
subscriptions_dicts = {
|
||||
subscription_name: subscription_object
|
||||
for subscription_name, subscription_object in subscriptions_dicts.items()
|
||||
if any(match in subscription_name for match in subscription_matches)
|
||||
}
|
||||
|
||||
for subscription_name, subscription_object in subscriptions_dicts.items():
|
||||
|
||||
# Hard-override subscriptions here
|
||||
mergedeep.merge(
|
||||
subscription_object,
|
||||
|
|
@ -140,7 +154,7 @@ class Subscription(SubscriptionDownload):
|
|||
subscriptions.append(
|
||||
cls.from_dict(
|
||||
config=config,
|
||||
preset_name=subscription_key,
|
||||
preset_name=subscription_name,
|
||||
preset_dict=subscription_object,
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue