Check whether the ID is valid.

    First check if the ID is missing, and then check if it is a qualified
    string type, finally check if the string is empty. For all checks, it
    would raise a ParseError with the corresponding message.

    Args:
        entity: a string type object to be checked.
        entity_type: a string that shows the type of entities to check, usually
            `Compound` or 'Reaction'.

def _check_id(entity, entity_type):
    """Check whether the ID is valid.

    First check if the ID is missing, and then check if it is a qualified
    string type, finally check if the string is empty. For all checks, it
    would raise a ParseError with the corresponding message.

    Args:
        entity: a string type object to be checked.
        entity_type: a string that shows the type of entities to check, usually
            `Compound` or 'Reaction'.
    """

    if entity is None:
        raise ParseError('{} ID missing'.format(entity_type))
    elif not isinstance(entity, string_types):
        msg = '{} ID must be a string, id was {}.'.format(entity_type, entity)
        if isinstance(entity, bool):
            msg += (' You may have accidentally used an ID value that YAML'
                    ' interprets as a boolean, such as "yes", "no", "on",'
                    ' "off", "true" or "false". To use this ID, you have to'
                    ' quote it with single or double quotes')
        raise ParseError(msg)
    elif len(entity) == 0:
        raise ParseError('{} ID must not be empty'.format(entity_type))