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

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
extracts and returns expected value by a given type .