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

    CLI Examples:

    .. code-block:: bash

        salt '*' lowpkg.file_dict httpd
        salt '*' lowpkg.file_dict httpd postfix
        salt '*' lowpkg.file_dict
    '''
    errors = []
    ret = {}
    pkgs = {}
    cmd = ['rpm', '-q' if packages else '-qa',
           '--queryformat', r'%{NAME} %{VERSION}\n']
    if packages:
        cmd.extend(packages)
    out = __salt__['cmd.run'](cmd, output_loglevel='trace', python_shell=False)
    for line in salt.utils.itertools.split(out, '\n'):
        if 'is not installed' in line:
            errors.append(line)
            continue
        comps = line.split()
        pkgs[comps[0]] = {'version': comps[1]}
    for pkg in pkgs:
        files = []
        cmd = ['rpm', '-ql', pkg]
        out = __salt__['cmd.run'](
            ['rpm', '-ql', pkg],
            output_loglevel='trace',
            python_shell=False)
        ret[pkg] = out.splitlines()
    return {'errors': errors, 'packages': ret}
dataset/ETHPy150Open saltstack/salt/salt/modules/rpm.py/file_dict/original