Update the highlighter lexer based on a mime type.

        :param mime_type: mime type of the new lexer to setup.
557044
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:
            # 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
1139383
def process_update(self, update: types.Update):
        
        yield 'update_id', update.update_id

        if update.message:
            yield 'update_type', 'message'
            yield from self.process_message(update.message)
        if update.edited_message:
            yield 'update_type', 'edited_message'
            yield from self.process_message(update.edited_message)
        if update.channel_post:
            yield 'update_type', 'channel_post'
            yield from self.process_message(update.channel_post)
        if update.edited_channel_post:
            yield 'update_type', 'edited_channel_post'
            yield from self.process_message(update.edited_channel_post)
        if update.inline_query:
            yield 'update_type', 'inline_query'
            yield from self.process_inline_query(update.inline_query)
        if update.chosen_inline_result:
            yield 'update_type', 'chosen_inline_result'
            yield from self.process_chosen_inline_result(update.chosen_inline_result)
        if update.callback_query:
            yield 'update_type', 'callback_query'
            yield from self.process_callback_query(update.callback_query)
        if update.shipping_query:
            yield 'update_type', 'shipping_query'
            yield from self.process_shipping_query(update.shipping_query)
        if update.pre_checkout_query:
            yield 'update_type', 'pre_checkout_query'
            yield from self.process_pre_checkout_query(update.pre_checkout_query)
370316
def register_mime_type(mime_type, extensions: [], charset: nil)
      extnames = Array(extensions)

      charset ||= :default if mime_type.start_with?('text/')
      charset = EncodingUtils::CHARSET_DETECT[charset] if charset.is_a?(Symbol)

      self.config = hash_reassoc(config, :mime_exts) do |mime_exts|
        extnames.each do |extname|
          mime_exts[extname] = mime_type
        end
        mime_exts
      end

      self.config = hash_reassoc(config, :mime_types) do |mime_types|
        type = { extensions: extnames }
        type[:charset] = charset if charset
        mime_types.merge(mime_type => type)
      end
    end
1263572
def mime_type(type, value)
      type = ".#{type}" unless type.to_s[0] == '.'
      ::Rack::Mime::MIME_TYPES[type] = value
    end
531800
def update(self):
        
        font = self.editor.font()
        for decoration in self._decorations:
            try:
                decoration.format.setFont(
                        font, QTextCharFormat.FontPropertiesSpecifiedOnly)
            except (TypeError, AttributeError):  # Qt < 5.3
                decoration.format.setFontFamily(font.family())
                decoration.format.setFontPointSize(font.pointSize())
        self.editor.setExtraSelections(self._decorations)
1234279
def update_one(self, update):
        
        self.__bulk.add_update(self.__selector,
                               update, multi=False, upsert=True,
                               collation=self.__collation)
692742
def update_email_asset(self, asset_id, name, asset_type):
        
        self.update_asset('EMAIL', asset_id, name, asset_type)
153650
static function changeMIMEType( &$mimeInfo, $mimetype )
    {
        $mimeInfo['name'] = $mimetype;
        $newMimeInfo = eZMimeType::findByName( $mimetype );
        $mimeInfo['suffixes'] = $newMimeInfo['suffixes'];
        $mimeInfo['prefixes'] = $newMimeInfo['prefixes'];
        $mimeInfo['suffix'] = $newMimeInfo['suffix'];
        $mimeInfo['prefix'] = $newMimeInfo['prefix'];
        $filename = $mimeInfo['filename'];
        $dotPosition = strrpos( $filename, '.' );
        $basename = $filename;
        if ( $dotPosition !== false )
            $basename = substr( $filename, 0, $dotPosition );
        $mimeInfo['filename'] = $basename . '.' . $mimeInfo['suffix'];
        if ( $mimeInfo['dirpath'] )
            $mimeInfo['url'] = $mimeInfo['dirpath'] . '/' . $mimeInfo['filename'];
        else
            $mimeInfo['url'] = $mimeInfo['filename'];
    }
284775
def ref_for_message_type(self, message_type):
    
    name = self.__normalized_name(message_type)
    if name not in self.__schemas:
      raise KeyError('Message has not been parsed: %s', name)
    return name
707677
def target_mime_type
      mime = self.template.class.default_mime_type
      return mime if mime

      path = File.basename(self.source_path.to_s)
      mime = MIME::Types.type_for(path).first
      return mime.to_s if mime

      parts = File.basename(path).split(".")
      if parts.size > 2
        mime = MIME::Types.type_for(parts[0..-2].join(".")).first
        return mime.to_s if mime
      else
        nil
      end
    end
837503
public function setMimeType(string $mime_type)
    {
        if (!preg_match('/^[\w_-]+\/[\w_-]+$/', $mime_type))
            throw new \InvalidArgumentException("Not a valid mime type: $mime_type");
        $this->mime_type = $mime_type;
        return $this;
    }
69124
def set_highlighter(self, highlighter):
        

        if not issubclass(highlighter.__class__, QSyntaxHighlighter):
            raise foundations.exceptions.ProgrammingError("{0} | '{1}' is not a 'QSyntaxHighlighter' subclass!".format(
                self.__class__.__name__, highlighter))

        if self.__highlighter:
            self.remove_highlighter()

        LOGGER.debug("> Setting '{0}' highlighter.".format(highlighter))
        self.__highlighter = highlighter

        return True
1354372
def _set_serializer_by_mime_type(self, mime_type):
        

        # ignore if binary response
        if isinstance(self._app_iter, BinaryResponse):
            self.logger.info("ignoring setting serializer for binary response")
            return

        for available_serializer in self._serializers:
            if available_serializer.content_type() == mime_type:
                self._selected_serializer = available_serializer
                self.logger.info("set serializer for mime type: %s" % mime_type)
                return

        self.logger.info("could not find serializer for mime type: %s" % mime_type)
        raise exception.UnsupportedVocabularyError(mime_type, self.supported_mime_types_str)
1179466
def set_content_type (self):
        """"""
        if self.url:
            self.content_type = mimeutil.guess_mimetype(self.url, read=self.get_content)
        else:
            self.content_type = u""
101736
def buffer_typechecks(self, call_id, payload):
        """"""
        if self.currently_buffering_typechecks:
            for note in payload['notes']:
                self.buffered_notes.append(note)
228522
function Highlighter(doc, type) {
        type = type || "textContent";
        this.doc = doc || document;
        this.classAppliers = {};
        this.highlights = [];
        this.converter = getConverter(type);
    }
306425
def update_contents(self, contents, mime_type):
        """"""
        import hashlib
        import time

        new_size = len(contents)

        self.mime_type = mime_type

        if mime_type == 'text/plain':
            self.contents = contents.encode('utf-8')
        else:
            self.contents = contents

        old_hash = self.hash

        self.hash = hashlib.md5(self.contents).hexdigest()

        if self.size and (old_hash != self.hash):
            self.modified = int(time.time())

        self.size = new_size