def cdk_context_decorator()

in source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/context.py [0:0]


        def cdk_context_decorator(f):
            @wraps(f)
            def wrapper(*args):
                # validate function arguments
                if len(args) > 1:
                    raise ValueError(ARGUMENT_ERROR)
                if len(args) == 1 and not isinstance(args[0], dict):
                    raise TypeError(ARGUMENT_ERROR)

                if len(args) == 0:
                    args = (context,)

                # override the CDK context as required
                if len(args) == 1:
                    context.update(args[0])

                    env_context_var = environ.get(context_var_name)
                    if env_context_var:
                        context[context_var_name] = env_context_var
                    elif context_var_name and context_var_value:
                        context[context_var_name] = context_var_value

                    if not context.get(context_var_name):
                        raise ValueError(
                            f"Missing cdk.json context variable or environment variable for {context_var_name}."
                        )

                    args = (context,)

                return f(*args)

            return wrapper