Performs a file lookup. Valid options (and their defaults) are::

        basename=False
        count=False
        existing=False
        follow=True
        ignore=False
        nofollow=False
        wholename=True
        regex=False
        database=<locate's default database>
        limit=<integer, not set by default>

    See the manpage for ``locate(1)`` for further explanation of these options.

    CLI Example:

    .. code-block:: bash

        salt '*' locate.locate

def locate(pattern, database='', limit=0, **kwargs):
    '''
    Performs a file lookup. Valid options (and their defaults) are::

        basename=False
        count=False
        existing=False
        follow=True
        ignore=False
        nofollow=False
        wholename=True
        regex=False
        database=<locate's default database>
        limit=<integer, not set by default>

    See the manpage for ``locate(1)`` for further explanation of these options.

    CLI Example:

    .. code-block:: bash

        salt '*' locate.locate
    '''
    options = ''
    toggles = {
        'basename': 'b',
        'count': 'c',
        'existing': 'e',
        'follow': 'L',
        'ignore': 'i',
        'nofollow': 'P',
        'wholename': 'w',
        }
    for option in kwargs:
        if bool(kwargs[option]) is True and option in toggles:
            options += toggles[option]
    if options:
        options = '-{0}'.format(options)
    if database:
        options += ' -d {0}'.format(database)
    if limit > 0:
        options += ' -l {0}'.format(limit)
    if 'regex' in kwargs and bool(kwargs['regex']) is True:
        options += ' --regex'
    cmd = 'locate {0} {1}'.format(options, pattern)
    out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
    return out