def file_dict(*packages, **kwargs):
    '''
    List the files that belong to a package, grouped by package. Not
    specifying any packages will return a list of _every_ file on the
    system's package database (not generally recommended).

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.file_list httpd
        salt '*' pkg.file_list httpd postfix
        salt '*' pkg.file_list
    '''
    errors = []
    files = {}

    if packages:
        match_pattern = '\'{0}-[0-9]*\''
        cmd = ['pkg_info', '-QL'] + [match_pattern.format(p) for p in packages]
    else:
        cmd = ['pkg_info', '-QLa']

    ret = __salt__['cmd.run_all'](cmd,
                                  output_loglevel='trace',
                                  python_shell=False)

    for line in ret['stderr'].splitlines():
        errors.append(line)

    pkg = None
    for line in ret['stdout'].splitlines():
        if pkg is not None and line.startswith('/'):
            files[pkg].append(line)
        elif ':/' in line:
            pkg, fn = line.split(':', 1)
            pkg, ver = pkg.rsplit('-', 1)
            files[pkg] = [fn]
        else:
            continue  # unexpected string

    return {'errors': errors, 'files': files}
def file_dict ( * packages , ** kwargs ) : errors = [ ] files = { } if packages : match_pattern = '\'{0}-[0-9]*\'' cmd = [ 'pkg_info' , '-QL' ] + [ match_pattern . format ( p ) for p in packages ] else : cmd = [ 'pkg_info' , '-QLa' ] ret = __salt__ [ 'cmd.run_all' ] ( cmd , output_loglevel = 'trace' , python_shell = False ) for line in ret [ 'stderr' ] . splitlines ( ) : errors . append ( line ) pkg = None for line in ret [ 'stdout' ] . splitlines ( ) : if pkg is not None and line . startswith ( '/' ) : files [ pkg ] . append ( line ) elif ':/' in line : pkg , fn = line . split ( ':' , 1 ) pkg , ver = pkg . rsplit ( '-' , 1 ) files [ pkg ] = [ fn ] else : continue return { 'errors' : errors , 'files' : files }
List the files that belong to a package, grouped by package. Not
    specifying any packages will return a list of _every_ file on the
    system's package database (not generally recommended).

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.file_list httpd
        salt '*' pkg.file_list httpd postfix
        salt '*' pkg.file_list