def check_extra_requirements(pkgname, pkgver):
 keyword = None
 match = re.match('^(~)?([<>])?(=)?([^<>=]*)$', pkgver)
 if match:
  (keyword, gt_lt, eq, verstr) = match.groups()
  prefix = (gt_lt or '')
  prefix += (eq or '')
  verstr = verstr.replace("'", '')
  if ((verstr[0] != ':') and (verstr[0] != '[')):
   prefix = (prefix or '=')
   atom = '{0}{1}-{2}'.format(prefix, pkgname, verstr)
  else:
   atom = '{0}{1}'.format(pkgname, verstr)
 else:
  return True
 try:
  cpv = _porttree().dbapi.xmatch('bestmatch-visible', atom)
 except portage.exception.InvalidAtom as iae:
  log.error('Unable to find a matching package for {0}: ({1})'.format(atom, iae))
  return False
 if (cpv == ''):
  return False
 try:
  (cur_repo, cur_use) = _vartree().dbapi.aux_get(cpv, ['repository', 'USE'])
 except KeyError:
  return False
 des_repo = re.match('^.+::([^\\[]+).*$', atom)
 if (des_repo and (des_repo.group(1) != cur_repo)):
  return False
 des_uses = set(portage.dep.dep_getusedeps(atom))
 cur_use = cur_use.split()
 if (len([x for x in des_uses.difference(cur_use) if ((x[0] != '-') or (x[1:] in cur_use))]) > 0):
  return False
 if keyword:
  if (not __salt__['portage_config.has_flag']('accept_keywords', atom, '~ARCH')):
   return False
 return True

def check_extra_requirements ( pkgname , pkgver ) : keyword = None match = re . match ( '^(~)?([<>])?(=)?([^<>=]*)$' , pkgver ) if match : ( keyword , gt_lt , eq , verstr ) = match . groups ( ) prefix = ( gt_lt or '' ) prefix += ( eq or '' ) verstr = verstr . replace ( "'" , '' ) if ( ( verstr [ 0 ] != ':' ) and ( verstr [ 0 ] != '[' ) ) : prefix = ( prefix or '=' ) atom = '{0}{1}-{2}' . format ( prefix , pkgname , verstr ) else : atom = '{0}{1}' . format ( pkgname , verstr ) else : return True try : cpv = _porttree ( ) . dbapi . xmatch ( 'bestmatch-visible' , atom ) except portage . exception . InvalidAtom as iae : log . error ( 'Unable to find a matching package for {0}: ({1})' . format ( atom , iae ) ) return False if ( cpv == '' ) : return False try : ( cur_repo , cur_use ) = _vartree ( ) . dbapi . aux_get ( cpv , [ 'repository' , 'USE' ] ) except KeyError : return False des_repo = re . match ( '^.+::([^\\[]+).*$' , atom ) if ( des_repo and ( des_repo . group ( 1 ) != cur_repo ) ) : return False des_uses = set ( portage . dep . dep_getusedeps ( atom ) ) cur_use = cur_use . split ( ) if ( len ( [ x for x in des_uses . difference ( cur_use ) if ( ( x [ 0 ] != '-' ) or ( x [ 1 : ] in cur_use ) ) ] ) > 0 ) : return False if keyword : if ( not __salt__ [ 'portage_config.has_flag' ] ( 'accept_keywords' , atom , '~ARCH' ) ) : return False return True
check if the installed package already has the given requirements .