File tree Expand file tree Collapse file tree
ardupilot_methodic_configurator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -430,20 +430,17 @@ def next_import_filename(vehicle_dir: str) -> str:
430430 """Return the next available numbered parameter filename for imported log parameters."""
431431 highest_prefix = 0
432432 try :
433- directory_iter = Path (vehicle_dir ).iterdir ()
433+ for file_path in Path (vehicle_dir ).iterdir ():
434+ if not file_path .is_file () or file_path .suffix != ".param" :
435+ continue
436+ prefix = file_path .name [:2 ]
437+ if prefix .isdigit ():
438+ highest_prefix = max (highest_prefix , int (prefix ))
434439 except OSError as exc :
435440 msg = _ ("Could not scan the vehicle directory for imported parameter files: {vehicle_dir}. {error}" ).format (
436441 vehicle_dir = vehicle_dir , error = str (exc )
437442 )
438443 raise VehicleProjectCreationError (_ ("Parameter import" ), msg ) from exc
439-
440- for file_path in directory_iter :
441- if not file_path .is_file () or file_path .suffix != ".param" :
442- continue
443- prefix = file_path .name [:2 ]
444- if prefix .isdigit ():
445- highest_prefix = max (highest_prefix , int (prefix ))
446-
447444 next_prefix = highest_prefix + 1
448445 if next_prefix > 99 :
449446 msg = _ ("Could not create an import parameter file because no numbered slot is available in {vehicle_dir}" )
You can’t perform that action at this time.
0 commit comments