From 1891e021306a9a1f8fedc578e6477ce4282ba1d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20=C5=A0tetiar?= Date: Sun, 13 Sep 2020 10:46:20 +0200 Subject: [PATCH] collect.py: fix scan method file content decoding MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes following error: File "misc/collect.py", line 54, in merge_profiles obj = json.loads(content.decode("utf-8")) AttributeError: 'str' object has no attribute 'decode' Signed-off-by: Petr Å tetiar --- misc/collect.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/misc/collect.py b/misc/collect.py index e22d419..60d863c 100755 --- a/misc/collect.py +++ b/misc/collect.py @@ -50,7 +50,7 @@ def merge_profiles(profiles, download_url): output["models"][title]["code"] = code for path, content in profiles.items(): - obj = json.loads(content.decode("utf-8")) + obj = json.loads(content) if obj["metadata_version"] != SUPPORTED_METADATA_VERSION: sys.stderr.write( @@ -114,7 +114,9 @@ def scrape(args): array = json.loads(file.read().decode("utf-8")) for profile in filter(lambda x: x.endswith("/profiles.json"), array): with urllib.request.urlopen("{}/{}".format(target, profile)) as file: - profiles["{}/{}".format(target, profile)] = file.read() + profiles["{}/{}".format(target, profile)] = file.read().decode( + "utf-8" + ) return profiles if not os.path.isfile(config_path): @@ -257,7 +259,7 @@ def scan(args): profiles = {} for ppath in Path(path).rglob("profiles.json"): - with open(ppath, "r") as file: + with open(ppath, "r", encoding="utf-8") as file: profiles[ppath] = file.read() if len(profiles) == 0: -- 2.30.2