docs: def version(*names, **kwargs):
      '''
      Common interface for obtaining the version of installed packages.
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' pkg_resource.version vim
          salt '*' pkg_resource.version foo bar baz
          salt '*' pkg_resource.version 'python*'
      '''
      ret = {}
      versions_as_list = \
          salt.utils.data.is_true(kwargs.pop('versions_as_list', False))
      pkg_glob = False
      if names:
          pkgs = __salt__['pkg.list_pkgs'](versions_as_list=True, **kwargs)
          for name in names:
              if '*' in name:
                  pkg_glob = True
                  for match in fnmatch.filter(pkgs, name):
                      ret[match] = pkgs.get(match, [])
              else:
                  ret[name] = pkgs.get(name, [])
      if not versions_as_list:
          __salt__['pkg_resource.stringify'](ret)
      # Return a string if no globbing is used, and there is one item in the
      # return dict
      if len(ret) == 1 and not pkg_glob:
          try:
              return next(six.itervalues(ret))
          except StopIteration:
              return ''
      return ret