def validate_labels(db_session, added_categories, removed_categories):
 add = {c.name for c in added_categories if c.name}
 add_all = ('all' in add)
 add_trash = ('trash' in add)
 add_spam = ('spam' in add)
 if ((add_all and (add_trash or add_spam)) or (add_trash and add_spam)):
  raise InputError('Only one of "all", "trash" or "spam" can be added')
 remove = {c.name for c in removed_categories if c.name}
 remove_all = ('all' in remove)
 remove_trash = ('trash' in remove)
 remove_spam = ('spam' in remove)
 if (remove_all and remove_trash and remove_spam):
  raise InputError('"all", "trash" and "spam" cannot all be removed')

def validate_labels ( db_session , added_categories , removed_categories ) : add = { c . name for c in added_categories if c . name } add_all = ( 'all' in add ) add_trash = ( 'trash' in add ) add_spam = ( 'spam' in add ) if ( ( add_all and ( add_trash or add_spam ) ) or ( add_trash and add_spam ) ) : raise InputError ( 'Only one of "all", "trash" or "spam" can be added' ) remove = { c . name for c in removed_categories if c . name } remove_all = ( 'all' in remove ) remove_trash = ( 'trash' in remove ) remove_spam = ( 'spam' in remove ) if ( remove_all and remove_trash and remove_spam ) : raise InputError ( '"all", "trash" and "spam" cannot all be removed' )
validate that the labels added and removed obey gmails semantics -- gmail messages must belong to exactly one of the [gmail]all mail .