def set_mime_type(self, mime_type):
        """
        Update the highlighter lexer based on a mime type.

        :param mime_type: mime type of the new lexer to setup.
        """
        try:
            self.set_lexer_from_mime_type(mime_type)
        except ClassNotFound:
            _logger().exception('failed to get lexer from mimetype')
            self._lexer = TextLexer()
            return False
        except ImportError:
            # import error while loading some pygments plugins, the editor
            # should not crash
            _logger().warning('failed to get lexer from mimetype (%s)' %
                              mime_type)
            self._lexer = TextLexer()
            return False
        else:
            return True
def set_mime_type ( self , mime_type ) : try : self . set_lexer_from_mime_type ( mime_type ) except ClassNotFound : _logger ( ) . exception ( 'failed to get lexer from mimetype' ) self . _lexer = TextLexer ( ) return False except ImportError : _logger ( ) . warning ( 'failed to get lexer from mimetype (%s)' % mime_type ) self . _lexer = TextLexer ( ) return False else : return True
Update the highlighter lexer based on a mime type.

        :param mime_type: mime type of the new lexer to setup.