mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 22:30:13 -06:00
Merge topic 'python-file-encoding'
b855674f5dTests: Always load presets schema as UTF-80de00b8b69Sphinx: Modernize UTF-8 encoding handling when updating CMake.qhpf0d6010cb5Sphinx: Specify encoding when opening files for title extraction Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8402
This commit is contained in:
@@ -4,13 +4,13 @@ import os.path
|
||||
import sys
|
||||
|
||||
|
||||
with open(sys.argv[1], "rb") as f:
|
||||
contents = json.loads(f.read().decode("utf-8-sig"))
|
||||
with open(sys.argv[1], "r", encoding="utf-8-sig") as f:
|
||||
contents = json.load(f)
|
||||
|
||||
schema_file = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"..", "..", "..", "Help", "manual", "presets", "schema.json")
|
||||
with open(schema_file) as f:
|
||||
with open(schema_file, "r", encoding="utf-8") as f:
|
||||
schema = json.load(f)
|
||||
|
||||
jsonschema.validate(contents, schema)
|
||||
|
||||
@@ -242,12 +242,13 @@ class CMakeTransform(Transform):
|
||||
The cmake --help-*-list commands also depend on this convention.
|
||||
Return the title or False if the document file does not exist.
|
||||
"""
|
||||
env = self.document.settings.env
|
||||
settings = self.document.settings
|
||||
env = settings.env
|
||||
title = self.titles.get(docname)
|
||||
if title is None:
|
||||
fname = os.path.join(env.srcdir, docname+'.rst')
|
||||
try:
|
||||
f = open(fname, 'r')
|
||||
f = open(fname, 'r', encoding=settings.input_encoding)
|
||||
except IOError:
|
||||
title = False
|
||||
else:
|
||||
|
||||
@@ -6,12 +6,12 @@ if len(sys.argv) != 2:
|
||||
sys.exit(-1)
|
||||
name = sys.argv[1] + "/CMake.qhp"
|
||||
|
||||
f = open(name, "rb")
|
||||
f = open(name, "r", encoding="utf-8")
|
||||
|
||||
if not f:
|
||||
sys.exit(-1)
|
||||
|
||||
lines = f.read().decode("utf-8").splitlines()
|
||||
lines = f.read().splitlines()
|
||||
|
||||
if not lines:
|
||||
sys.exit(-1)
|
||||
@@ -47,5 +47,5 @@ for line in lines:
|
||||
line = part1 + prefix + "id=\"" + domain_object_type + "/" + domain_object + "\" " + part2
|
||||
newlines.append(line + "\n")
|
||||
|
||||
f = open(name, "wb")
|
||||
f.writelines(map(lambda line: line.encode("utf-8"), newlines))
|
||||
f = open(name, "w", encoding="utf-8")
|
||||
f.writelines(newlines)
|
||||
|
||||
Reference in New Issue
Block a user