21
21
from re import compile as re_compile
22
22
from shutil import copy2 as shutil_copy2
23
23
from shutil import copytree as shutil_copytree
24
- from typing import Any , Dict , List , Tuple
24
+ from typing import Any
25
25
from zipfile import ZipFile
26
26
27
27
from requests import get as requests_get
@@ -82,16 +82,16 @@ class LocalFilesystem(VehicleComponents, ConfigurationSteps, ProgramSettings):
82
82
"""
83
83
84
84
def __init__ (self , vehicle_dir : str , vehicle_type : str , fw_version : str , allow_editing_template_files : bool ):
85
- self .file_parameters : Dict [str , Dict [str , Par ]] = {}
85
+ self .file_parameters : dict [str , dict [str , Par ]] = {}
86
86
VehicleComponents .__init__ (self )
87
87
ConfigurationSteps .__init__ (self , vehicle_dir , vehicle_type )
88
88
ProgramSettings .__init__ (self )
89
89
self .vehicle_type = vehicle_type
90
90
self .fw_version = fw_version
91
91
self .allow_editing_template_files = allow_editing_template_files
92
- self .param_default_dict : Dict [str , Par ] = {}
92
+ self .param_default_dict : dict [str , Par ] = {}
93
93
self .vehicle_dir = vehicle_dir
94
- self .doc_dict : Dict [str , Any ] = {}
94
+ self .doc_dict : dict [str , Any ] = {}
95
95
if vehicle_dir is not None :
96
96
self .re_init (vehicle_dir , vehicle_type )
97
97
@@ -215,7 +215,7 @@ def __extend_and_reformat_parameter_documentation_metadata(self): # pylint: dis
215
215
prefix_parts += [f"Default: { default_value } " ]
216
216
param_info ["doc_tooltip" ] = ("\n " ).join (prefix_parts )
217
217
218
- def read_params_from_files (self ) -> Dict [str , Dict [str , "Par" ]]:
218
+ def read_params_from_files (self ) -> dict [str , dict [str , "Par" ]]:
219
219
"""
220
220
Reads intermediate parameter files from a directory and stores their contents in a dictionary.
221
221
@@ -227,7 +227,7 @@ def read_params_from_files(self) -> Dict[str, Dict[str, "Par"]]:
227
227
- Dict[str, Dict[str, 'Par']]: A dictionary with filenames as keys and as values
228
228
a dictionary with (parameter names, values) pairs.
229
229
"""
230
- parameters : Dict [str , Dict [str , Par ]] = {}
230
+ parameters : dict [str , dict [str , Par ]] = {}
231
231
if os_path .isdir (self .vehicle_dir ):
232
232
# Regular expression pattern for filenames starting with two digits followed by an underscore and ending in .param
233
233
pattern = re_compile (r"^\d{2}_.*\.param$" )
@@ -261,7 +261,7 @@ def str_to_bool(s):
261
261
return False
262
262
return None
263
263
264
- def export_to_param (self , params : Dict [str , "Par" ], filename_out : str , annotate_doc : bool = True ) -> None :
264
+ def export_to_param (self , params : dict [str , "Par" ], filename_out : str , annotate_doc : bool = True ) -> None :
265
265
"""
266
266
Exports a dictionary of parameters to a .param file and optionally annotates the documentation.
267
267
@@ -293,7 +293,7 @@ def vehicle_configuration_file_exists(self, filename: str) -> bool:
293
293
os_path .join (self .vehicle_dir , filename )
294
294
)
295
295
296
- def __all_intermediate_parameter_file_comments (self ) -> Dict [str , str ]:
296
+ def __all_intermediate_parameter_file_comments (self ) -> dict [str , str ]:
297
297
"""
298
298
Retrieves all comments associated with parameters from intermediate parameter files.
299
299
@@ -311,7 +311,7 @@ def __all_intermediate_parameter_file_comments(self) -> Dict[str, str]:
311
311
ret [param ] = info .comment
312
312
return ret
313
313
314
- def annotate_intermediate_comments_to_param_dict (self , param_dict : Dict [str , float ]) -> Dict [str , "Par" ]:
314
+ def annotate_intermediate_comments_to_param_dict (self , param_dict : dict [str , float ]) -> dict [str , "Par" ]:
315
315
"""
316
316
Annotates comments from intermediate parameter files to a parameter value-only dictionary.
317
317
@@ -331,7 +331,7 @@ def annotate_intermediate_comments_to_param_dict(self, param_dict: Dict[str, flo
331
331
ret [param ] = Par (float (value ), ip_comments .get (param , "" ))
332
332
return ret
333
333
334
- def categorize_parameters (self , param : Dict [str , "Par" ]) -> Tuple [ Dict [str , "Par" ], Dict [str , "Par" ], Dict [str , "Par" ]]:
334
+ def categorize_parameters (self , param : dict [str , "Par" ]) -> tuple [ dict [str , "Par" ], dict [str , "Par" ], dict [str , "Par" ]]:
335
335
"""
336
336
Categorize parameters into three categories based on their default values and documentation attributes.
337
337
@@ -393,7 +393,7 @@ def add_configuration_file_to_zip(self, zipf, filename):
393
393
if self .vehicle_configuration_file_exists (filename ):
394
394
zipf .write (os_path .join (self .vehicle_dir , filename ), arcname = filename )
395
395
396
- def zip_files (self , files_to_zip : List [ Tuple [bool , str ]]):
396
+ def zip_files (self , files_to_zip : list [ tuple [bool , str ]]):
397
397
"""
398
398
Zips the intermediate parameter files that were written to, including specific summary files.
399
399
@@ -469,7 +469,7 @@ def tempcal_imu_result_param_tuple(self):
469
469
tempcal_imu_result_param_filename = "03_imu_temperature_calibration_results.param"
470
470
return [tempcal_imu_result_param_filename , os_path .join (self .vehicle_dir , tempcal_imu_result_param_filename )]
471
471
472
- def copy_fc_values_to_file (self , selected_file : str , params : Dict [str , float ]):
472
+ def copy_fc_values_to_file (self , selected_file : str , params : dict [str , float ]):
473
473
ret = 0
474
474
if selected_file in self .file_parameters :
475
475
for param , v in self .file_parameters [selected_file ].items ():
@@ -553,7 +553,7 @@ def get_eval_variables(self):
553
553
variables ["doc_dict" ] = self .doc_dict
554
554
return variables
555
555
556
- def copy_fc_params_values_to_template_created_vehicle_files (self , fc_parameters : Dict [str , float ]):
556
+ def copy_fc_params_values_to_template_created_vehicle_files (self , fc_parameters : dict [str , float ]):
557
557
eval_variables = self .get_eval_variables ()
558
558
for param_filename , param_dict in self .file_parameters .items ():
559
559
for param_name , param in param_dict .items ():
@@ -570,18 +570,18 @@ def copy_fc_params_values_to_template_created_vehicle_files(self, fc_parameters:
570
570
Par .export_to_param (Par .format_params (param_dict ), os_path .join (self .vehicle_dir , param_filename ))
571
571
return ""
572
572
573
- def write_param_default_values (self , param_default_values : Dict [str , "Par" ]) -> bool :
573
+ def write_param_default_values (self , param_default_values : dict [str , "Par" ]) -> bool :
574
574
param_default_values = dict (sorted (param_default_values .items ()))
575
575
if self .param_default_dict != param_default_values :
576
576
self .param_default_dict = param_default_values
577
577
return True
578
578
return False
579
579
580
- def write_param_default_values_to_file (self , param_default_values : Dict [str , "Par" ], filename : str = "00_default.param" ):
580
+ def write_param_default_values_to_file (self , param_default_values : dict [str , "Par" ], filename : str = "00_default.param" ):
581
581
if self .write_param_default_values (param_default_values ):
582
582
Par .export_to_param (Par .format_params (self .param_default_dict ), os_path .join (self .vehicle_dir , filename ))
583
583
584
- def get_download_url_and_local_filename (self , selected_file : str ) -> Tuple [str , str ]:
584
+ def get_download_url_and_local_filename (self , selected_file : str ) -> tuple [str , str ]:
585
585
if (
586
586
selected_file in self .configuration_steps
587
587
and "download_file" in self .configuration_steps [selected_file ]
@@ -593,7 +593,7 @@ def get_download_url_and_local_filename(self, selected_file: str) -> Tuple[str,
593
593
return src , os_path .join (self .vehicle_dir , dst )
594
594
return "" , ""
595
595
596
- def get_upload_local_and_remote_filenames (self , selected_file : str ) -> Tuple [str , str ]:
596
+ def get_upload_local_and_remote_filenames (self , selected_file : str ) -> tuple [str , str ]:
597
597
if (
598
598
selected_file in self .configuration_steps
599
599
and "upload_file" in self .configuration_steps [selected_file ]
0 commit comments