Show More
@@ -21,13 +21,6 from __future__ import print_function | |||
|
21 | 21 | |
|
22 | 22 | import os |
|
23 | 23 | |
|
24 | from .displaypub import ( | |
|
25 | publish_pretty, publish_html, | |
|
26 | publish_latex, publish_svg, | |
|
27 | publish_png, publish_json, | |
|
28 | publish_javascript, publish_jpeg | |
|
29 | ) | |
|
30 | ||
|
31 | 24 | from IPython.utils.py3compat import string_types |
|
32 | 25 | |
|
33 | 26 | #----------------------------------------------------------------------------- |
@@ -3,7 +3,7 | |||
|
3 | 3 | There are two components of the display system: |
|
4 | 4 | |
|
5 | 5 | * Display formatters, which take a Python object and compute the |
|
6 |
representation of the object in various formats (text, HTML, SV |
|
|
6 | representation of the object in various formats (text, HTML, SVG, etc.). | |
|
7 | 7 | * The display publisher that is used to send the representation data to the |
|
8 | 8 | various frontends. |
|
9 | 9 | |
@@ -162,151 +162,3 def publish_display_data(source, data, metadata=None): | |||
|
162 | 162 | ) |
|
163 | 163 | |
|
164 | 164 | |
|
165 | def publish_pretty(data, metadata=None): | |
|
166 | """Publish raw text data to all frontends. | |
|
167 | ||
|
168 | Parameters | |
|
169 | ---------- | |
|
170 | data : unicode | |
|
171 | The raw text data to publish. | |
|
172 | metadata : dict | |
|
173 | A dictionary for metadata related to the data. This can contain | |
|
174 | arbitrary key, value pairs that frontends can use to interpret | |
|
175 | the data. | |
|
176 | """ | |
|
177 | publish_display_data( | |
|
178 | u'IPython.core.displaypub.publish_pretty', | |
|
179 | {'text/plain':data}, | |
|
180 | metadata=metadata | |
|
181 | ) | |
|
182 | ||
|
183 | ||
|
184 | def publish_html(data, metadata=None): | |
|
185 | """Publish raw HTML data to all frontends. | |
|
186 | ||
|
187 | Parameters | |
|
188 | ---------- | |
|
189 | data : unicode | |
|
190 | The raw HTML data to publish. | |
|
191 | metadata : dict | |
|
192 | A dictionary for metadata related to the data. This can contain | |
|
193 | arbitrary key, value pairs that frontends can use to interpret | |
|
194 | the data. | |
|
195 | """ | |
|
196 | publish_display_data( | |
|
197 | u'IPython.core.displaypub.publish_html', | |
|
198 | {'text/html':data}, | |
|
199 | metadata=metadata | |
|
200 | ) | |
|
201 | ||
|
202 | ||
|
203 | def publish_latex(data, metadata=None): | |
|
204 | """Publish raw LaTeX data to all frontends. | |
|
205 | ||
|
206 | Parameters | |
|
207 | ---------- | |
|
208 | data : unicode | |
|
209 | The raw LaTeX data to publish. | |
|
210 | metadata : dict | |
|
211 | A dictionary for metadata related to the data. This can contain | |
|
212 | arbitrary key, value pairs that frontends can use to interpret | |
|
213 | the data. | |
|
214 | """ | |
|
215 | publish_display_data( | |
|
216 | u'IPython.core.displaypub.publish_latex', | |
|
217 | {'text/latex':data}, | |
|
218 | metadata=metadata | |
|
219 | ) | |
|
220 | ||
|
221 | def publish_png(data, metadata=None): | |
|
222 | """Publish raw binary PNG data to all frontends. | |
|
223 | ||
|
224 | Parameters | |
|
225 | ---------- | |
|
226 | data : str/bytes | |
|
227 | The raw binary PNG data to publish. | |
|
228 | metadata : dict | |
|
229 | A dictionary for metadata related to the data. This can contain | |
|
230 | arbitrary key, value pairs that frontends can use to interpret | |
|
231 | the data. | |
|
232 | """ | |
|
233 | publish_display_data( | |
|
234 | u'IPython.core.displaypub.publish_png', | |
|
235 | {'image/png':data}, | |
|
236 | metadata=metadata | |
|
237 | ) | |
|
238 | ||
|
239 | ||
|
240 | def publish_jpeg(data, metadata=None): | |
|
241 | """Publish raw binary JPEG data to all frontends. | |
|
242 | ||
|
243 | Parameters | |
|
244 | ---------- | |
|
245 | data : str/bytes | |
|
246 | The raw binary JPEG data to publish. | |
|
247 | metadata : dict | |
|
248 | A dictionary for metadata related to the data. This can contain | |
|
249 | arbitrary key, value pairs that frontends can use to interpret | |
|
250 | the data. | |
|
251 | """ | |
|
252 | publish_display_data( | |
|
253 | u'IPython.core.displaypub.publish_jpeg', | |
|
254 | {'image/jpeg':data}, | |
|
255 | metadata=metadata | |
|
256 | ) | |
|
257 | ||
|
258 | ||
|
259 | def publish_svg(data, metadata=None): | |
|
260 | """Publish raw SVG data to all frontends. | |
|
261 | ||
|
262 | Parameters | |
|
263 | ---------- | |
|
264 | data : unicode | |
|
265 | The raw SVG data to publish. | |
|
266 | metadata : dict | |
|
267 | A dictionary for metadata related to the data. This can contain | |
|
268 | arbitrary key, value pairs that frontends can use to interpret | |
|
269 | the data. | |
|
270 | """ | |
|
271 | publish_display_data( | |
|
272 | u'IPython.core.displaypub.publish_svg', | |
|
273 | {'image/svg+xml':data}, | |
|
274 | metadata=metadata | |
|
275 | ) | |
|
276 | ||
|
277 | def publish_json(data, metadata=None): | |
|
278 | """Publish raw JSON data to all frontends. | |
|
279 | ||
|
280 | Parameters | |
|
281 | ---------- | |
|
282 | data : unicode | |
|
283 | The raw JSON data to publish. | |
|
284 | metadata : dict | |
|
285 | A dictionary for metadata related to the data. This can contain | |
|
286 | arbitrary key, value pairs that frontends can use to interpret | |
|
287 | the data. | |
|
288 | """ | |
|
289 | publish_display_data( | |
|
290 | u'IPython.core.displaypub.publish_json', | |
|
291 | {'application/json':data}, | |
|
292 | metadata=metadata | |
|
293 | ) | |
|
294 | ||
|
295 | def publish_javascript(data, metadata=None): | |
|
296 | """Publish raw Javascript data to all frontends. | |
|
297 | ||
|
298 | Parameters | |
|
299 | ---------- | |
|
300 | data : unicode | |
|
301 | The raw Javascript data to publish. | |
|
302 | metadata : dict | |
|
303 | A dictionary for metadata related to the data. This can contain | |
|
304 | arbitrary key, value pairs that frontends can use to interpret | |
|
305 | the data. | |
|
306 | """ | |
|
307 | publish_display_data( | |
|
308 | u'IPython.core.displaypub.publish_javascript', | |
|
309 | {'application/javascript':data}, | |
|
310 | metadata=metadata | |
|
311 | ) | |
|
312 |
General Comments 0
You need to be logged in to leave comments.
Login now