From 4f36fab55fe065e19b723d7cacf0d1dbf5fa9971 Mon Sep 17 00:00:00 2001 From: nucleogenic Date: Tue, 23 Aug 2022 03:24:08 +0100 Subject: [PATCH] Fix Python 3.7 compatibility (#800) --- python/common/src/util/unarchiver.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/common/src/util/unarchiver.py b/python/common/src/util/unarchiver.py index f2a94c0a..7bbb4b9a 100644 --- a/python/common/src/util/unarchiver.py +++ b/python/common/src/util/unarchiver.py @@ -79,7 +79,8 @@ def extract_archive(file_path, **kwargs): extracted_members = [] for line in lines[1:-1]: - if line_matches := match(unar_file_extracted, line): + line_matches = match(unar_file_extracted, line) + if line_matches: matches = line_matches.groupdict() member = { "name": str(pathlib.PurePath(matches["path"]).name), @@ -90,7 +91,11 @@ def extract_archive(file_path, **kwargs): "absolute_path": str(pathlib.PurePath(tmp_dir).joinpath(matches["path"])), } - member_types = matches.get("types", "").removeprefix(", ").split(", ") + member_types = matches.get("types", "") + if member_types.startswith(", "): + member_types = member_types[2:].split(", ") + else: + member_types = member_types.split(", ") if "dir" in member_types: member["is_dir"] = True