feat: Make startup scripts idempotent

This commit is contained in:
kr3ator 2022-04-05 08:34:08 +02:00
parent a6eb4fef00
commit 9be7b0e109
42 changed files with 275 additions and 95 deletions

View file

@ -0,0 +1,15 @@
from typing import Tuple
def split_params(params: dict, unique_params: list = None) -> Tuple[dict, dict]:
"""Split params dict into dict with matching params and a dict with default values"""
if unique_params is None:
unique_params = ["name", "slug"]
matching_params = {}
for unique_param in unique_params:
param = params.pop(unique_param, None)
if param:
matching_params[unique_param] = param
return matching_params, params