From: Petr Štetiar Date: Sun, 13 Sep 2020 08:46:20 +0000 (+0200) Subject: collect.py: fix scan method file content decoding X-Git-Tag: v3.0.0~15 X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=1891e021306a9a1f8fedc578e6477ce4282ba1d2;hp=7297db81ba0a559457ff3e32157fc4c342528f53;p=web%2Ffirmware-selector-openwrt-org.git collect.py: fix scan method file content decoding 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 --- 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: