code: def list_pkgs(*packages, **kwargs):
      '''
      List the packages currently installed in a dict::
  
          {'<package_name>': '<version>'}
  
      root
          use root as top level directory (default: "/")
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' lowpkg.list_pkgs
      '''
      pkgs = {}
      cmd = ['rpm']
      if kwargs.get('root'):
          cmd.extend(['--root', kwargs['root']])
      cmd.extend(['-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:
              continue
          comps = line.split()
          pkgs[comps[0]] = comps[1]
      return pkgf list_pkgs(*packages, **kwargs):
      '''
      List the packages currently installed in a dict::
  
          {'<package_name>': '<version>'}
  
      root
          use root as top level directory (default: "/")
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' lowpkg.list_pkgs
      '''
      pkgs = {}
      cmd = ['rpm']
      if kwargs.get('root'):
          cmd.extend(['--root', kwargs['root']])
      cmd.extend(['-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:
              continue
          comps = line.split()
          pkgs[comps[0]] = comps[1]
      return pkgs
docs: List the packages currently installed in a dict::
  
          {'<package_name>': '<version>'}
  
      root
          use root as top level directory (default: "/")
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' lowpkg.list_pkgs