aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Herrmann <adrian.herrmann@qt.io>2022-09-27 20:31:51 +0200
committerAdrian Herrmann <adrian.herrmann@qt.io>2022-09-29 16:19:16 +0000
commit81d81baf0ef6c42ebdb6a2b2293d09031ce6dd5c (patch)
tree9039f695c13364db032384fb97168b1c4b631ac8
parent92943cbb530edb4fd8b7292b3b0ea964d7a6fdde (diff)
example_gallery: Switch to UTF-8 encoding
Switch the encoding when reading example-related files (code, rst, pyproject etc.) to UTF-8 to enable special characters and 😊. Pick-to: 6.3 Change-Id: I6737875bc9b64d069b8adc478912f4ab4567e28e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--tools/example_gallery/main.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/example_gallery/main.py b/tools/example_gallery/main.py
index 7f51e8b3c..9768fba4f 100644
--- a/tools/example_gallery/main.py
+++ b/tools/example_gallery/main.py
@@ -133,7 +133,7 @@ def get_code_tabs(files, project_dir):
_path = project_dir / project_file
_file_content = ""
try:
- with open(_path, "r") as _f:
+ with open(_path, "r", encoding="utf-8") as _f:
_file_content = remove_licenses(_f.read())
except UnicodeDecodeError as e:
print(f"example_gallery: error decoding {project_dir}/{_path}:{e}",
@@ -246,7 +246,7 @@ if __name__ == "__main__":
files = []
try:
- with pyproject_file.open("r") as pyf:
+ with pyproject_file.open("r", encoding="utf-8") as pyf:
pyproject = json.load(pyf)
files = pyproject["files"]
except (json.JSONDecodeError, KeyError) as e:
@@ -256,11 +256,11 @@ if __name__ == "__main__":
if files:
rst_file_full = EXAMPLES_DOC / rst_file
- with open(rst_file_full, "w") as out_f:
+ with open(rst_file_full, "w", encoding="utf-8") as out_f:
if has_doc:
doc_rst = original_doc_dir / f"{example_name}.rst"
- with open(doc_rst) as doc_f:
+ with open(doc_rst, encoding="utf-8") as doc_f:
content_f = doc_f.read()
# Copy other files in the 'doc' directory, but