def __grant_generate(grant, database, user, host='localhost', grant_option=False, escape=True, ssl_option=False):
 grant = re.sub('\\s*,\\s*', ', ', grant).upper()
 grant = __grant_normalize(grant)
 db_part = database.rpartition('.')
 dbc = db_part[0]
 table = db_part[2]
 if escape:
  if (dbc is not '*'):
   dbc = quote_identifier(dbc, for_grants=(table is '*'))
  if (table is not '*'):
   table = quote_identifier(table)
 qry = 'GRANT {0} ON {1}.{2} TO %(user)s@%(host)s'.format(grant, dbc, table)
 args = {}
 args['user'] = user
 args['host'] = host
 if (isinstance(ssl_option, list) and len(ssl_option)):
  qry += __ssl_option_sanitize(ssl_option)
 if salt.utils.is_true(grant_option):
  qry += ' WITH GRANT OPTION'
 log.debug('Grant Query generated: {0} args {1}'.format(qry, repr(args)))
 return {'qry': qry, 'args': args}

def __grant_generate ( grant , database , user , host = 'localhost' , grant_option = False , escape = True , ssl_option = False ) : grant = re . sub ( '\\s*,\\s*' , ', ' , grant ) . upper ( ) grant = __grant_normalize ( grant ) db_part = database . rpartition ( '.' ) dbc = db_part [ 0 ] table = db_part [ 2 ] if escape : if ( dbc is not '*' ) : dbc = quote_identifier ( dbc , for_grants = ( table is '*' ) ) if ( table is not '*' ) : table = quote_identifier ( table ) qry = 'GRANT {0} ON {1}.{2} TO %(user)s@%(host)s' . format ( grant , dbc , table ) args = { } args [ 'user' ] = user args [ 'host' ] = host if ( isinstance ( ssl_option , list ) and len ( ssl_option ) ) : qry += __ssl_option_sanitize ( ssl_option ) if salt . utils . is_true ( grant_option ) : qry += ' WITH GRANT OPTION' log . debug ( 'Grant Query generated: {0} args {1}' . format ( qry , repr ( args ) ) ) return { 'qry' : qry , 'args' : args }
validate grants and build the query that could set the given grants note that this query contains arguments for user and host but not for grants or database .