def coalesce_option_value(value, value_type, label=None):
 value_type = value_type.lower()
 try:
  if (value_type in ('string', 'str')):
   return_value = str(value)
  elif (value_type == 'list'):
   if isinstance(value, compat.string_type):
    return_value = value.split(',')
   else:
    return_value = list(value)
  elif (value_type == 'float'):
   return_value = float(value)
  elif (value_type in ['integer', 'int']):
   return_value = int(value)
  elif (value_type in ['bool', 'boolean']):
   if (not value):
    return_value = False
   elif isinstance(value, compat.string_type):
    return_value = (value.lower() in ['1', 'true', 'yes', 'on'])
   else:
    return_value = bool(value)
  else:
   raise ArgumentError(('Unknown option value type %s' % value_type))
 except ValueError:
  if label:
   label = ('parameter %s ' % label)
  else:
   label = ''
  raise ArgumentError(("Unable to convert %svalue '%s' into type %s" % (label, astring, value_type)))
 return return_value

def coalesce_option_value ( value , value_type , label = None ) : value_type = value_type . lower ( ) try : if ( value_type in ( 'string' , 'str' ) ) : return_value = str ( value ) elif ( value_type == 'list' ) : if isinstance ( value , compat . string_type ) : return_value = value . split ( ',' ) else : return_value = list ( value ) elif ( value_type == 'float' ) : return_value = float ( value ) elif ( value_type in [ 'integer' , 'int' ] ) : return_value = int ( value ) elif ( value_type in [ 'bool' , 'boolean' ] ) : if ( not value ) : return_value = False elif isinstance ( value , compat . string_type ) : return_value = ( value . lower ( ) in [ '1' , 'true' , 'yes' , 'on' ] ) else : return_value = bool ( value ) else : raise ArgumentError ( ( 'Unknown option value type %s' % value_type ) ) except ValueError : if label : label = ( 'parameter %s ' % label ) else : label = '' raise ArgumentError ( ( "Unable to convert %svalue '%s' into type %s" % ( label , astring , value_type ) ) ) return return_value
convert string into an object value of value_type .