def _update_entry(entry, status, directives):
 for (directive, state) in six.iteritems(directives):
  if (directive == 'delete_others'):
   status['delete_others'] = state
   continue
  for (attr, vals) in six.iteritems(state):
   status['mentioned_attributes'].add(attr)
   vals = _toset(vals)
   if (directive == 'default'):
    if (len(vals) and ((attr not in entry) or (not len(entry[attr])))):
     entry[attr] = vals
   elif (directive == 'add'):
    vals.update(entry.get(attr, ()))
    if len(vals):
     entry[attr] = vals
   elif (directive == 'delete'):
    existing_vals = entry.pop(attr, set())
    if len(vals):
     existing_vals -= vals
     if len(existing_vals):
      entry[attr] = existing_vals
   elif (directive == 'replace'):
    entry.pop(attr, None)
    if len(vals):
     entry[attr] = vals
   else:
    raise ValueError(('unknown directive: ' + directive))

def _update_entry ( entry , status , directives ) : for ( directive , state ) in six . iteritems ( directives ) : if ( directive == 'delete_others' ) : status [ 'delete_others' ] = state continue for ( attr , vals ) in six . iteritems ( state ) : status [ 'mentioned_attributes' ] . add ( attr ) vals = _toset ( vals ) if ( directive == 'default' ) : if ( len ( vals ) and ( ( attr not in entry ) or ( not len ( entry [ attr ] ) ) ) ) : entry [ attr ] = vals elif ( directive == 'add' ) : vals . update ( entry . get ( attr , ( ) ) ) if len ( vals ) : entry [ attr ] = vals elif ( directive == 'delete' ) : existing_vals = entry . pop ( attr , set ( ) ) if len ( vals ) : existing_vals -= vals if len ( existing_vals ) : entry [ attr ] = existing_vals elif ( directive == 'replace' ) : entry . pop ( attr , None ) if len ( vals ) : entry [ attr ] = vals else : raise ValueError ( ( 'unknown directive: ' + directive ) )
update an entrys attributes using the provided directives .