def parse_directive_value(name, value, relaxed_bool=False):
 type = directive_types.get(name)
 if (not type):
  return None
 orig_value = value
 if (type is bool):
  value = str(value)
  if (value == 'True'):
   return True
  if (value == 'False'):
   return False
  if relaxed_bool:
   value = value.lower()
   if (value in ('true', 'yes')):
    return True
   elif (value in ('false', 'no')):
    return False
  raise ValueError(("%s directive must be set to True or False, got '%s'" % (name, orig_value)))
 elif (type is int):
  try:
   return int(value)
  except ValueError:
   raise ValueError(("%s directive must be set to an integer, got '%s'" % (name, orig_value)))
 elif (type is str):
  return str(value)
 elif callable(type):
  return type(name, value)
 else:
  assert False

def parse_directive_value ( name , value , relaxed_bool = False ) : type = directive_types . get ( name ) if ( not type ) : return None orig_value = value if ( type is bool ) : value = str ( value ) if ( value == 'True' ) : return True if ( value == 'False' ) : return False if relaxed_bool : value = value . lower ( ) if ( value in ( 'true' , 'yes' ) ) : return True elif ( value in ( 'false' , 'no' ) ) : return False raise ValueError ( ( "%s directive must be set to True or False, got '%s'" % ( name , orig_value ) ) ) elif ( type is int ) : try : return int ( value ) except ValueError : raise ValueError ( ( "%s directive must be set to an integer, got '%s'" % ( name , orig_value ) ) ) elif ( type is str ) : return str ( value ) elif callable ( type ) : return type ( name , value ) else : assert False
parses value as an option value for the given name and returns the interpreted value .