]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
importer: Fix SyntaxWarning about regular expressions master
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 24 Jul 2025 17:33:37 +0000 (17:33 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 24 Jul 2025 17:33:37 +0000 (17:33 +0000)
/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 <michael.tremer@ipfire.org>
src/scripts/location-importer.in

index 641aec2d44435c53bd6c8ad9d4dd5cf918d15687..407278417f4d7ea1486cacac63daf85907311eb5 100644 (file)
@@ -1651,7 +1651,7 @@ class CLI(object):
 
        async def _handle_update_announcements_from_bird(self, server):
                # Pre-compile the regular expression for faster searching
 
        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)
 
 
                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
                        # 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()
                                if m:
                                        # Select the last AS number in the path
                                        autnum = m.group(1).decode()