From 23377784ee8248fb3f4b122bbc82e8fb74a9fea8 Mon Sep 17 00:00:00 2001 From: Willi Date: Thu, 5 Dec 2024 14:21:55 +0100 Subject: [PATCH] Force utf-8 for json encoding --- arlas/cli/model_infering.py | 2 +- arlas/cli/service.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arlas/cli/model_infering.py b/arlas/cli/model_infering.py index 3480df6..6c8231d 100644 --- a/arlas/cli/model_infering.py +++ b/arlas/cli/model_infering.py @@ -171,7 +171,7 @@ def make_mapping(file: str, nb_lines: int = 2, types: dict[str, str] = {}, no_fu no_index: list[str] = []): tree = {} mapping = {} - with open(file) as f: + with open(file, mode="r", encoding="utf-8") as f: i = 0 for line in f: if i > nb_lines: diff --git a/arlas/cli/service.py b/arlas/cli/service.py index 92b4887..af09df7 100644 --- a/arlas/cli/service.py +++ b/arlas/cli/service.py @@ -328,7 +328,7 @@ def count_collection(arlas: str, collection: str) -> list[list[str]]: def count_hits(file_path: str) -> int: line_number = 0 - with open(file_path) as f: + with open(file_path, mode="r", encoding="utf-8") as f: for line in f: line_number = line_number + 1 return line_number @@ -388,7 +388,7 @@ def index_hits(arlas: str, index: str, file_path: str, bulk_size: int = 5000, co line_number = 0 line_in_bulk = 0 bulk = [] - with open(file_path) as f: + with open(file_path, mode="r", encoding="utf-8") as f: with alive_bar(count) as bar: for line in f: line_number = line_number + 1