Skip to content

Commit

Permalink
Use raw strings for regular expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
AT0myks committed Dec 21, 2023
1 parent 9477a33 commit c0627fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions reolinkfw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
ROOTFS_SECTIONS = ("fs", "rootfs")
FS_SECTIONS = ROOTFS_SECTIONS + ("app",)

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

DUMMY = object()

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

Expand Down

0 comments on commit c0627fd

Please sign in to comment.