def filter_sets(all_sets, only, hide):
	"""
	Filters a set of categories.

	This method is used by many commands that use some sort of dictionary
	of available data sets/categories, which must filter those sets according
	to the ones the user wants to have included in the response by that command.

	Arguments:
		all_sets (dict): The base dictionary of all available sets (from which
						 a subset should be filtered).
		only (tuple): A tuple of the names of the categories/sets to include.
		hide (tuple): A tuple of the names of the categories/sets to exclude.
					  Note that sets are hidden after the 'only' sets have
					  been processed, i.e. if a certain set is in 'only' and
					  in 'hide', it will first be selected and then discared
					  again (which would make no sense). Usually either 'only'
					  or 'hide' is empty.

	Returns:
		A dictionary containing the filtered key/value pairs.
	"""
	filtered = {}
	only = only or all_sets
	for key, value in all_sets.items():
		if key in only and key not in hide:
			filtered[key] = value

	return filtered