def query_package(module, name):
 (rc, out, err) = module.run_command(('%s -p -v' % PKGIN_PATH))
 if (rc == 0):
  pflag = '-p'
  splitchar = ';'
 else:
  pflag = ''
  splitchar = ' '
 (rc, out, err) = module.run_command(('%s %s search "^%s$"' % (PKGIN_PATH, pflag, name)))
 if (rc == 0):
  packages = out.split('\n')
  for package in packages:
   (pkgname_with_version, raw_state) = package.split(splitchar)[0:2]
   pkg_search_obj = re.search('^(.*?)\\-[0-9][0-9.]*(nb[0-9]+)*', pkgname_with_version, re.M)
   if (not pkg_search_obj):
    continue
   pkgname_without_version = pkg_search_obj.group(1)
   if (name != pkgname_without_version):
    continue
   if (raw_state == '<'):
    return 'outdated'
   elif ((raw_state == '=') or (raw_state == '>')):
    return 'present'
   else:
    return False
  return False

def query_package ( module , name ) : ( rc , out , err ) = module . run_command ( ( '%s -p -v' % PKGIN_PATH ) ) if ( rc == 0 ) : pflag = '-p' splitchar = ';' else : pflag = '' splitchar = ' ' ( rc , out , err ) = module . run_command ( ( '%s %s search "^%s$"' % ( PKGIN_PATH , pflag , name ) ) ) if ( rc == 0 ) : packages = out . split ( '\n' ) for package in packages : ( pkgname_with_version , raw_state ) = package . split ( splitchar ) [ 0 : 2 ] pkg_search_obj = re . search ( '^(.*?)\\-[0-9][0-9.]*(nb[0-9]+)*' , pkgname_with_version , re . M ) if ( not pkg_search_obj ) : continue pkgname_without_version = pkg_search_obj . group ( 1 ) if ( name != pkgname_without_version ) : continue if ( raw_state == '<' ) : return 'outdated' elif ( ( raw_state == '=' ) or ( raw_state == '>' ) ) : return 'present' else : return False return False
returns package info .