does Message message match against the specified rule.
351258
def matches_rule(message, rule, destinations = None) :
    ""
    if not isinstance(message, Message) :
        raise TypeError("message must be a Message")
    #end if
    rule = unformat_rule(rule)
    eavesdrop = rule.get("eavesdrop", "false") == "true"

    def match_message_type(expect, actual) :
        return \
            actual == Message.type_from_string(expect)
    #end match_message_type

    def match_path_namespace(expect, actual) :
        return \
            (
                actual != None
            and
                (
                    expect == actual
                or
                    actual.startswith(expect) and (expect == "/" or actual[len(expect)] == "/")
                )
            )
    #end match_path_namespace

    def match_dotted_namespace(expect, actual) :
        return \
            (
                actual != None
            and
                (
                    expect == actual
                or
                    actual.startswith(expect) and actual[len(expect)] == "."
                )
            )
    #end match_dotted_namespace

    def get_nth_arg(msg, n, expect_types) :
        msg_signature = parse_signature(msg.signature)
        if n >= len(msg_signature) :
            raise IndexError("arg nr %d beyond nr args %d" % (n, len(msg_signature)))
        #end if
        val = msg.all_objects[n]
        valtype = msg_signature[n]
        if valtype not in expect_types :
            if False :
                raise TypeError \
                  (
                        "expecting one of types %s, not %s for arg %d val %s"
                    %
                        ((repr(expect_types), repr(valtype), n, repr(val)))
                  )
            #end if
            val = None # never match
        #end if
        return \
            val
    #end get_nth_arg

    def get_arg_0_str(message) :
        return \
            get_nth_arg(message, 0, [BasicType(TYPE.STRING)])
    #end get_arg_0_str

    def match_arg_paths(expect, actual) :
        return \
            (
                actual != None
            and
                (
                    expect == actual
                or
                    expect.endswith("/") and actual.startswith(expect)
                or
                    actual.endswith("/") and expect.startswith(actual)
                )
            )
    #end match_arg_paths

    match_types = \
        ( # note that message attribute value of None will fail to match
          # any expected string value, which is exactly what we want
            ("type", None, match_message_type, None),
            ("sender", None, operator.eq, None),
            ("interface", None, operator.eq, None),
            ("member", None, operator.eq, None),
            ("path", None, operator.eq, None),
            ("destination", None, operator.eq, None),
            ("path_namespace", "path", match_path_namespace, None),
            ("arg0namespace", None, match_dotted_namespace, get_arg_0_str),
            # “arg«n»path” handled specially below
        )

#begin matches_rule
    keys_used = set(rule.keys()) - {"eavesdrop"}
    matches = \
        (
            eavesdrop
        or
            destinations == None
        or
            message.destination == None
        or
            message.destination in destinations
        )
    if matches :
        try_matching = iter(match_types)
        while True :
            try_rule = next(try_matching, None)
            if try_rule == None :
                break
            rulekey, attrname, action, accessor = try_rule
            if attrname == None :
                attrname = rulekey
            #end if
            if rulekey in rule :
                if accessor != None :
                    val = accessor(message)
                else :
                    val = getattr(message, attrname)
                #end if
                keys_used.remove(rulekey)
                if not action(rule[rulekey], val) :
                    matches = False
                    break
                #end if
            #end if
        #end while
    #end if
    if matches :
        try_matching = iter(rule.keys())
        while True :
            try_key = next(try_matching, None)
            if try_key == None :
                break
            if try_key.startswith("arg") and not try_key.endswith("namespace") :
                argnr = try_key[3:]
                is_path = argnr.endswith("path")
                if is_path :
                    argnr = argnr[:-4]
                #end if
                argnr = int(argnr)
                if not (0 <= argnr < 64) :
                    raise ValueError("argnr %d out of range" % argnr)
                #end if
                argval = get_nth_arg \
                  (
                    message,
                    argnr,
                    [BasicType(TYPE.STRING)] + ([], [BasicType(TYPE.OBJECT_PATH)])[is_path]
                  )
                keys_used.remove(try_key)
                if not (operator.eq, match_arg_paths)[is_path](rule[try_key], argval) :
                    matches = False
                    break
                #end if
            #end if
        #end while
    #end if
    if matches and len(keys_used) != 0 :
        # fixme: not checking for unrecognized rule keys if I didn’t try matching them all
        raise KeyError("unrecognized rule keywords: %s" % ", ".join(sorted(keys_used)))
    #end if
    return \
        matches
134719
public List<Stream> match(Message message) {
        final Set<Stream> result = Sets.newHashSet();
        final Set<Stream> blackList = Sets.newHashSet();

        for (final Rule rule : rulesList) {
            if (blackList.contains(rule.getStream())) {
                continue;
            }

            final StreamRule streamRule = rule.getStreamRule();
            final StreamRuleType streamRuleType = streamRule.getType();
            final Stream.MatchingType matchingType = rule.getMatchingType();
            if (!ruleTypesNotNeedingFieldPresence.contains(streamRuleType)
                && !message.hasField(streamRule.getField())) {
                if (matchingType == Stream.MatchingType.AND) {
                    result.remove(rule.getStream());
                    // blacklist stream because it can't match anymore
                    blackList.add(rule.getStream());
                }

                continue;
            }

            final Stream stream;
            if (streamRuleType != StreamRuleType.REGEX) {
                stream = rule.match(message);
            } else {
                stream = rule.matchWithTimeOut(message, streamProcessingTimeout, TimeUnit.MILLISECONDS);
            }

            if (stream == null) {
                if (matchingType == Stream.MatchingType.AND) {
                    result.remove(rule.getStream());
                    // blacklist stream because it can't match anymore
                    blackList.add(rule.getStream());
                }
            } else {
                result.add(stream);
                if (matchingType == Stream.MatchingType.OR) {
                    // blacklist stream because it is already matched
                    blackList.add(rule.getStream());
                }
            }
        }

        final Stream defaultStream = defaultStreamProvider.get();
        boolean alreadyRemovedDefaultStream = false;
        for (Stream stream : result) {
            streamMetrics.markIncomingMeter(stream.getId());
            if (stream.getRemoveMatchesFromDefaultStream()) {
                if (alreadyRemovedDefaultStream || message.removeStream(defaultStream)) {
                    alreadyRemovedDefaultStream = true;
                    if (LOG.isTraceEnabled()) {
                        LOG.trace("Successfully removed default stream <{}> from message <{}>", defaultStream.getId(), message.getId());
                    }
                } else {
                    if (LOG.isWarnEnabled()) {
                        LOG.warn("Couldn't remove default stream <{}> from message <{}>", defaultStream.getId(), message.getId());
                    }
                }
            }
        }
        // either the message stayed on the default stream, in which case we mark that stream's throughput,
        // or someone removed it, in which case we don't mark it.
        if (!alreadyRemovedDefaultStream) {
            streamMetrics.markIncomingMeter(defaultStream.getId());
        }

        return ImmutableList.copyOf(result);
    }
377869
def is_outbound_message_filter(cb):
    

    try:
        handlers = get_magic_attr(cb)
    except AttributeError:
        return False

    hs = HandlerSpec(
        (_apply_outbound_message_filter, ())
    )

    return hs in handlers
541936
public boolean isFilterMatch(BaseMessageHeader messageHeader)
    {
        boolean bMatch = true;
        if (messageHeader != null)
        {
            if (this.getQueueName() != null)
                if (!this.getQueueName().equals(messageHeader.getQueueName()))
                    return false;   // No match
            if (this.getQueueType() != null)
                if (!this.getQueueType().equals(messageHeader.getQueueType()))
                    return false;   // No match
            if (this.getMessageSource() != null)
                if (this.getMessageSource() == messageHeader.getMessageSource())
                    return false;   // If the source codes are the same object, don't echo!
            Object[][] mxMessageHeader = messageHeader.getNameValueTree();
            Object[][] mxMessageFilter = this.getNameValueTree();
            bMatch = this.compareTrees(mxMessageHeader, mxMessageFilter, false);
            if (bMatch)
                if (messageHeader.getRegistryIDMatch() != null)
                    if (!messageHeader.getRegistryIDMatch().equals(this.getRegistryID()))
                        bMatch = false;
        }
        return bMatch;    // MATCH!!!
    }
425116
function Message($, rule_id, options) {

    var rule = new ruleValidator($, rule_id, options),
        message = '';

    if ( typeof rule.valid === 'boolean' && !rule.valid ) {
        message = typeof rule.rule.message == 'function' ? rule.rule.message(options) : rule.rule.message;
    }

    this.text = message;
}
623499
public function matches(MessageReceived $message): bool
    {
        return $message->getData() ? hash_equals($this->value, $message->getData()) : false;
    }
187240
private function validateAgainstExpression( $field, $value, $rule, $message = null )
    {
        if (preg_match($this->expressions[ $rule ], $value)) {
            return true;
        }

        if (!$message) {
            $message = $this->error_messages[ $rule ];
        }

        static::$errors[ $field ] = $message;

        return false;
    }
502465
boolean containsRule( Rule rule ) {
        for( int i = state.stackIdx - 1; i >= 0; i-- ) {
            if( rule == state.stack.get( i ).mixin ) {
                return true;
            }
        }
        return false;
    }
1002421
function verify(postedMessage) {
		if (
			// Check incoming message is valid
			typeof postedMessage === 'object' &&
			typeof postedMessage.uuid === 'string' &&
			postedMessage._respondable === true
		) {
			var messageSource = _getSource();
			return (
				// Check the version matches
				postedMessage._source === messageSource ||
				// Allow free communication with axe test
				postedMessage._source === 'axeAPI.x.y.z' ||
				messageSource === 'axeAPI.x.y.z'
			);
		}
		return false;
	}
545948
def _check_message_valid(msg):
    """"""
    try:
        if int(msg[:2], 16) != (len(msg) - 2):
            raise ValueError("Elk message length incorrect")
        _check_checksum(msg)
    except IndexError:
        raise ValueError("Elk message length incorrect")
575439
def match(self, user, message):
        
        self._log.info('Attempting to match message against Pattern: {pattern}'
                       .format(pattern=self.pattern.pattern if hasattr(self.pattern, 'pattern') else self.pattern))
        self.user = user

        # Make sure the topic matches (if one is defined)
        if user.topic != self.topic:
            self._log.debug('User topic "{u_topic}" does not match Trigger topic "{t_topic}", skipping check'
                            .format(u_topic=user.topic, t_topic=self.topic))
            return

        def get_response():
            # Does the user have a limit for this response enforced?
            if user.is_limited(self):
                if self.ulimit_blocking:
                    self._log.debug('An active blocking limit for this trigger is being enforced against the user '
                                    '{uid}, no trigger will be matched'.format(uid=user.id))
                    raise LimitError

                self._log.debug('An active limit for this response is being enforced against the user {uid}, '
                                'skipping'.format(uid=user.id))
                return ''

            # Is there a global limit for this response enforced?
            if self.agentml.is_limited(self):
                if self.glimit_blocking:
                    self._log.debug('An active blocking limit for this trigger is being enforced globally, no trigger '
                                    'will be matched')
                    raise LimitError

                self._log.debug('An active limit for this response is being enforced against the user {uid}, '
                                'skipping'.format(uid=user.id))
                return ''

            # Chance testing
            if self.chance is not None and self.chance != 100:
                # Chance succeeded
                if self.chance >= random.uniform(0, 100):
                    self._log.info('Trigger had a {chance}% chance of being selected and succeeded selection'
                                   .format(chance=self.chance))
                # Chance failed
                else:
                    if self.chance_blocking:
                        self._log.info('Trigger had a blocking {chance}% chance of being selected but failed selection'
                                       ', no trigger will be matched'.format(chance=self.chance))
                        raise ChanceError

                    self._log.info('Response had a {chance}% chance of being selected but failed selection'
                                   .format(chance=self.chance))
                    return ''

            random_response = self._responses.random(user)
            if not random_response and self.blocking:
                self._log.info('Trigger was matched, but there are no available responses and the trigger is blocking '
                               'any further attempts. Giving up')
                raise ParserBlockingError

            if random_response:
                self.apply_reactions(user)
            else:
                self._log.info('Trigger was matched, but there are no available responses')
                random_response = ''

            return random_response

        # String match
        if isinstance(self.pattern, string_types) and str(message) == self.pattern:
            self._log.info('String Pattern matched: {match}'.format(match=self.pattern))
            return get_response()

        # Regular expression match
        if hasattr(self.pattern, 'match'):
            match = self.pattern.match(str(message))
            if match:
                self._log.info('Regex pattern matched: {match}'.format(match=self.pattern.pattern))

                # Parse pattern wildcards
                self.stars['normalized'] = match.groups()
                for message_format in [message.CASE_PRESERVED, message.RAW]:
                    message.format = message_format
                    format_match = self.pattern.match(str(message))
                    if format_match:
                        self.stars[message_format] = format_match.groups()

                self._log.debug('Assigning pattern wildcards: {stars}'.format(stars=str(self.stars)))
                return get_response()
109427
def find_matching(cls, message, channel):
		
		return (
			handler
			for handler in cls._registry
			if isinstance(handler, cls)
			and handler.match(message, channel)
		)
909333
def match(msg)
      if @type
        if { Message::SIGNAL => "signal", Message::METHOD_CALL => "method_call",
             Message::METHOD_RETURN => "method_return",
             Message::ERROR => "error" }[msg.message_type] != @type
          return false
        end
      end
      return false if @interface && @interface != msg.interface
      return false if @member && @member != msg.member
      return false if @path && @path != msg.path
      # FIXME: sender and destination are ignored
      true
    end
140258
def matches(self, a, b, **config):
        
        submitter_a = a['msg']['override']['submitter']['name']
        submitter_b = b['msg']['override']['submitter']['name']
        if submitter_a != submitter_b:
            return False
        return True
49273
public boolean sendToMatching(Msg msg)
    {
        //  Is this end of a multipart message?
        boolean msgMore = msg.hasMore();

        //  Push the message to matching pipes.
        distribute(msg);

        //  If mutlipart message is fully sent, activate all the eligible pipes.
        if (!msgMore) {
            active = eligible;
        }

        more = msgMore;

        return true;
    }
518440
def verifymessage(self, address, signature, message):
        """"""
        return self.req("verifymessage", [address, signature, message])
1225425
def matches_all_rules(self, target_filename):
        

        for rule in self.match_rules:
            if rule.test(target_filename) is False:
                return False

        self.logger.debug('{0}: {1} - {2}'.format(self.name,
                                                  os.path.basename(target_filename),
                                                  'Match'))
        return True