From 52d6f390efd2d0297d1de2d6a216164f9928ac63 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Mon, 31 Aug 2020 19:09:35 +0200 Subject: [PATCH] Better option - strip just the extension. --- wutils.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/wutils.py b/wutils.py index 29cbf0ad5..7a4b19e19 100644 --- a/wutils.py +++ b/wutils.py @@ -178,14 +178,13 @@ def get_run_program(program_string, command_template=None): argv = shlex.split(program_string) #print "%r ==shlex.split==> %r" % (program_string, argv) program_name = argv[0] + + # if the script name ends with .cc - strip it + if program_name.endswith('.cc'): + program_name = program_name.rsplit('.', 1)[0] try: program_obj = find_program(program_name, env) - except ValueError as ex: - pass # try if the use passed the whole script name (i.e., including the '.cc' at the end) - try: - program_name = program_name.replace('.cc', '') - program_obj = find_program(program_name, env) except ValueError as ex: raise WafError(str(ex)) @@ -200,13 +199,13 @@ def get_run_program(program_string, command_template=None): else: program_name = program_string + + # if the script name ends with .cc - strip it + if program_name.endswith('.cc'): + program_name = program_name.rsplit('.', 1)[0] + try: program_obj = find_program(program_name, env) - except ValueError as ex: - pass # try if the use passed the whole script name (i.e., including the '.cc' at the end) - try: - program_name = program_name.replace('.cc', '') - program_obj = find_program(program_name, env) except ValueError as ex: raise WafError(str(ex))