def _gcm_send_plain(registration_id, data, **kwargs):

	values = {"registration_id": registration_id} if registration_id else {}

	for k, v in data.items():
		values["data.%s" % (k)] = v.encode("utf-8")

	for k, v in kwargs.items():
		if v:
			if isinstance(v, bool):
				# Encode bools into ints
				v = 1
			values[k] = v

	data = urlencode(sorted(values.items())).encode("utf-8")  # sorted items for tests

	result = _gcm_send(data, "application/x-www-form-urlencoded;charset=UTF-8")

	# Information about handling response from Google docs (https://developers.google.com/cloud-messaging/http):
	# If first line starts with id, check second line:
	# If second line starts with registration_id, gets its value and replace the registration tokens in your
	# server database. Otherwise, get the value of Error

	if result.startswith("id"):
		lines = result.split("\n")
		if len(lines) > 1 and lines[1].startswith("registration_id"):
			new_id = lines[1].split("=")[-1]
			_gcm_handle_canonical_id(new_id, registration_id)

	elif result.startswith("Error="):
		if result in ("Error=NotRegistered", "Error=InvalidRegistration"):
			# Deactivate the problematic device
			device = GCMDevice.objects.filter(registration_id=values["registration_id"])
			device.update(active=0)
			return result

		raise GCMError(result)

	return result
Lex a string into chunks:
dataset/ETHPy150Open jleclanche/django-push-notifications/push_notifications/gcm.py/_gcm_send_plain--crossover with--dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Paste-2.0.1/paste/util/template.py/lex