11"""Plugin builder"""
22
3+ import json
34from copy import deepcopy
45from pathlib import Path
56
6- from cppython .core .utility import read_json , write_json , write_model_json
77from cppython .plugins .cmake .schema import CMakePresets , CMakeSyncData , ConfigurePreset
88
99
@@ -23,7 +23,9 @@ def write_provider_preset(provider_directory: Path, data: CMakeSyncData) -> None
2323
2424 json_path = provider_directory / f'{ data .provider_name } .json'
2525
26- write_model_json (json_path , presets )
26+ serialized = json .loads (presets .model_dump_json (exclude_none = True , by_alias = False ))
27+ with open (json_path , 'w' , encoding = 'utf8' ) as file :
28+ json .dump (serialized , file , ensure_ascii = False , indent = 4 )
2729
2830 @staticmethod
2931 def write_cppython_preset (
@@ -42,7 +44,10 @@ def write_cppython_preset(
4244
4345 cppython_json_path = cppython_preset_directory / 'cppython.json'
4446
45- write_model_json (cppython_json_path , presets )
47+ serialized = json .loads (presets .model_dump_json (exclude_none = True , by_alias = False ))
48+ with open (cppython_json_path , 'w' , encoding = 'utf8' ) as file :
49+ json .dump (serialized , file , ensure_ascii = False , indent = 4 )
50+
4651 return cppython_json_path
4752
4853 @staticmethod
@@ -57,7 +62,9 @@ def write_root_presets(preset_file: Path, _: Path) -> None:
5762 Args:
5863 preset_file: Preset file to modify
5964 """
60- initial_root_preset = read_json (preset_file )
65+ with open (preset_file , encoding = 'utf-8' ) as file :
66+ initial_root_preset = json .load (file )
6167
6268 if (root_preset := deepcopy (initial_root_preset )) != initial_root_preset :
63- write_json (preset_file , root_preset )
69+ with open (preset_file , 'w' , encoding = 'utf-8' ) as file :
70+ json .dump (root_preset , file , ensure_ascii = False , indent = 4 )
0 commit comments