From: Michael Tremer Date: Thu, 24 Jul 2025 17:33:37 +0000 (+0000) Subject: importer: Fix SyntaxWarning about regular expressions X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;ds=sidebyside;p=people%2Fms%2Flibloc.git importer: Fix SyntaxWarning about regular expressions /usr/bin/location-importer:1654: SyntaxWarning: invalid escape sequence '\s' route = re.compile(b"^\s(.+?)\s+.+?\[(?:AS(.*?))?.\]$") /usr/bin/location-importer:1724: SyntaxWarning: invalid escape sequence '\s' m = re.match(b"\s+BGP\.as_path:.* (\d+) {\d+}$", line) Signed-off-by: Michael Tremer --- diff --git a/src/scripts/location-importer.in b/src/scripts/location-importer.in index 641aec2..4072784 100644 --- a/src/scripts/location-importer.in +++ b/src/scripts/location-importer.in @@ -1651,7 +1651,7 @@ class CLI(object): async def _handle_update_announcements_from_bird(self, server): # Pre-compile the regular expression for faster searching - route = re.compile(b"^\s(.+?)\s+.+?\[(?:AS(.*?))?.\]$") + route = re.compile(br"^\s(.+?)\s+.+?\[(?:AS(.*?))?.\]$") log.info("Requesting routing table from Bird (%s)" % server) @@ -1721,7 +1721,7 @@ class CLI(object): # Run "show route all" for each network for line in self._bird_cmd(server, "show route %s all" % network): # Try finding the path - m = re.match(b"\s+BGP\.as_path:.* (\d+) {\d+}$", line) + m = re.match(br"\s+BGP\.as_path:.* (\d+) {\d+}$", line) if m: # Select the last AS number in the path autnum = m.group(1).decode()