docs: def _match(names):
      '''
      Since pkg_delete requires the full "pkgname-version" string, this function
      will attempt to match the package name with its version. Returns a list of
      partial matches and package names that match the "pkgname-version" string
      required by pkg_delete, and a list of errors encountered.
      '''
      pkgs = list_pkgs(versions_as_list=True)
      errors = []
  
      # Look for full matches
      full_pkg_strings = []
      out = __salt__['cmd.run_stdout'](['pkg_info'],
                                       output_loglevel='trace',
                                       python_shell=False)
      for line in out.splitlines():
          try:
              full_pkg_strings.append(line.split()[0])
          except IndexError:
              continue
      full_matches = [x for x in names if x in full_pkg_strings]
  
      # Look for pkgname-only matches
      matches = []
      ambiguous = []
      for name in set(names) - set(full_matches):
          cver = pkgs.get(name)
          if cver is not None:
              if len(cver) == 1:
                  matches.append('{0}-{1}'.format(name, cver[0]))
              else:
                  ambiguous.append(name)
                  errors.append(
                      'Ambiguous package \'{0}\'. Full name/version required. '
                      'Possible matches: {1}'.format(
                          name,
                          ', '.join(['{0}-{1}'.format(name, x) for x in cver])
                      )
                  )
  
      # Find packages that did not match anything
      not_matched = \
          set(names) - set(matches) - set(full_matches) - set(ambiguous)
      for name in not_matched:
          errors.append('Package \'{0}\' not found'.format(name))
  
      return matches + full_matches, errors