# Path: django_eventstream/utils.py
# def sse_encode_event(event_type, data, event_id=None, escape=False, json_encode=True):
# 	if json_encode:
# 		data_str = json.dumps(data, cls=DjangoJSONEncoder)
# 	else:
# 		data_str = data
# 	if escape:
# 		event_type = build_id_escape(event_type)
# 		data_str = build_id_escape(data_str)
# 	out = 'event: %s\n' % event_type
# 	if event_id:
# 		out += 'id: %s\n' % event_id
# 	out += 'data: %s\n\n' % data_str
# 	return out
# 
# def make_id(ids):
# 	id_parts = []
# 	for channel, id in six.iteritems(ids):
# 		enc_channel = quote(channel)
# 		id_parts.append('%s:%s' % (enc_channel, id))
# 	return ','.join(id_parts)
# 
# def build_id_escape(s):
# 	out = ''
# 	for c in s:
# 		if c == '%':
# 			out += '%%'
# 		else:
# 			out += c
# 	return out


import copy
import time
import jwt
import six
from gripcontrol import Channel
from django.conf import settings
from django.http import HttpResponse
from .utils import sse_encode_event, make_id, build_id_escape
	from urllib import quote
	from urllib.parse import quote
			'user': user_id
		}
		params['es-meta'] = six.ensure_text(jwt.encode(es_meta,
				settings.SECRET_KEY.encode('utf-8')))
		next_uri = http_request.path + '?' + params.urlencode()

		instruct = http_request.grip.start_instruct()

		instruct.set_next_link(next_uri)

		for channel in six.iterkeys(self.channel_items):
			enc_channel = quote(channel)
			last_id = last_ids.get(channel)
			gc = Channel('events-%s' % enc_channel, prev_id=last_id)
			if last_id:
				gc.filters.append('build-id')
			gc.filters.append('skip-users')
			instruct.add_channel(gc)

		gc = Channel('user-%s' % user_id)
		gc.filters.append('require-sub')
		instruct.add_channel(gc)

		if not more:
			instruct.set_hold_stream()

		if len(last_ids) > 0:
			id_parts = []
			for channel in six.iterkeys(last_ids):
				enc_channel = quote(channel)

# Path: django_eventstream/utils.py
# def sse_encode_event(event_type, data, event_id=None, escape=False, json_encode=True):
# 	if json_encode:
# 		data_str = json.dumps(data, cls=DjangoJSONEncoder)
# 	else:
# 		data_str = data
# 	if escape:
# 		event_type = build_id_escape(event_type)
# 		data_str = build_id_escape(data_str)
# 	out = 'event: %s\n' % event_type
# 	if event_id:
# 		out += 'id: %s\n' % event_id
# 	out += 'data: %s\n\n' % data_str
# 	return out
# 
# def make_id(ids):
# 	id_parts = []
# 	for channel, id in six.iteritems(ids):
# 		enc_channel = quote(channel)
# 		id_parts.append('%s:%s' % (enc_channel, id))
# 	return ','.join(id_parts)
# 
# def build_id_escape(s):
# 	out = ''
# 	for c in s:
# 		if c == '%':
# 			out += '%%'
# 		else:
# 			out += c
# 	return out


# Path: django_eventstream/eventresponse.py
import copy
import time
import jwt
import six
from gripcontrol import Channel
from django.conf import settings
from django.http import HttpResponse
from .utils import sse_encode_event, make_id, build_id_escape
	from urllib import quote
	from urllib.parse import quote

			'user': user_id
		}
		params['es-meta'] = six.ensure_text(jwt.encode(es_meta,
				settings.SECRET_KEY.encode('utf-8')))
		next_uri = http_request.path + '?' + params.urlencode()

		instruct = http_request.grip.start_instruct()

		instruct.set_next_link(next_uri)

		for channel in six.iterkeys(self.channel_items):
			enc_channel = quote(channel)
			last_id = last_ids.get(channel)
			gc = Channel('events-%s' % enc_channel, prev_id=last_id)
			if last_id:
				gc.filters.append('build-id')
			gc.filters.append('skip-users')
			instruct.add_channel(gc)

		gc = Channel('user-%s' % user_id)
		gc.filters.append('require-sub')
		instruct.add_channel(gc)

		if not more:
			instruct.set_hold_stream()

		if len(last_ids) > 0:
			id_parts = []
			for channel in six.iterkeys(last_ids):
				enc_channel = quote(channel)

				id_parts.append('%s:%%(events-%s)s' % (build_id_escape(