Validate/return msg_filter from request (e.g. 'fuzzy', 'untranslated'),
        or a default.

        If a query is also specified in the request, then return None.
425894
def msg_filter(self):
        
        if self.query:
            msg_filter = None
        else:
            msg_filter = self._request_request('msg_filter', 'all')
            available_msg_filters = {'untranslated', 'translated', 'fuzzy', 'all'}
            if msg_filter not in available_msg_filters:
                msg_filter = 'all'
        return msg_filter
1113958
def _check_request(self, msg):
        
        if "jsonrpc" not in msg:
            raise InvalidRequestError("'\"jsonrpc\": \"2.0\"' must be included.")
        if msg["jsonrpc"] != "2.0":
            raise InvalidRequestError("'jsonrpc' must be exactly the string '2.0', but it was '{}'."
                                      .format(msg["jsonrpc"]))
        if "method" not in msg:
            raise InvalidRequestError("No method specified.")
        if "id" in msg:
            if msg["id"] is None:
                raise InvalidRequestError("typedjsonrpc does not allow id to be None.")
            if isinstance(msg["id"], float):
                raise InvalidRequestError("typedjsonrpc does not support float ids.")
            if not isinstance(msg["id"], (six.string_types, six.integer_types)):
                raise InvalidRequestError("id must be a string or integer; '{}' is of type {}."
                                          .format(msg["id"], type(msg["id"])))
        if msg["method"] not in self._name_to_method_info:
            raise MethodNotFoundError("Could not find method '{}'.".format(msg["method"]))
182095
def filter_query(filter_dict, required_keys):
    """"""
    if not isinstance(filter_dict, dict):
        raise TypeError("dict_list is not a list. Please try again")

    if not isinstance(required_keys, list):
        raise TypeError("dict_list is not a list. Please try again")

    available = []
    for k,v in filter_dict.items():
        # print(k, v)
        if k in required_keys:
            available.append(k)
    return available
922517
def queryset(self, request):
        
        qs = super(MultilingualInlineAdmin, self).queryset(request)
        # Don't now what the hell I was thinking here, but this code breaks stuff:
        #
        # checkfield = self.get_fill_check_field()
        # if checkfield is not None:
        #     kwargs = {str('%s_%s__isnull' % (checkfield, GLL.language_code)): False}
        #     from django.db.models.fields import CharField
        #     if isinstance(self.model._meta.translation_model._meta.get_field_by_name(checkfield)[0], CharField):
        #         kwargs[str('%s_%s__gt' % (checkfield, GLL.language_code))] = ''
        #     return qs.filter(**kwargs)
        return qs.filter(translations__language_code=GLL.language_code).distinct()
413682
def input(self, filter_fn, prompt):
        
        while True:
            try:
                return filter_fn(raw_input(prompt))
            except InvalidInputError as e:
                if e.message:
                    self.show('ERROR: ' + e.message)
            except KeyboardInterrupt:
                raise RejectWarning
364899
def filter_query_string(query):
    
    return '&'.join([q for q in query.split('&')
        if not (q.startswith('_k=') or q.startswith('_e=') or q.startswith('_s'))])
428901
def validate_query(self, using=None, **kwargs):
        
        return self._get_connection(using).indices.validate_query(index=self._name, **kwargs)
1137723
public String filter (String msg, Name otherUser, boolean outgoing)
    {
        // first, check against the drop-always list
        _stopMatcher.reset(msg);
        if (_stopMatcher.find()) {
            return null;
        }

        // then see what kind of curse filtering the user has configured
        Mode level = getFilterMode();
        if (level == Mode.UNFILTERED) {
            return msg;
        }

        StringBuffer inbuf = new StringBuffer(msg);
        StringBuffer outbuf = new StringBuffer(msg.length());
        for (int ii=0, nn=_matchers.length; ii < nn; ii++) {
            Matcher m = _matchers[ii];
            m.reset(inbuf);
            while (m.find()) {
                switch (level) {
                case DROP:
                    return null;

                case COMIC:
                    m.appendReplacement(outbuf,
                        _replacements[ii].replace(" ", comicChars(_comicLength[ii])));
                    break;

                case VERNACULAR:
                    String vernacular = _vernacular[ii];
                    if (Character.isUpperCase(m.group(2).codePointAt(0))) {
                        int firstCharLen = Character.charCount(vernacular.codePointAt(0));
                        vernacular = vernacular.substring(0, firstCharLen).toUpperCase() +
                                     vernacular.substring(firstCharLen);
                    }
                    m.appendReplacement(outbuf, _replacements[ii].replace(" ", vernacular));
                    break;

                case UNFILTERED:
                    // We returned the msg unadulterated above in this case, so it should be
                    // impossible to wind up here, but let's enumerate it so we can let the compiler
                    // scream about missing enum values in a switch
                    log.warning("Omg? We're trying to filter chat even though we're unfiltered?");
                    break;

                }
            }
            if (outbuf.length() == 0) {
                // optimization: if we didn't find a match, jump to the next
                // pattern without doing any StringBuilder jimmying
                continue;
            }
            m.appendTail(outbuf);

            // swap the buffers around and clear the output
            StringBuffer temp = inbuf;
            inbuf = outbuf;
            outbuf = temp;
            outbuf.setLength(0);
        }

        return inbuf.toString();
    }
1015699
def filter_query(self, query):
        

        for filter_class in list(self.filter_classes):
            query = filter_class().filter_query(self.request, query, self)

        return query
1345360
def _validate_open_params(**params):
        
        if not params['FilterQueryLanguage'] and params['FilterQuery']:
            raise CIMError(
                CIM_ERR_INVALID_PARAMETER,
                "FilterQuery without FilterQueryLanguage definition is "
                "invalid")
        if params['FilterQueryLanguage']:
            if params['FilterQueryLanguage'] != 'DMTF:FQL':
                raise CIMError(
                    CIM_ERR_QUERY_LANGUAGE_NOT_SUPPORTED,
                    _format("FilterQueryLanguage {0!A} not supported",
                            params['FilterQueryLanguage']))
        ot = params['OperationTimeout']
        if ot:
            if not isinstance(ot, six.integer_types) or ot < 0 \
                    or ot > OPEN_MAX_TIMEOUT:
                raise CIMError(
                    CIM_ERR_INVALID_PARAMETER,
                    _format("OperationTimeout {0!A }must be positive integer "
                            "less than {1!A}", ot, OPEN_MAX_TIMEOUT))
1167600
function (msg) {

                if (uri && (msg.getUriPath().indexOf(uri) != 0)) {
                    if (beVerbose) {
                        logger.log("uri filter did not match", uri, msg.getUriPath(), { coreID: that.getHexCoreID() });
                    }
                    return;
                }

                if (tokenHex && (tokenHex != msg.getTokenString())) {
                    if (beVerbose) {
                        logger.log("Tokens did not match ", tokenHex, msg.getTokenString(), { coreID: that.getHexCoreID() });
                    }
                    return;
                }

                if (once) {
                    that.removeListener(evtName, handler);
                }

                process.nextTick(function () {
                    try {
                        if (beVerbose) {
                            logger.log('heard ', name, { coreID: that.coreID });
                        }
                        callback(msg);
                    }
                    catch (ex) {
                        logger.error("listenFor - caught error: ", ex, ex.stack, { coreID: that.getHexCoreID() });
                    }
                });
            }
1038912
def _get_filter_ids(cls, request):
        
        id_query = request.url.query.get('id', None)

        if id_query is None:
            return None

        filter_ids = id_query.split(',')
        for filter_id in filter_ids:
            cls._validate_id(filter_id)

        return filter_ids
1322314
def _filter(msgdata, mailparser, mdfolder, mailfilters):
    """"""
    if mailfilters:
        for f in mailfilters:
            msg = mailparser.parse(StringIO(msgdata))
            rule = f(msg, folder=mdfolder)
            if rule:
                yield rule
    return
561214
def unpack(cls, msg, client, server, request_id):
        
        flags, = _UNPACK_INT(msg[:4])
        namespace, pos = _get_c_string(msg, 4)
        num_to_return, = _UNPACK_INT(msg[pos:pos + 4])
        pos += 4
        cursor_id, = _UNPACK_LONG(msg[pos:pos + 8])
        return OpGetMore(namespace=namespace, flags=flags, _client=client,
                         num_to_return=num_to_return, cursor_id=cursor_id,
                         request_id=request_id, _server=server)
1038098
async def _query_validator(self, request_type, response_proto,
                               payload, error_traps=None):
        
        LOGGER.debug(
            'Sending %s request to validator',
            self._get_type_name(request_type))

        payload_bytes = payload.SerializeToString()
        response = await self._send_request(request_type, payload_bytes)
        content = self._parse_response(response_proto, response)

        LOGGER.debug(
            'Received %s response from validator with status %s',
            self._get_type_name(response.message_type),
            self._get_status_name(response_proto, content.status))

        self._check_status_errors(response_proto, content, error_traps)
        return self._message_to_dict(content)
387547
def force_text(s, encoding='utf-8',  errors='strict'):
    
    if issubclass(type(s), str):
        return s
    try:
        if isinstance(s, bytes):
            s = str(s, encoding, errors)
        else:
            s = str(s)
    except UnicodeDecodeError as e:
        raise DjangoUnicodeDecodeError(s, *e.args)
    return s
793008
def make_filter(self, fieldname, query_func, expct_value):
        '''  '''

        def actual_filter(item):
            value = getattr(item, fieldname)

            if query_func in NULL_AFFECTED_FILTERS and value is None:
                return False

            if query_func == 'eq':
                return value == expct_value
            elif query_func == 'ne':
                return value != expct_value
            elif query_func == 'lt':
                return value < expct_value
            elif query_func == 'lte':
                return value <= expct_value
            elif query_func == 'gt':
                return value > expct_value
            elif query_func == 'gte':
                return value >= expct_value
            elif query_func == 'startswith':
                return value.startswith(expct_value)
            elif query_func == 'endswith':
                return value.endswith(expct_value)

        actual_filter.__doc__ = '{} {} {}'.format('val', query_func, expct_value)

        return actual_filter