environment/lib/python2.7/site-packages/IPython/frontend/qt/console/rich_ipython_widget.py
def _handle_display_data(self, msg):
        """ Overridden to handle rich data types, like SVG.
        """
        if not self._hidden and self._is_from_this_session(msg):
            source = msg['content']['source']
            data = msg['content']['data']
            metadata = msg['content']['metadata']
            # Try to use the svg or html representations.
            # FIXME: Is this the right ordering of things to try?
            if data.has_key('image/svg+xml'):
                self.log.debug("display: %s", msg.get('content', ''))
                svg = data['image/svg+xml']
                self._append_svg(svg, True)
            elif data.has_key('image/png'):
                self.log.debug("display: %s", msg.get('content', ''))
                # PNG data is base64 encoded as it passes over the network
                # in a JSON structure so we decode it.
                png = decodestring(data['image/png'].encode('ascii'))
                self._append_png(png, True)
            elif data.has_key('image/jpeg') and self._jpg_supported:
                self.log.debug("display: %s", msg.get('content', ''))
                jpg = decodestring(data['image/jpeg'].encode('ascii'))
                self._append_jpg(jpg, True)
            else:
                # Default back to the plain text representation.
                return super(RichIPythonWidget, self)._handle_display_data(msg)
def _handle_display_data(self, msg):
        """ Overridden to handle rich data types, like SVG.
        """
        if not self._hidden and self._is_from_this_session(msg):
            source = msg['content']['source']
            data = msg['content']['data']
            metadata = msg['content']['metadata']
            # Try to use the svg or html representations.
            # FIXME: Is this the right ordering of things to try?
            if data.has_key('image/svg+xml'):
                self.log.debug("display: %s", msg.get('content', ''))
                svg = data['image/svg+xml']
                self._append_svg(svg, True)
            elif data.has_key('image/png'):
                self.log.debug("display: %s", msg.get('content', ''))
                # PNG data is base64 encoded as it passes over the network
                # in a JSON structure so we decode it.
                png = decodestring(data['image/png'].encode('ascii'))
                self._append_png(png, True)
            elif data.has_key('image/jpeg') and self._jpg_supported:
                self.log.debug("display: %s", msg.get('content', ''))
                jpg = decodestring(data['image/jpeg'].encode('ascii'))
                self._append_jpg(jpg, True)
            else:
                # Default back to the plain text representation.
                return super(RichIPythonWidget, self)._handle_display_data(msg)
def _handle_display_data ( self , msg ) : if not self . _hidden and self . _is_from_this_session ( msg ) : source = msg [ 'content' ] [ 'source' ] data = msg [ 'content' ] [ 'data' ] metadata = msg [ 'content' ] [ 'metadata' ] # Try to use the svg or html representations. # FIXME: Is this the right ordering of things to try? if data . has_key ( 'image/svg+xml' ) : self . log . debug ( "display: %s" , msg . get ( 'content' , '' ) ) svg = data [ 'image/svg+xml' ] self . _append_svg ( svg , True ) elif data . has_key ( 'image/png' ) : self . log . debug ( "display: %s" , msg . get ( 'content' , '' ) ) # PNG data is base64 encoded as it passes over the network # in a JSON structure so we decode it. png = decodestring ( data [ 'image/png' ] . encode ( 'ascii' ) ) self . _append_png ( png , True ) elif data . has_key ( 'image/jpeg' ) and self . _jpg_supported : self . log . debug ( "display: %s" , msg . get ( 'content' , '' ) ) jpg = decodestring ( data [ 'image/jpeg' ] . encode ( 'ascii' ) ) self . _append_jpg ( jpg , True ) else : # Default back to the plain text representation. return super ( RichIPythonWidget , self ) . _handle_display_data ( msg )
Overridden to handle rich data types, like SVG.
Overridden to handle rich data types like SVG .