INNER CODE UNIT · Python

_matches_command_template

unrealcv/unrealcv · client/python/unrealcv/__init__.py:182

    def _matches_command_template(cls, command, template):
        command = cls._normalize_command_whitespace(command)
        template = cls._normalize_command_whitespace(template)
        if not command or not template:
            return False

        pattern_parts = []
        position = 0
        for placeholder in re.finditer(r'\[[^\[\]]+\]', template):
            literal = template[position : placeholder.start()]
            pattern_parts.append(re.escape(literal).replace(r'\ ', r'\s+'))
            pattern_parts.append(r'\S*')
            position = placeholder.end()
        literal = template[position:]
        pattern_parts.append(re.escape(literal).replace(r'\ ', r'\s+'))
        return re.fullmatch(''.join(pattern_parts), command) is not None

    def _warn_if_command_maybe_unsupported(self, message):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…