def get_pkg_id(pkg):
 pkg = _quote(pkg)
 package_ids = []
 temp_dir = __salt__['temp.dir'](prefix='pkg-')
 try:
  cmd = 'xar -t -f {0} | grep PackageInfo'.format(pkg)
  out = __salt__['cmd.run'](cmd, python_shell=True, output_loglevel='quiet')
  files = out.split('\n')
  if ('Error opening' not in out):
   cmd = 'xar -x -f {0} {1}'.format(pkg, ' '.join(files))
   __salt__['cmd.run'](cmd, cwd=temp_dir, output_loglevel='quiet')
   for f in files:
    i = _get_pkg_id_from_pkginfo(os.path.join(temp_dir, f))
    if len(i):
     package_ids.extend(i)
  else:
   package_ids = _get_pkg_id_dir(pkg)
 finally:
  __salt__['file.remove'](temp_dir)
 return package_ids

def get_pkg_id ( pkg ) : pkg = _quote ( pkg ) package_ids = [ ] temp_dir = __salt__ [ 'temp.dir' ] ( prefix = 'pkg-' ) try : cmd = 'xar -t -f {0} | grep PackageInfo' . format ( pkg ) out = __salt__ [ 'cmd.run' ] ( cmd , python_shell = True , output_loglevel = 'quiet' ) files = out . split ( '\n' ) if ( 'Error opening' not in out ) : cmd = 'xar -x -f {0} {1}' . format ( pkg , ' ' . join ( files ) ) __salt__ [ 'cmd.run' ] ( cmd , cwd = temp_dir , output_loglevel = 'quiet' ) for f in files : i = _get_pkg_id_from_pkginfo ( os . path . join ( temp_dir , f ) ) if len ( i ) : package_ids . extend ( i ) else : package_ids = _get_pkg_id_dir ( pkg ) finally : __salt__ [ 'file.remove' ] ( temp_dir ) return package_ids
attempt to get the package id from a .