(value, expected)
return value
Extracts and returns expected value by a given type

    >>> extractExpectedValue(['1'], EXPECTED.BOOL)
    True
    >>> extractExpectedValue('1', EXPECTED.INT)
    1
Extracts and returns expected value by a given type
Extracts and returns expected value by a given type
def extractExpectedValue(value, expected):
    """
    Extracts and returns expected value by a given type

    >>> extractExpectedValue(['1'], EXPECTED.BOOL)
    True
    >>> extractExpectedValue('1', EXPECTED.INT)
    1
    """

    if expected:
        value = unArrayizeValue(value)

        if isNoneValue(value):
            value = None
        elif expected == EXPECTED.BOOL:
            if isinstance(value, int):
                value = bool(value)
            elif isinstance(value, basestring):
                value = value.strip().lower()
                if value in ("true", "false"):
                    value = value == "true"
                elif value in ("1", "-1"):
                    value = True
                elif value == "0":
                    value = False
                else:
                    value = None
        elif expected == EXPECTED.INT:
            if isinstance(value, basestring):
                value = int(value) if value.isdigit() else None

    return value
def extractExpectedValue ( value , expected ) : if expected : value = unArrayizeValue ( value ) if isNoneValue ( value ) : value = None elif expected == EXPECTED . BOOL : if isinstance ( value , int ) : value = bool ( value ) elif isinstance ( value , basestring ) : value = value . strip ( ) . lower ( ) if value in ( "true" , "false" ) : value = value == "true" elif value in ( "1" , "-1" ) : value = True elif value == "0" : value = False else : value = None elif expected == EXPECTED . INT : if isinstance ( value , basestring ) : value = int ( value ) if value . isdigit ( ) else None return value