stacker/blueprints/base.py
def validate_variable_type(var_name, var_type, value):
    """Ensures the value is the correct variable type.

    Args:
        var_name (str): The name of the defined variable on a blueprint.
        var_type (type): The type that the value should be.
        value (obj): The object representing the value provided for the
            variable

    Returns:
        object: Returns the appropriate value object. If the original value
            was of CFNType, the returned value will be wrapped in CFNParameter.

    Raises:
        ValueError: If the `value` isn't of `var_type` and can't be cast as
            that type, this is raised.
    """

    if isinstance(var_type, CFNType):
        value = CFNParameter(name=var_name, value=value)
    elif isinstance(var_type, TroposphereType):
        try:
            value = var_type.create(value)
        except Exception as exc:
            name = "{}.create".format(var_type.resource_name)
            raise ValidatorError(var_name, name, value, exc)
    else:
        if not isinstance(value, var_type):
            raise ValueError(
                "Value for variable %s must be of type %s. Actual "
                "type: %s." % (var_name, var_type, type(value))
            )

    return value
Ensures the value is the correct variable type.

    Args:
        var_name (str): The name of the defined variable on a blueprint.
        var_type (type): The type that the value should be.
        value (obj): The object representing the value provided for the
            variable

    Returns:
        object: Returns the appropriate value object. If the original value
            was of CFNType, the returned value will be wrapped in CFNParameter.

    Raises:
        ValueError: If the `value` isn't of `var_type` and can't be cast as
            that type, this is raised.
    
Ensures the value is the correct variable type.
Ensures the value is the correct variable type .
def validate_variable_type(var_name, var_type, value):
    if isinstance(var_type, CFNType):
        value = CFNParameter(name=var_name, value=value)
    elif isinstance(var_type, TroposphereType):
        try:
            value = var_type.create(value)
        except Exception as exc:
            name = "{}.create".format(var_type.resource_name)
            raise ValidatorError(var_name, name, value, exc)
    else:
        if not isinstance(value, var_type):
            raise ValueError(
                "Value for variable %s must be of type %s. Actual "
                "type: %s." % (var_name, var_type, type(value))
            )
    return value
def validate_variable_type ( var_name , var_type , value ) : if isinstance ( var_type , CFNType ) : value = CFNParameter ( name = var_name , value = value ) elif isinstance ( var_type , TroposphereType ) : try : value = var_type . create ( value ) except Exception as exc : name = "{}.create" . format ( var_type . resource_name ) raise ValidatorError ( var_name , name , value , exc ) else : if not isinstance ( value , var_type ) : raise ValueError ( "Value for variable %s must be of type %s. Actual " "type: %s." % ( var_name , var_type , type ( value ) ) ) return value
Ensures the value is the correct variable type.
Ensures the value is the correct variable type .
"""Ensures the value is the correct variable type.

    Args:
        var_name (str): The name of the defined variable on a blueprint.
        var_type (type): The type that the value should be.
        value (obj): The object representing the value provided for the
            variable

    Returns:
        object: Returns the appropriate value object. If the original value
            was of CFNType, the returned value will be wrapped in CFNParameter.

    Raises:
        ValueError: If the `value` isn't of `var_type` and can't be cast as
            that type, this is raised.
    """
Returns the appropriate value object. If the original value
was of CFNType, the returned value will be wrapped in CFNParameter.
Returns the appropriate value object . If the original value was of CFNType the returned value will be wrapped in CFNParameter .
object
If the `value` isn't of `var_type` and can't be cast as
that type, this is raised.
If the ` value ` isn ' t of ` var_type ` and can ' t be cast as that type this is raised .
ValueError
var_name
The name of the defined variable on a blueprint.
The name of the defined variable on a blueprint .
var_type
The type that the value should be.
The type that the value should be .
value
The object representing the value provided for the
variable
The object representing the value provided for the variable