def _merge_flags(new_flags, old_flags=None, conf='any'):
 if (not old_flags):
  old_flags = []
 args = [old_flags, new_flags]
 if (conf == 'accept_keywords'):
  tmp = (new_flags + [i for i in old_flags if _check_accept_keywords(new_flags, i)])
 else:
  tmp = portage.flatten(args)
 flags = {}
 for flag in tmp:
  if (flag[0] == '-'):
   flags[flag[1:]] = False
  else:
   flags[flag] = True
 tmp = []
 for (key, val) in six.iteritems(flags):
  if val:
   tmp.append(key)
  else:
   tmp.append(('-' + key))
 tmp.sort(cmp=(lambda x, y: cmp(x.lstrip('-'), y.lstrip('-'))))
 return tmp

def _merge_flags ( new_flags , old_flags = None , conf = 'any' ) : if ( not old_flags ) : old_flags = [ ] args = [ old_flags , new_flags ] if ( conf == 'accept_keywords' ) : tmp = ( new_flags + [ i for i in old_flags if _check_accept_keywords ( new_flags , i ) ] ) else : tmp = portage . flatten ( args ) flags = { } for flag in tmp : if ( flag [ 0 ] == '-' ) : flags [ flag [ 1 : ] ] = False else : flags [ flag ] = True tmp = [ ] for ( key , val ) in six . iteritems ( flags ) : if val : tmp . append ( key ) else : tmp . append ( ( '-' + key ) ) tmp . sort ( cmp = ( lambda x , y : cmp ( x . lstrip ( '-' ) , y . lstrip ( '-' ) ) ) ) return tmp
merges multiple lists of flags removing duplicates and resolving conflicts giving priority to lasts lists .