def format_grant(grant):
    """ Convert a dict describing mysql grants into a GRANT command

    Args:
    grant - dict with keys string privileges, username, source_host, password
            and a bool grant_option

    Returns:
    sql - A GRANT command in string format
    """
    if grant['grant_option']:
        grant_option = ' WITH GRANT OPTION'
    else:
        grant_option = ''
    sql_format = "GRANT {privs} ON *.* TO `{user}`@`{host}` " + \
                 "IDENTIFIED BY '{password}' {grant_option};"
    sql = sql_format.format(
        privs=grant['privileges'],
        user=grant['username'],
        host=grant['source_host'],
        password=grant['password'],
        grant_option=grant_option)
    return sql