Skip to content

Commit c0627fd

Browse files
committed
Use raw strings for regular expressions
1 parent 9477a33 commit c0627fd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

reolinkfw/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
ROOTFS_SECTIONS = ("fs", "rootfs")
6060
FS_SECTIONS = ROOTFS_SECTIONS + ("app",)
6161

62-
RE_BANNER = re.compile(b"\x00(Linux version .+? \(.+?@.+?\) \(.+?\) .+?)\n\x00")
63-
RE_COMPLINK = re.compile(b"\x00([^\x00]+?-linux-.+? \(.+?\) [0-9].+?)\n\x00+(.+?)\n\x00")
62+
RE_BANNER = re.compile(rb"\x00(Linux version .+? \(.+?@.+?\) \(.+?\) .+?)\n\x00")
63+
RE_COMPLINK = re.compile(rb"\x00([^\x00]+?-linux-.+? \(.+?\) [0-9].+?)\n\x00+(.+?)\n\x00")
6464
RE_IKCFG = re.compile(b"IKCFG_ST(.+?)IKCFG_ED", re.DOTALL)
6565
RE_KERNEL_COMP = re.compile(
6666
b"(?P<lz4>" + FileType.LZ4_LEGACY_FRAME.value + b')'
@@ -74,7 +74,7 @@
7474
# Type: kernel (0x02)
7575
# Only used for MStar/SigmaStar cameras (Lumus and RLC-410W IPC_30K128M4MP)
7676
RE_MSTAR = re.compile(FileType.UIMAGE.value + b".{24}\x11.\x02.{33}", re.DOTALL)
77-
RE_UBOOT = re.compile(b"U-Boot [0-9]{4}\.[0-9]{2}.*? \(.+?\)")
77+
RE_UBOOT = re.compile(rb"U-Boot [0-9]{4}\.[0-9]{2}.*? \(.+?\)")
7878

7979
DUMMY = object()
8080

@@ -446,7 +446,7 @@ def get_info_from_files(files: InfoFiles) -> DVRInfo:
446446
info["version_file"] = files["version_file"].decode().strip()
447447
if not info.get("firmware_version_prefix"):
448448
thefile = files["dvr"] if files["dvr"] is not None else files["router"]
449-
match = re.search(b"echo (v[23]\.0\.0)", thefile) if thefile is not None else None
449+
match = re.search(rb"echo (v[23]\.0\.0)", thefile) if thefile is not None else None
450450
info["firmware_version_prefix"] = match.group(1).decode() if match else None
451451
return info # type: ignore
452452

0 commit comments

Comments
 (0)