@@ -472,11 +472,7 @@ def locate_config(root: str) -> str | None:
472
472
config_path = os .path .join (root , f )
473
473
return config_path
474
474
475
- if args .debug_filepath is None :
476
- error_exit ("'debug_filepath' not specified for parsing test" )
477
- file_exists = os .path .isfile (args .debug_filepath )
478
- if file_exists is False :
479
- error_exit ("Specified 'debug_filepath' does not exist" )
475
+ ensure_file_accessible (args .debug_filepath )
480
476
# Get preprocessor definitions from config file
481
477
pp_suffixes = None
482
478
pp_defs = {}
@@ -520,13 +516,15 @@ def locate_config(root: str) -> str | None:
520
516
print ("{}: {}" .format (obj .get_type (), obj .FQSN ))
521
517
522
518
519
+ def ensure_file_accessible (filepath : str ):
520
+ """Ensure the file exists and is accessible, raising an error if not."""
521
+ if not os .path .isfile (filepath ):
522
+ error_exit (f"File '{ filepath } ' does not exist or is not accessible" )
523
+ print (f' File = "{ filepath } "' )
524
+
525
+
523
526
def check_request_params (args , loc_needed = True ):
524
- if args .debug_filepath is None :
525
- error_exit ("'debug_filepath' not specified for debug request" )
526
- file_exists = os .path .isfile (args .debug_filepath )
527
- if file_exists is False :
528
- error_exit ("Specified 'debug_filepath' does not exist" )
529
- print (f' File = "{ args .debug_filepath } "' )
527
+ ensure_file_accessible (args .debug_filepath )
530
528
if loc_needed :
531
529
if args .debug_line is None :
532
530
error_exit ("'debug_line' not specified for debug request" )
0 commit comments