From b6929c9453c2a9152e6ce279192404f418b1c8e0 Mon Sep 17 00:00:00 2001 From: dece Date: Wed, 8 Jun 2022 17:12:33 +0200 Subject: [PATCH] plugins: stop using match as name In Python 3.10 match will become a soft keyword. The program would still work but syntax highlighting is getting weird. --- edmond/plugin.py | 18 +++++++++--------- edmond/plugins/capture_give.py | 8 ++++---- edmond/plugins/notes.py | 8 ++++---- edmond/plugins/youtube_parser.py | 10 +++++----- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/edmond/plugin.py b/edmond/plugin.py index 92c06d6..82760dc 100644 --- a/edmond/plugin.py +++ b/edmond/plugin.py @@ -183,8 +183,8 @@ class Plugin: return True return False - def __save_question(self, question, match, preamble): - content = question[len(match):].strip() + def __save_question(self, question, matched, preamble): + content = question[len(matched):].strip() content = content.rstrip("?").rstrip() question = Question(preamble, content) self.question = question @@ -228,23 +228,23 @@ class Plugin: # If no_content is False (default), simply compare the parsed # identifier with available identifiers. if no_content: - match = lambda pc, ai: ( + matches = lambda pc, ai: ( pc.raw == ai or pc.raw.startswith(ai + " ") ) else: - match = lambda pc, ai: pc.ident == ai + matches = lambda pc, ai: pc.ident == ai # First case: the command identifier has been used. - if match(parsed_command, ident): + if matches(parsed_command, ident): parsed_command.ident = ident - parsed_command.match = ident + parsed_command.matched = ident self.__save_command(parsed_command) return True # Second case: an alias of the identifier has been used. ident_aliases = aliases.get(ident, []) for alias in ident_aliases: - if match(parsed_command, alias): + if matches(parsed_command, alias): parsed_command.ident = ident - parsed_command.match = alias + parsed_command.matched = alias self.__save_command(parsed_command) return True return False @@ -313,4 +313,4 @@ class Command: # Raw command content (minus name and suffix), always set. raw: str # Identifier matched, possibly an alias. Set only when matched. - match: str = "" + matched: str = "" diff --git a/edmond/plugins/capture_give.py b/edmond/plugins/capture_give.py index f1d86dd..a82772c 100644 --- a/edmond/plugins/capture_give.py +++ b/edmond/plugins/capture_give.py @@ -29,11 +29,11 @@ class CaptureGivePlugin(Plugin): # "give" command. if self.command.ident == self.config["commands"][0]: - content = self.command.raw[len(self.command.match):].strip() - match = self.content_re.match(content) - if not match: + content = self.command.raw[len(self.command.matched):].strip() + matched = self.content_re.matched(content) + if not matched: return False - groups = match.groupdict() + groups = matched.groupdict() if any(k not in groups for k in ("thing", "person")): return False thing = groups["thing"] diff --git a/edmond/plugins/notes.py b/edmond/plugins/notes.py index 878b0fe..56a98a0 100644 --- a/edmond/plugins/notes.py +++ b/edmond/plugins/notes.py @@ -32,11 +32,11 @@ class NotesPlugin(Plugin): # "note down" command. if self.command.ident == self.config["commands"][0]: - content = self.command.raw[len(self.command.match):].strip() - match = self.content_re.match(content) - if not match: + content = self.command.raw[len(self.command.matched):].strip() + matched = self.content_re.match(content) + if not matched: return False - groups = match.groupdict() + groups = matched.groupdict() if any(k not in groups for k in ("target", "note")): return False target = groups["target"] diff --git a/edmond/plugins/youtube_parser.py b/edmond/plugins/youtube_parser.py index a5b3a05..4f9aafe 100644 --- a/edmond/plugins/youtube_parser.py +++ b/edmond/plugins/youtube_parser.py @@ -37,13 +37,13 @@ class YoutubeParserPlugin(Plugin): return False words = event.arguments[0].split() for word in words: - match = self.VIDEO_URL_RE.match(word) - if match: - return self.handle_match(match, event.target) + matched = self.VIDEO_URL_RE.match(word) + if matched: + return self.handle_match(matched, event.target) return False - def handle_match(self, match, target): - groupdict = match.groupdict() + def handle_match(self, matched, target): + groupdict = matched.groupdict() code = groupdict.get("code1") or groupdict.get("code2") if not code: return False