Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions utils/codegen/generate-config-info.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ def generate(config, output_dir, source_mrdocs_dir):
# metadata the header carries, so there are no longer any generated
# ConfigSchema.cpp or PublicToolArgs sources.
config_schema_hpp = generate_config_schema_hpp(config)
with open(os.path.join(mrdocs_build_include_dir, 'ConfigSchema.hpp'), 'w') as f:
with open(os.path.join(mrdocs_build_include_dir, 'ConfigSchema.hpp'), 'w', encoding='utf-8') as f:
f.write(config_schema_hpp)


Expand All @@ -963,7 +963,7 @@ def main():
sys.exit(1)

# parse input file
with open(input_file, 'r') as f:
with open(input_file, 'r', encoding='utf-8') as f:
config = json.load(f)

generate(config, output_dir, os.path.dirname(os.path.abspath(input_file)))
Expand Down
6 changes: 3 additions & 3 deletions utils/codegen/generate-version-header.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def main():
}

content = ''
with open(args.template, "r") as f:
with open(args.template, "r", encoding="utf-8") as f:
content = f.read()
for name, value in substitutions.items():
content = content.replace(f"@{name}@", value)
Expand All @@ -166,12 +166,12 @@ def main():
# file (and never triggers a rebuild of everything that includes it).
previous = None
if os.path.exists(args.output):
with open(args.output, "r") as f:
with open(args.output, "r", encoding="utf-8") as f:
previous = f.read()
if content != previous:
if os.path.dirname(args.output):
os.makedirs(os.path.dirname(args.output), exist_ok=True)
with open(args.output, "w") as f:
with open(args.output, "w", encoding="utf-8") as f:
f.write(content)


Expand Down
6 changes: 3 additions & 3 deletions utils/codegen/generate-yaml-schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ def main():

# Generate the schema
mrdocs_config_path = os.path.join(mrdocs_root_dir, 'src', 'mrdocs', 'ConfigOptions.json')
with open(mrdocs_config_path, 'r') as f:
with open(mrdocs_config_path, 'r', encoding='utf-8') as f:
config = json.loads(f.read())
yaml_schema = generate_yaml_schema(config)

if args.check:
# Check if the generated schema matches the existing schema
with open(mrdocs_schema_path, 'r') as f:
with open(mrdocs_schema_path, 'r', encoding='utf-8') as f:
existing_schema = f.read()
if yaml_schema != existing_schema:
print(
Expand All @@ -190,7 +190,7 @@ def main():
print("The generated schema matches the existing schema.")
else:
# Write the schema to the file
with open(mrdocs_schema_path, 'w') as f:
with open(mrdocs_schema_path, 'w', encoding='utf-8', newline='\n') as f:
f.write(yaml_schema)


Expand Down
2 changes: 1 addition & 1 deletion utils/codegen/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def GenerateIndexedCppFiles(parentDirectory, fileContents):
for index, aDeclaration in enumerate(contents):
fileName = name_fmt.format(index)
filePath = os.path.join(parentDirectory, fileName)
with open(filePath, "w") as f:
with open(filePath, "w", encoding="utf-8") as f:
f.write(aDeclaration)


Expand Down
Loading