99
1010
1111class Channel :
12- '''
12+ """
1313 Accepts a name which should either be the name of the group
1414 or the channel_name to which the content will be broadcast to.
1515
@@ -20,11 +20,11 @@ class Channel:
2020 If you're using this and initializes this with the session key as a name.
2121 You need to set the identifier to '{"channel":"StimulusReflex::Channel"}'
2222 which is the default identifier in the frontend.
23- '''
23+ """
2424
25- def __init__ (self , name , identifier = '' ):
25+ def __init__ (self , name , identifier = "" ):
2626 if not identifier :
27- identifier = json .dumps ({' channel' : name }).replace (' ' , '' )
27+ identifier = json .dumps ({" channel" : name }).replace (" " , "" )
2828 self .identifier = identifier
2929 self .name = name
3030 self .operations = self .stub ()
@@ -37,27 +37,28 @@ def add_operation(self, key, options):
3737
3838 def stub (self ):
3939 return {
40- ' dispatch_event' : [],
41- ' morph' : [],
42- ' inner_html' : [],
43- ' outer_html' : [],
44- ' text_content' : [],
45- ' insert_adjacent_html' : [],
46- ' insert_adjacent_text' : [],
47- ' remove' : [],
48- ' set_value' : [],
49- ' set_attribute' : [],
50- ' remove_attribute' : [],
51- ' add_css_class' : [],
52- ' remove_css_class' : [],
53- ' set_dataset_property' : [],
54- ' set_style' : []
40+ " dispatch_event" : [],
41+ " morph" : [],
42+ " inner_html" : [],
43+ " outer_html" : [],
44+ " text_content" : [],
45+ " insert_adjacent_html" : [],
46+ " insert_adjacent_text" : [],
47+ " remove" : [],
48+ " set_value" : [],
49+ " set_attribute" : [],
50+ " remove_attribute" : [],
51+ " add_css_class" : [],
52+ " remove_css_class" : [],
53+ " set_dataset_property" : [],
54+ " set_style" : [],
5555 }
5656
5757 def broadcast (self ):
5858 operations = {
5959 camelcase (key ): camelize_value (value )
60- for key , value in self .operations .items () if value
60+ for key , value in self .operations .items ()
61+ if value
6162 }
6263 channel_layer = get_channel_layer ()
6364 group_send = async_to_sync (channel_layer .group_send )
@@ -67,24 +68,24 @@ def broadcast(self):
6768 "identifier" : self .identifier ,
6869 "type" : "message" ,
6970 "cableReady" : True ,
70- "operations" : operations
71- }
71+ "operations" : operations ,
72+ },
7273 )
7374 self .clear ()
7475
7576 def dispatch_event (self , options = {}):
76- '''
77+ """
7778 dispatch_event: [{
7879 name: "string",
7980 detail: "object",
8081 selector: "string",
8182 }, ...
8283 ],
83- '''
84- self .add_operation (' dispatch_event' , options )
84+ """
85+ self .add_operation (" dispatch_event" , options )
8586
8687 def morph (self , options = {}):
87- '''
88+ """
8889 morph: [{
8990 selector: "string",
9091 html: "string"
@@ -93,120 +94,120 @@ def morph(self, options={}):
9394 focus_selector: "string",
9495 }, ...
9596 ],
96- '''
97- self .add_operation (' morph' , options )
97+ """
98+ self .add_operation (" morph" , options )
9899
99100 def inner_html (self , options = {}):
100- '''
101- inner_html: [{
102- selector: "string",
103- focus_selector: "string",
104- html: "string"
105- }, ...],
106- '''
107- self .add_operation (' inner_html' , options )
101+ """
102+ inner_html: [{
103+ selector: "string",
104+ focus_selector: "string",
105+ html: "string"
106+ }, ...],
107+ """
108+ self .add_operation (" inner_html" , options )
108109
109110 def outer_html (self , options = {}):
110- '''
111- outer_html: [{
112- selector: "string",
113- focus_selector: "string",
114- html: "string"
115- }, ...],
116- '''
117- self .add_operation (' outer_html' , options )
111+ """
112+ outer_html: [{
113+ selector: "string",
114+ focus_selector: "string",
115+ html: "string"
116+ }, ...],
117+ """
118+ self .add_operation (" outer_html" , options )
118119
119120 def text_content (self , options = {}):
120- '''
121- text_content: [{
122- selector: "string",
123- text: "string"
124- }, ...]
125- '''
126- self .add_operation (' text_content' , options )
121+ """
122+ text_content: [{
123+ selector: "string",
124+ text: "string"
125+ }, ...]
126+ """
127+ self .add_operation (" text_content" , options )
127128
128129 def insert_adjacent_html (self , options = {}):
129- '''
130+ """
130131 insert_adjacent_html: [{
131132 selector: "string",
132133 focus_selector: "string",
133134 position: "string",
134135 html: "string"
135136 }, ...],
136- '''
137- self .add_operation (' insert_adjacent_html' , options )
137+ """
138+ self .add_operation (" insert_adjacent_html" , options )
138139
139140 def remove (self , options = {}):
140- '''
141+ """
141142 remove: [{
142143 selector: "string",
143144 focus_selector: "string,
144145 }, ...],
145- '''
146- self .add_operation (' remove' , options )
146+ """
147+ self .add_operation (" remove" , options )
147148
148149 def remove_attribute (self , options = {}):
149- '''
150+ """
150151 remove_attribute: [{
151152 selector: "string",
152153 name: "string"
153154 }, ...],
154- '''
155- self .add_operation (' remove_attribute' , options )
155+ """
156+ self .add_operation (" remove_attribute" , options )
156157
157158 def set_attribute (self , options = {}):
158- '''
159+ """
159160 set_attribute: [{
160161 selector: "string",
161162 name: "string",
162163 value: "string"
163164 }, ...],
164- '''
165- self .add_operation (' set_attribute' , options )
165+ """
166+ self .add_operation (" set_attribute" , options )
166167
167168 def set_value (self , options = {}):
168- '''
169+ """
169170 set_value: [{
170171 selector: "string",
171172 value: "string"
172173 }, ...],
173- '''
174- self .add_operation (' set_value' , options )
174+ """
175+ self .add_operation (" set_value" , options )
175176
176177 def add_css_class (self , options = {}):
177- '''
178+ """
178179 add_css_class: [{
179180 selector: "string",
180181 name: "string"
181182 }, ...],
182- '''
183- self .add_operation (' add_css_class' , options )
183+ """
184+ self .add_operation (" add_css_class" , options )
184185
185186 def remove_css_class (self , options = {}):
186- '''
187+ """
187188 remove_css_class: [{
188189 selector: "string",
189190 name: "string"
190191 }, ...],
191- '''
192- self .add_operation (' remove_css_class' , options )
192+ """
193+ self .add_operation (" remove_css_class" , options )
193194
194195 def set_dataset_property (self , options ):
195- '''
196+ """
196197 set_dataset_property: [{
197198 selector: "string",
198199 name: "string",
199200 value: "string"
200201 }, ...],
201- '''
202- self .add_operation (' set_dataset_property' , options )
202+ """
203+ self .add_operation (" set_dataset_property" , options )
203204
204205 def set_style (self , options ):
205- '''
206+ """
206207 set_style: [{
207208 selector: "string",
208209 name: "string",
209210 value: "string"
210211 }, ...],
211- '''
212- self .add_operation (' set_style' , options )
212+ """
213+ self .add_operation (" set_style" , options )
0 commit comments