File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed
Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ def extract_services(input_dir: Path):
77 service_entries = []
88 for model_file in input_dir .glob ("*.json" ):
99 try :
10- with open (model_file , "r" ) as f :
10+ with open (model_file , "r" , encoding = "utf-8" ) as f :
1111 model_data = json .load (f )
1212
1313 shapes = model_data .get ("shapes" , model_data )
@@ -25,6 +25,18 @@ def extract_services(input_dir: Path):
2525 "servicename" : shape_name ,
2626 "protocol" : protocol
2727 })
28+ except json .JSONDecodeError as e :
29+ service_entries .append ({
30+ "filename" : model_file .name ,
31+ "servicename" : "ERROR" ,
32+ "protocol" : f"JSON decode error: { e } "
33+ })
34+ except UnicodeDecodeError as e :
35+ service_entries .append ({
36+ "filename" : model_file .name ,
37+ "servicename" : "ERROR" ,
38+ "protocol" : f"Encoding error: { e } "
39+ })
2840 except Exception as e :
2941 service_entries .append ({
3042 "filename" : model_file .name ,
Original file line number Diff line number Diff line change 1616def extract_services (input_dir : Path ):
1717 for model_file in input_dir .glob ("*.json" ):
1818 try :
19- with open (model_file , "r" ) as f :
19+ with open (model_file , "r" , encoding = "utf-8" ) as f :
2020 model_data = json .load (f )
2121
2222 shapes = model_data .get ("shapes" , model_data )
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ def process(model_entry):
4141
4242 model_path = Path (model_entry ['filepath' ])
4343
44- with open (model_path , "r" ) as f :
44+ with open (model_path , "r" , encoding = "utf-8" ) as f :
4545 model_data = json .load (f )
4646
4747 # Basic OpenAPI structure
You can’t perform that action at this time.
0 commit comments