tools/json_schema_compiler/feature_compiler.py
def _GetCheckedValue(self, key, expected_type, expected_values,
                       enum_map, value):
    """Returns a string to be used in the generated C++ code for a given key's
    python value, or None if the value is invalid. For example, if the python
    value is True, this returns 'true', for a string foo, this returns "foo",
    and for an enum, this looks up the C++ definition in the enum map.
      key: The key being parsed.
      expected_type: The expected type for this value, or None if any type is
                     allowed.
      expected_values: The list of allowed values for this value, or None if any
                       value is allowed.
      enum_map: The map from python value -> cpp value for all allowed values,
               or None if no special mapping should be made.
      value: The value to check.
    """
    valid = True
    if expected_values and value not in expected_values:
      self._AddKeyError(key, 'Illegal value: "%s"' % value)
      valid = False

    t = self._GetType(value)
    if expected_type and t is not expected_type:
      self._AddKeyError(key, 'Illegal value: "%s"' % value)
      valid = False

    if not valid:
      return None

    if enum_map:
      return enum_map[value]

    if t is str:
      return '"%s"' % str(value)
    if t is int:
      return str(value)
    if t is bool:
      return 'true' if value else 'false'
    assert False, 'Unsupported type: %s' % value
Returns a string to be used in the generated C++ code for a given key's
    python value, or None if the value is invalid. For example, if the python
    value is True, this returns 'true', for a string foo, this returns "foo",
    and for an enum, this looks up the C++ definition in the enum map.
      key: The key being parsed.
      expected_type: The expected type for this value, or None if any type is
                     allowed.
      expected_values: The list of allowed values for this value, or None if any
                       value is allowed.
      enum_map: The map from python value -> cpp value for all allowed values,
               or None if no special mapping should be made.
      value: The value to check.
    
Returns a string to be used in the generated C++ code for a given key's
python value, or None if the value is invalid. For example, if the python
value is True, this returns 'true', for a string foo, this returns "foo",
and for an enum, this looks up the C++ definition in the enum map.
key: The key being parsed.
expected_type: The expected type for this value, or None if any type is
allowed.
expected_values: The list of allowed values for this value, or None if any
value is allowed.
enum_map: The map from python value -> cpp value for all allowed values,
or None if no special mapping should be made.
value: The value to check.
Returns a string to be used in the generated C ++ code for a given key ' s python value or None if the value is invalid . For example if the python value is True this returns ' true ' for a string foo this returns " foo " and for an enum this looks up the C ++ definition in the enum map . key : The key being parsed . expected_type : The expected type for this value or None if any type is allowed . expected_values : The list of allowed values for this value or None if any value is allowed . enum_map : The map from python value - > cpp value for all allowed values or None if no special mapping should be made . value : The value to check .
def _GetCheckedValue(self, key, expected_type, expected_values,
                       enum_map, value):
    valid = True
    if expected_values and value not in expected_values:
      self._AddKeyError(key, 'Illegal value: "%s"' % value)
      valid = False
    t = self._GetType(value)
    if expected_type and t is not expected_type:
      self._AddKeyError(key, 'Illegal value: "%s"' % value)
      valid = False
    if not valid:
      return None
    if enum_map:
      return enum_map[value]
    if t is str:
      return '"%s"' % str(value)
    if t is int:
      return str(value)
    if t is bool:
      return 'true' if value else 'false'
    assert False, 'Unsupported type: %s' % value
def _GetCheckedValue ( self , key , expected_type , expected_values , enum_map , value ) : valid = True if expected_values and value not in expected_values : self . _AddKeyError ( key , 'Illegal value: "%s"' % value ) valid = False t = self . _GetType ( value ) if expected_type and t is not expected_type : self . _AddKeyError ( key , 'Illegal value: "%s"' % value ) valid = False if not valid : return None if enum_map : return enum_map [ value ] if t is str : return '"%s"' % str ( value ) if t is int : return str ( value ) if t is bool : return 'true' if value else 'false' assert False , 'Unsupported type: %s' % value
Returns a string to be used in the generated C++ code for a given key's
python value, or None if the value is invalid.
Returns a string to be used in the generated C ++ code for a given key ' s python value or None if the value is invalid .
"""Returns a string to be used in the generated C++ code for a given key's
    python value, or None if the value is invalid. For example, if the python
    value is True, this returns 'true', for a string foo, this returns "foo",
    and for an enum, this looks up the C++ definition in the enum map.
      key: The key being parsed.
      expected_type: The expected type for this value, or None if any type is
                     allowed.
      expected_values: The list of allowed values for this value, or None if any
                       value is allowed.
      enum_map: The map from python value -> cpp value for all allowed values,
               or None if no special mapping should be made.
      value: The value to check.
    """
self
key
expected_type
expected_values
enum_map
value