def categorize_users(user, source_event, source_node, event, node):
 remove = utils.users_to_remove(source_event, source_node, node)
 source_node_subs = compile_subscriptions(source_node, utils.find_subscription_type(source_event))
 new_subs = compile_subscriptions(node, utils.find_subscription_type(source_event), event)
 move = subscriptions_users_union(source_node_subs, new_subs)
 warn = subscriptions_users_difference(source_node_subs, new_subs)
 (warn, remove) = subscriptions_node_permissions(node, warn, remove)
 warn = subscriptions_users_remove_duplicates(warn, new_subs, remove_same=False)
 move = subscriptions_users_remove_duplicates(move, new_subs, remove_same=False)
 move = subscriptions_users_remove_duplicates(move, warn, remove_same=True)
 move = subscriptions_users_remove_duplicates(move, remove, remove_same=True)
 for notifications in constants.NOTIFICATION_TYPES:
  user_id = user._id
  if (user_id in warn[notifications]):
   warn[notifications].remove(user_id)
  if (user_id in move[notifications]):
   move[notifications].remove(user_id)
  if (user_id in remove[notifications]):
   remove[notifications].remove(user_id)
 return (move, warn, remove)

def categorize_users ( user , source_event , source_node , event , node ) : remove = utils . users_to_remove ( source_event , source_node , node ) source_node_subs = compile_subscriptions ( source_node , utils . find_subscription_type ( source_event ) ) new_subs = compile_subscriptions ( node , utils . find_subscription_type ( source_event ) , event ) move = subscriptions_users_union ( source_node_subs , new_subs ) warn = subscriptions_users_difference ( source_node_subs , new_subs ) ( warn , remove ) = subscriptions_node_permissions ( node , warn , remove ) warn = subscriptions_users_remove_duplicates ( warn , new_subs , remove_same = False ) move = subscriptions_users_remove_duplicates ( move , new_subs , remove_same = False ) move = subscriptions_users_remove_duplicates ( move , warn , remove_same = True ) move = subscriptions_users_remove_duplicates ( move , remove , remove_same = True ) for notifications in constants . NOTIFICATION_TYPES : user_id = user . _id if ( user_id in warn [ notifications ] ) : warn [ notifications ] . remove ( user_id ) if ( user_id in move [ notifications ] ) : move [ notifications ] . remove ( user_id ) if ( user_id in remove [ notifications ] ) : remove [ notifications ] . remove ( user_id ) return ( move , warn , remove )
categorize users from a file subscription into three categories .