docs: def list_pkgs(versions_as_list=False, **kwargs):
      '''
      List the packages currently installed as a dict:
  
      .. code-block:: python
  
          {'<package_name>': '<version>'}
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' pkg.list_pkgs
      '''
      versions_as_list = salt.utils.data.is_true(versions_as_list)
      # not yet implemented or not applicable
      if any([salt.utils.data.is_true(kwargs.get(x))
              for x in ('removed', 'purge_desired')]):
          return {}
  
      if 'pkg.list_pkgs' in __context__:
          if versions_as_list:
              return __context__['pkg.list_pkgs']
          else:
              ret = copy.deepcopy(__context__['pkg.list_pkgs'])
              __salt__['pkg_resource.stringify'](ret)
              return ret
  
      ret = {}
      cmd = '/usr/bin/pkginfo -x'
  
      # Package information returned two lines per package. On even-offset
      # lines, the package name is in the first column. On odd-offset lines, the
      # package version is in the second column.
      lines = __salt__['cmd.run'](
              cmd,
              output_loglevel='trace',
              python_shell=False).splitlines()
      for index, line in enumerate(lines):
          if index % 2 == 0:
              name = line.split()[0].strip()
          if index % 2 == 1:
              version_num = line.split()[1].strip()
              __salt__['pkg_resource.add_pkg'](ret, name, version_num)
  
      __salt__['pkg_resource.sort_pkglist'](ret)
      __context__['pkg.list_pkgs'] = copy.deepcopy(ret)
      if not versions_as_list:
          __salt__['pkg_resource.stringify'](ret)
      return ret