#NEWLINE# def get_user_grants( self , username , login_from = '%' ) : #NEWLINE# #INDENT# "\n        Returns all grants for the given user at the given location.\n\n        :param username: Name of the user to be verify.\n        :type username: :class:`str`\n        :param login_from: Locations that this user can login from. Defaults to '%' (anywhere).\n        :type login_from: :class:`str`\n        :return: The user grants.\n        :rtype: :class:`list`\n\n        Example:\n        ::\n\n            class MySampleRole(Role):\n                def provision(self):\n                    with self.using(MySQLRole) as role:\n                        if role.get_user_grants('user', login_from='%'):\n                            pass\n        " #NEWLINE# grants = self . __execute_query ( ( "SHOW GRANTS FOR '%s'@'%s';" % ( username , login_from ) ) ) #NEWLINE# only_grants = [ ] #NEWLINE# for grant in grants : #NEWLINE# #INDENT# filtered_grants = filter ( ( lambda x : x . startswith ( 'GRANT ' ) ) , grant . itervalues ( ) ) #NEWLINE# only_grants . extend ( filtered_grants ) #NEWLINE# #UNINDENT# return only_grants